Skip to content

Commit

Permalink
Bump gems to latest
Browse files Browse the repository at this point in the history
* Use RSpec 2.0 syntax and remove `.should`
* Use AWS-SDK v2
* Correct usage of `CommandParser` for latest version
  • Loading branch information
siruguri committed Jan 9, 2016
1 parent 87115c7 commit 81925b2
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 91 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
language: ruby
before_install: gem install bundler
script: bundle exec rspec
rvm:
- 2.0.0
- 2.1.0
- 2.2.0
59 changes: 31 additions & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,43 @@ PATH
remote: .
specs:
s3sync (2.0.2)
aws-sdk
cmdparse
aws-sdk (< 2.2)
cmdparse (~> 3.0)

GEM
remote: https://rubygems.org/
specs:
aws-sdk (1.31.3)
json (~> 1.4)
nokogiri (>= 1.4.4)
uuidtools (~> 2.1)
bump (0.5.0)
cmdparse (2.0.5)
aws-sdk (2.1.36)
aws-sdk-resources (= 2.1.36)
aws-sdk-core (2.1.36)
jmespath (~> 1.0)
aws-sdk-resources (2.1.36)
aws-sdk-core (= 2.1.36)
bump (0.5.3)
cmdparse (3.0.1)
diff-lcs (1.2.5)
docile (1.1.1)
json (1.8.1)
mini_portile (0.5.2)
multi_json (1.8.2)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
rake (10.1.1)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.7)
rspec-expectations (2.14.4)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.4)
simplecov (0.8.2)
docile (1.1.5)
jmespath (1.1.3)
json (1.8.3)
rake (10.4.2)
rspec (3.4.0)
rspec-core (~> 3.4.0)
rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.4.0)
rspec-core (3.4.1)
rspec-support (~> 3.4.0)
rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-mocks (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
simplecov (0.11.1)
docile (~> 1.1.0)
multi_json
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
uuidtools (2.1.4)
json (~> 1.8)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)

PLATFORMS
ruby
Expand Down
52 changes: 23 additions & 29 deletions lib/s3sync/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
require 's3sync/version'
require 's3sync/exceptions'
require 's3sync/sync'
require 'aws/s3'
require 'aws-sdk'
require 'cmdparse'


Expand Down Expand Up @@ -63,9 +63,9 @@ def usage
u.join ''
end

def execute(args)
def execute(*args)
# Connecting to amazon
s3 = AWS::S3.new
s3 = AWS::S3::Client.new

# From the command line
key, file = args
Expand Down Expand Up @@ -101,7 +101,7 @@ def parse_acl(opt)

class ListBuckets < BaseCmd
def initialize
super 'listbuckets', false, false, false
super 'listbuckets', takes_commands: false #, false, false

@short_desc = "List all available buckets for your user"
end
Expand All @@ -117,11 +117,11 @@ class CreateBucket < BaseCmd
attr_accessor :acl

def initialize
super 'createbucket', false, false
super 'createbucket', takes_commands: false #, false

@short_desc = "Create a new bucket under your user account"

self.options = CmdParse::OptionParserWrapper.new do |opt|
self.options do |opt|
parse_acl(opt)
end
end
Expand All @@ -147,13 +147,13 @@ class DeleteBucket < BaseCmd
attr_accessor :force

def initialize
super 'deletebucket', false, false
super 'deletebucket', takes_commands: false #, false

@short_desc = "Remove a bucket from your account"

@force = false

self.options = CmdParse::OptionParserWrapper.new do |opt|
self.options do |opt|
opt.on("-f", "--force", "Clean the bucket then deletes it") {|f|
@force = f
}
Expand All @@ -179,7 +179,7 @@ class List < BaseCmd
attr_accessor :max_entries

def initialize
super 'list', false, false
super 'list', takes_commands: false #, false

@short_desc = "List items filed under a given bucket"

Expand All @@ -189,7 +189,7 @@ def initialize

@has_prefix = true

self.options = CmdParse::OptionParserWrapper.new do |opt|
self.options do |opt|
opt.on("-m", "--max-entries=NUM", "Limit the number of entries to output") {|m|
@max_entries = m
}
Expand Down Expand Up @@ -223,7 +223,7 @@ def run s3, bucket, key, file, args

class Delete < BaseCmd
def initialize
super 'delete', false, false
super 'delete', takes_commands: false #, false

@short_desc = "Delete a key from a bucket"

Expand All @@ -242,7 +242,7 @@ class Url < BaseCmd
attr_accessor :secure

