cliaws 1.7.4 → 1.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/Rakefile +1 -1
  2. data/VERSION +1 -1
  3. data/cliaws.gemspec +4 -4
  4. data/lib/cliaws/cli/s3.rb +115 -115
  5. metadata +5 -2
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ begin
11
11
  gemspec.executables = %w(clis3 clisqs cliec2)
12
12
  gemspec.extra_rdoc_files = %w(History.txt License.txt vendor/right_http_connection-1.2.1/README.txt)
13
13
 
14
- gemspec.add_dependency "thor", "< 0.10"
14
+ gemspec.add_dependency "thor", "> 0.11", "< 0.12"
15
15
  gemspec.add_dependency "right_aws", "~> 1.10"
16
16
  end
17
17
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.7.4
1
+ 1.7.6
data/cliaws.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{cliaws}
5
- s.version = "1.7.4"
5
+ s.version = "1.7.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Fran\303\247ois Beausoleil"]
@@ -46,14 +46,14 @@ Gem::Specification.new do |s|
46
46
  s.specification_version = 3
47
47
 
48
48
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49
- s.add_runtime_dependency(%q<thor>, ["< 0.10"])
49
+ s.add_runtime_dependency(%q<thor>, ["> 0.11", "< 0.12"])
50
50
  s.add_runtime_dependency(%q<right_aws>, ["~> 1.10"])
51
51
  else
52
- s.add_dependency(%q<thor>, ["< 0.10"])
52
+ s.add_dependency(%q<thor>, ["> 0.11", "< 0.12"])
53
53
  s.add_dependency(%q<right_aws>, ["~> 1.10"])
54
54
  end
55
55
  else
56
- s.add_dependency(%q<thor>, ["< 0.10"])
56
+ s.add_dependency(%q<thor>, ["> 0.11", "< 0.12"])
57
57
  s.add_dependency(%q<right_aws>, ["~> 1.10"])
58
58
  end
59
59
  end
data/lib/cliaws/cli/s3.rb CHANGED
@@ -2,9 +2,9 @@ require "thor"
2
2
  require "cliaws"
3
3
 
4
4
  module Cliaws
5
- module Cli
6
- class S3 < Thor
7
- map ["-h", "--help"] => :help
5
+ module Cli
6
+ class S3 < Thor
7
+ map ["-h", "--help"] => :help
8
8
 
9
9
  desc "buckets", <<EOD
10
10
  Returns a list of bucket names.
@@ -32,16 +32,16 @@ EOD
32
32
  bucket.delete(options[:force])
33
33
  end
34
34
 
35
- desc "url S3_OBJECT_PATH", <<EOD
35
+ desc "url S3_OBJECT_PATH", <<EOD
36
36
  Returns a signed, private, URL to the given S3 object that is valid for 24 hours.
37
37
  EOD
38
- def url(s3_object)
39
- puts Cliaws.s3.url(s3_object)
40
- rescue Cliaws::S3::UnknownBucket
41
- abort "Could not find bucket named #{$!.bucket_name}"
42
- end
38
+ def url(s3_object)
39
+ puts Cliaws.s3.url(s3_object)
40
+ rescue Cliaws::S3::UnknownBucket
41
+ abort "Could not find bucket named #{$!.bucket_name}"
42
+ end
43
43
 
44
- desc "list [S3_OBJECT_PATH_PREFIX]", <<EOD
44
+ desc "list [S3_OBJECT_PATH_PREFIX]", <<EOD
45
45
  Lists all S3 objects that start with the given string.
46
46
 
47
47
  EXAMPLES
@@ -61,24 +61,24 @@ photos/johnson_and_us.jpg
61
61
  $ clis3 list vacation/p
62
62
  photos/johnson_and_us.jpg
63
63
  EOD
64
- def list(prefix="")
65
- puts Cliaws.s3.list(prefix)
66
- rescue Cliaws::S3::UnknownBucket
67
- abort "Could not find bucket named #{$!.bucket_name}"
68
- end
64
+ def list(prefix="")
65
+ puts Cliaws.s3.list(prefix)
66
+ rescue Cliaws::S3::UnknownBucket
67
+ abort "Could not find bucket named #{$!.bucket_name}"
68
+ end
69
69
 
70
- desc "touch S3_OBJECT_PATH", <<EOD
70
+ desc "touch S3_OBJECT_PATH", <<EOD
71
71
  Creates or OVERWRITES a named file at the specified path.
72
72
 
73
73
  WARNING: If the file already exists, IT WILL BE OVERWRITTEN with no content.
74
74
  EOD
