cliaws 1.2.5 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +6 -0
- data/bin/clis3 +34 -17
- data/bin/clisqs +0 -0
- data/lib/cliaws/s3.rb +4 -4
- data/lib/cliaws/version.rb +2 -2
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 1.3.0 2008-10-01
|
2
|
+
|
3
|
+
* Rewrote the algorithm for "clis3 put". The new algorithm is saner, and prevents writing
|
4
|
+
0 byte files when the input's size is unknown and cannot be determined.
|
5
|
+
* Return an exit status of 0 on normal exit on clis3 put.
|
6
|
+
|
1
7
|
== 1.2.5 2008-09-15
|
2
8
|
|
3
9
|
* More testing for "clis3 put - S3_OBJECT" and "cat x | clis3 put S3_OBJECT" highlighted
|
data/bin/clis3
CHANGED
@@ -71,36 +71,53 @@ Main {
|
|
71
71
|
paths = params["files_or_s3_path"].values
|
72
72
|
s3_object = paths.pop
|
73
73
|
|
74
|
+
single_put_mapper = lambda do |source, s3_path|
|
75
|
+
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)
|
76
|
+
s3_path
|
77
|
+
end
|
78
|
+
|
79
|
+
multi_put_mapper = lambda do |source, s3_path|
|
80
|
+
if source.respond_to?(:path) then
|
81
|
+
File.join(s3_path, File.basename(source.path))
|
82
|
+
else
|
83
|
+
raise ArgumentError, "Cannot write to a directory when one or more sources are not files: #{source.inspect}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
74
87
|
if params["data"].given? && !paths.empty? then
|
75
88
|
raise ArgumentError, "Cannot specify both --data and filename(s) to send."
|
76
89
|
elsif params["data"].given? then
|
77
|
-
|
90
|
+
sources = [StringIO.new(params["data"].value)]
|
91
|
+
mapper = single_put_mapper
|
78
92
|
elsif paths == ["-"] then
|
79
|
-
|
93
|
+
sources = [STDIN]
|
94
|
+
mapper = single_put_mapper
|
80
95
|
else
|
81
96
|
targets = paths.map {|filename| filename.to_s}
|
82
97
|
case targets.length
|
83
98
|
when 0
|
84
|
-
|
99
|
+
sources = [STDIN]
|
100
|
+
mapper = single_put_mapper
|
85
101
|
when 1
|
86
|
-
File.open(
|
87
|
-
|
88
|
-
end
|
89
|
-
exit 0
|
102
|
+
sources = targets.map {|target| File.open(target, "rb")}
|
103
|
+
mapper = single_put_mapper
|
90
104
|
else
|
91
|
-
targets.
|
92
|
-
|
93
|
-
remote_file = File.join(s3_object, File.basename(local_file))
|
94
|
-
puts "%-30s => %s" % [local_file, remote_file]
|
95
|
-
Cliaws.s3.put(source, remote_file)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
exit 0
|
105
|
+
sources = targets.map {|target| File.open(target, "rb")}
|
106
|
+
mapper = multi_put_mapper
|
99
107
|
end
|
100
108
|
end
|
101
109
|
|
102
|
-
|
103
|
-
|
110
|
+
sources.each do |source|
|
111
|
+
target = mapper.call(source, s3_object)
|
112
|
+
if source.respond_to?(:path) then
|
113
|
+
puts "#{source.path} => #{target}"
|
114
|
+
else
|
115
|
+
puts "STDIN => #{target}"
|
116
|
+
end
|
117
|
+
|
118
|
+
Cliaws.s3.put(source, target)
|
119
|
+
end
|
120
|
+
exit_success!
|
104
121
|
|
105
122
|
rescue Cliaws::S3::UnknownBucket
|
106
123
|
abort "Could not find bucket named #{$!.bucket_name}"
|
data/bin/clisqs
CHANGED
File without changes
|
data/lib/cliaws/s3.rb
CHANGED
@@ -45,8 +45,8 @@ module Cliaws
|
|
45
45
|
puts headers.merge(key.meta_headers).to_yaml
|
46
46
|
end
|
47
47
|
|
48
|
-
def put(source, s3_object)
|
49
|
-
bucket, keyname = bucket_and_key_name(s3_object)
|
48
|
+
def put(source, s3_object, create=true)
|
49
|
+
bucket, keyname = bucket_and_key_name(s3_object, create)
|
50
50
|
bucket.put(keyname, source)
|
51
51
|
end
|
52
52
|
|
@@ -56,9 +56,9 @@ module Cliaws
|
|
56
56
|
end
|
57
57
|
|
58
58
|
protected
|
59
|
-
def bucket_and_key_name(full_name)
|
59
|
+
def bucket_and_key_name(full_name, create=true)
|
60
60
|
bucket_name, path = full_name.split("/", 2)
|
61
|
-
bucket = s3.bucket(bucket_name,
|
61
|
+
bucket = s3.bucket(bucket_name, create)
|
62
62
|
raise UnknownBucket.new(bucket_name) unless bucket
|
63
63
|
[bucket, path]
|
64
64
|
end
|
data/lib/cliaws/version.rb
CHANGED
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.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Fran\xC3\xA7ois Beausoleil"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-10-01 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|