def initialize
super 'url', false, false
super 'url', takes_commands: false #, false

@short_desc = "Generates public urls or authenticated endpoints for the object"
@description = "Notice that --method and --public are mutually exclusive"
Expand All @@ -252,7 +252,7 @@ def initialize
@expires_in = false
@has_prefix = 'required'

self.options = CmdParse::OptionParserWrapper.new do |opt|
self.options do |opt|
opt.on("-m", "--method=METHOD", "Options: #{AVAILABLE_METHODS.join ', '}") {|m|
@method = m
}
Expand Down Expand Up @@ -305,7 +305,7 @@ def run s3, bucket, key, file, args

class Put < BaseCmd
def initialize
super 'put', false, false
super 'put', takes_commands: false #, false

@short_desc = 'Upload a file to a bucket under a certain prefix'
@has_prefix = true
Expand All @@ -326,7 +326,7 @@ def run s3, bucket, key, file, args

class Get < BaseCmd
def initialize
super 'get', false, false
super 'get', takes_commands: false #, false
@short_desc = "Retrieve an object and save to the specified file"
@has_prefix = 'required'
end
Expand Down Expand Up @@ -359,7 +359,7 @@ class Sync < BaseCmd
attr_accessor :acl

def initialize
super 'sync', false, false
super 'sync', takes_commands: false #, false

@short_desc = "Synchronize an S3 and a local folder"
@s3 = nil
Expand All @@ -368,7 +368,7 @@ def initialize
@dry_run = false
@verbose = false

self.options = CmdParse::OptionParserWrapper.new do |opt|
self.options do |opt|
opt.on("-x EXPR", "--exclude=EXPR", "Skip copying files that matches this pattern. (Ruby REs)") {|v|
@exclude = v
}
Expand Down Expand Up @@ -425,22 +425,16 @@ def run s3, bucket, key, file, args
end

def run conf
cmd = CmdParse::CommandParser.new true
cmd.program_name = File.basename $0
cmd.program_version = S3Sync::VERSION
cmd = CmdParse::CommandParser.new handle_exceptions: true
cmd.main_options do |opt|
opt.program_name = File.basename $0
opt.version = S3Sync::VERSION
end

cmd.options = CmdParse::OptionParserWrapper.new do |opt|
cmd.global_options do |opt|
opt.separator "Global options:"
end

cmd.main_command.short_desc = 'Tool belt for managing your S3 buckets'
cmd.main_command.description =<<END.strip
S3Sync provides a list of commands that will allow you to manage your content
stored in S3 buckets. To learn about each feature, please use the `help`
command:
$ #{File.basename $0} help sync"
END
# Commands used more often
cmd.add_command List.new
cmd.add_command Delete.new
Expand Down
5 changes: 3 additions & 2 deletions s3sync.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ Gem::Specification.new do |spec|

spec.homepage = "https://github.com/clarete/s3sync"
spec.license = "MIT"
spec.required_ruby_version = '~>2'

spec.files = `git ls-files lib bin`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }

# Library requirements
spec.add_dependency "aws-sdk", "< 2.0"
spec.add_dependency "cmdparse", "~> 2.0"
spec.add_dependency "aws-sdk", "< 2.2"
spec.add_dependency "cmdparse", "~> 3.0"

# Development requirements
spec.add_development_dependency "simplecov"
Expand Down
2 changes: 1 addition & 1 deletion spec/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
expect {
# When I execute it with a mocked s3 instance
command.run(s3, nil, nil, nil, nil)
}.to match_stdout('b1\nb2\n')
}.to output("b1\nb2\n").to_stdout
end

it "Should be able to create buckets" do
Expand Down
4 changes: 2 additions & 2 deletions spec/local_source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# Then I see that the directory nodes contain both their parent paths and
# their names
local.list_files.should be_eql({
expect(local.list_files).to eql({
"file1.txt" => Node.new(fixture("directory2"), "file1.txt", 10),
"file2.txt" => Node.new(fixture("directory2"), "file2.txt", 11),
})
Expand All @@ -42,7 +42,7 @@

# Then I see that the directory nodes contain both their parent paths and
# their names
local.list_files.should be_eql({
expect(local.list_files).to eql({
"file1.txt" => Node.new(fixture("directory2"), "file1.txt", 10),
"file2.txt" => Node.new(fixture("directory2"), "file2.txt", 11),
"subd/sub1.txt" => Node.new(fixture("directory2"), "subd/sub1.txt", 11),
Expand Down
Loading

0 comments on commit 81925b2

Please sign in to comment.