75
- def touch(s3_object)
76
- Cliaws.s3.put("", s3_object)
77
- rescue Cliaws::S3::UnknownBucket
78
- abort "Could not find bucket named #{$!.bucket_name}"
79
- end
75
+ def touch(s3_object)
76
+ Cliaws.s3.put("", s3_object)
77
+ rescue Cliaws::S3::UnknownBucket
78
+ abort "Could not find bucket named #{$!.bucket_name}"
79
+ end
80
80
 
81
- desc "put [LOCAL_FILE [LOCAL_FILE ...]] S3_PATH", <<EOD
81
+ desc "put [LOCAL_FILE [LOCAL_FILE ...]] S3_PATH", <<EOD
82
82
  Puts one or more named local files, or a simple string, to a path.
83
83
 
84
84
  This method has the same interface as cp(1).
@@ -91,108 +91,108 @@ $ clis3 put photos/peter.jpg photos/sarah.jpg vacation/2009/photos/hosts
91
91
  $ clis3 put movies vacation/2009/movies
92
92
  EOD
93
93
  method_options :data => :string
94
- def put(*args)
95
- paths = args
96
- s3_object = paths.pop
97
-
98
- single_put_mapper = lambda do |source, s3_path|
99
- raise ArgumentError, "Writing directly from STDIN is forbidden when STDIN's size is unknown. The RightAws library will write a zero-byte file to Amazon's servers." unless source.respond_to?(:lstat) || source.respond_to?(:size)
100
- s3_path
101
- end
102
-
103
- multi_put_mapper = lambda do |source, s3_path|
104
- if source.respond_to?(:path) then
105
- File.join(s3_path, File.basename(source.path))
106
- else
107
- raise ArgumentError, "Cannot write to a directory when one or more sources are not files: #{source.inspect}"
108
- end
109
- end
110
-
111
- if options[:data] && !paths.empty? then
112
- raise ArgumentError, "Cannot specify both --data and filename(s) to send."
113
- elsif options[:data] then
114
- sources = [StringIO.new(options[:data])]
115
- mapper = single_put_mapper
116
- elsif paths == ["-"] then
117
- sources = [STDIN]
118
- mapper = single_put_mapper
119
- else
120
- targets = paths.map {|filename| filename.to_s}
121
- case targets.length
122
- when 0
123
- sources = [STDIN]
124
- mapper = single_put_mapper
125
- when 1
126
- sources = targets.map {|target| File.open(target, "rb")}
127
- mapper = single_put_mapper
128
- else
129
- sources = targets.map {|target| File.open(target, "rb")}
130
- mapper = multi_put_mapper
131
- end
132
- end
133
-
134
- sources.each do |source|
135
- target = mapper.call(source, s3_object)
136
- if source.respond_to?(:path) then
137
- puts "#{source.path} => #{target}"
138
- else
139
- puts "STDIN => #{target}"
140
- end
141
-
142
- Cliaws.s3.put(source, target)
143
- end
144
- rescue Cliaws::S3::UnknownBucket
145
- abort "Could not find bucket named #{$!.bucket_name}"
146
- end
147
-
148
- desc "rm S3_OBJECT [S3_OBJECT ...]", <<EOD
94
+ def put(*args)
95
+ paths = args
96
+ s3_object = paths.pop
97
+
98
+ single_put_mapper = lambda do |source, s3_path|
99
+ raise ArgumentError, "Writing directly from STDIN is forbidden when STDIN's size is unknown. The RightAws library will write a zero-byte file to Amazon's servers." unless source.respond_to?(:lstat) || source.respond_to?(:size)
100
+ s3_path
101
+ end
102
+
103
+ multi_put_mapper = lambda do |source, s3_path|
104
+ if source.respond_to?(:path) then
105
+ File.join(s3_path, File.basename(source.path))
106
+ else
107
+ raise ArgumentError, "Cannot write to a directory when one or more sources are not files: #{source.inspect}"
108
+ end
109
+ end
110
+
111
+ if options[:data] && !paths.empty? then
112
+ raise ArgumentError, "Cannot specify both --data and filename(s) to send."
113
+ elsif options[:data] then
114
+ sources = [StringIO.new(options[:data])]
115
+ mapper = single_put_mapper
116
+ elsif paths == ["-"] then
117
+ sources = [STDIN]
118
+ mapper = single_put_mapper
119
+ else
120
+ targets = paths.map {|filename| filename.to_s}
121
+ case targets.length
122
+ when 0
123
+ sources = [STDIN]
124
+ mapper = single_put_mapper
125
+ when 1
126
+ sources = targets.map {|target| File.open(target, "rb")}
127
+ mapper = single_put_mapper
128
+ else
129
+ sources = targets.map {|target| File.open(target, "rb")}
130
+ mapper = multi_put_mapper
131
+ end
132
+ end
133
+
134
+ sources.each do |source|
135
+ target = mapper.call(source, s3_object)
136
+ if source.respond_to?(:path) then
137
+ puts "#{source.path} => #{target}"
138
+ else
139
+ puts "STDIN => #{target}"
140
+ end
141
+
142
+ Cliaws.s3.put(source, target)
143
+ end
144
+ rescue Cliaws::S3::UnknownBucket
145
+ abort "Could not find bucket named #{$!.bucket_name}"
146
+ end
147
+
148
+ desc "rm S3_OBJECT [S3_OBJECT ...]", <<EOD
149
149
  Deletes one or more S3 objects.
150
150
 
151
151
  Does not accept wildcards: each path to delete must be named individually.
152
152
  EOD
153
- def rm(*paths)
154
- paths.each do |path|
155
- puts "rm #{path}"
156
- Cliaws.s3.rm(path)
157
- end
158
- rescue Cliaws::S3::UnknownBucket
159
- abort "Could not find bucket named #{$!.bucket_name}"
160
- end
161
-
162
- desc "cat S3_OBJECT", <<EOD
153
+ def rm(*paths)
154
+ paths.each do |path|
155
+ puts "rm #{path}"
156
+ Cliaws.s3.rm(path)
157
+ end
158
+ rescue Cliaws::S3::UnknownBucket
159
+ abort "Could not find bucket named #{$!.bucket_name}"
160
+ end
161
+
162
+ desc "cat S3_OBJECT", <<EOD
163
163
  Prints the contents of the named object to STDOUT.
164
164
  A single new line (\n) will be appended to the output.
165
165
  EOD
166
- def cat(s3_object)
167
- print Cliaws.s3.get(s3_object, STDOUT)
168
- puts
169
- rescue Cliaws::S3::UnknownBucket
170
- abort "Could not find bucket named #{$!.bucket_name}"
171
- end
172
-
173
- desc "get S3_OBJECT [LOCAL_FILE]", <<EOD
166
+ def cat(s3_object)
167
+ print Cliaws.s3.get(s3_object, STDOUT)
168
+ puts
169
+ rescue Cliaws::S3::UnknownBucket
170
+ abort "Could not find bucket named #{$!.bucket_name}"
171
+ end
172
+
173
+ desc "get S3_OBJECT [LOCAL_FILE]", <<EOD
174
174
  Returns the raw contents of the named object.
175
175
 
176
176
  If LOCAL_FILE is unspecified, it will default to STDOUT.
177
177
  EOD
178
- def get(s3_object, local_path=nil)
179
- out = if local_path then
180
- File.open(local_path, "wb")
181
- else
182
- STDOUT
183
- end
184
-
185
- Cliaws.s3.get(s3_object, out)
186
- rescue Cliaws::S3::UnknownBucket
187
- abort "Could not find bucket named #{$!.bucket_name}"
188
- end
189
-
190
- desc "head S3_OBJECT", "Returns a YAML representation of meta data that Amazon keeps about the named object"
191
- def head(s3_object)
192
- puts Cliaws.s3.head(s3_object).to_yaml
193
- rescue Cliaws::S3::UnknownBucket
194
- abort "Could not find bucket named #{$!.bucket_name}"
195
- end
178
+ def get(s3_object, local_path=nil)
179
+ out = if local_path then
180
+ File.open(local_path, "wb")
181
+ else
182
+ STDOUT
183
+ end
184
+
185
+ Cliaws.s3.get(s3_object, out)
186
+ rescue Cliaws::S3::UnknownBucket
187
+ abort "Could not find bucket named #{$!.bucket_name}"
188
+ end
189
+
190
+ desc "head S3_OBJECT", "Returns a YAML representation of meta data that Amazon keeps about the named object"
191
+ def head(s3_object)
192
+ puts Cliaws.s3.head(s3_object).to_yaml
193
+ rescue Cliaws::S3::UnknownBucket
194
+ abort "Could not find bucket named #{$!.bucket_name}"
195
+ end
196
196
 
197
197
  desc "grants BUCKET|KEY", <<EOD
198
198
  Returns a YAML representation of grants assigned to a bucket or key.
@@ -249,6 +249,6 @@ EOD
249
249
  Cliaws.s3.grant(thing, who => permissions.map {|perm| perm.gsub('_', '-')})
250
250
  grants(thing)
251
251
  end
252
- end
253
- end
252
+ end
253
+ end
254
254
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cliaws
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.4
4
+ version: 1.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Fran\xC3\xA7ois Beausoleil"
@@ -18,9 +18,12 @@ dependencies:
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: "0.11"
21
24
  - - <
22
25
  - !ruby/object:Gem::Version
23
- version: "0.10"
26
+ version: "0.12"
24
27
  version:
25
28
  - !ruby/object:Gem::Dependency
26
29
  name: right_aws