s3cp 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ === 1.0.2 / 2012-03-9
2
+
3
+ * Added: `s3up` now outputs uploaded file size to STDERR, e.g.,
4
+
5
+ % ls | s3up s3://bucket/path/to/file
6
+ s3://bucket/path/to/file => 214B
7
+
1
8
  === 1.0.1 / 2012-03-9
2
9
 
3
10
  * Added: New command `s3up` to upload STDIN to S3
data/lib/s3cp/s3cp.rb CHANGED
@@ -207,19 +207,7 @@ def log(msg)
207
207
  puts msg if @verbose
208
208
  end
209
209
 
210
- def headers_array_to_hash(header_array)
211
- headers = {}
212
- header_array.each do |header|
213
- header_parts = header.split(": ", 2)
214
- if header_parts.size == 2
215
- headers[header_parts[0].downcase] = header_parts[1] # RightAWS gem expect lowercase header names :(
216
- else
217
- log("Header ignored because of error splitting [#{header}]. Expected colon delimiter; e.g. Header: Value")
218
- end
219
- end
220
- headers
221
- end
222
- @headers = headers_array_to_hash(options[:headers])
210
+ @headers = S3CP.headers_array_to_hash(options[:headers])
223
211
 
224
212
  def with_headers(msg)
225
213
  unless @headers.empty?
data/lib/s3cp/s3up.rb CHANGED
@@ -54,19 +54,7 @@ unless ARGV.size > 0
54
54
  exit
55
55
  end
56
56
 
57
- def headers_array_to_hash(header_array)
58
- headers = {}
59
- header_array.each do |header|
60
- header_parts = header.split(": ", 2)
61
- if header_parts.size == 2
62
- headers[header_parts[0].downcase] = header_parts[1] # RightAWS gem expect lowercase header names :(
63
- else
64
- log("Header ignored because of error splitting [#{header}]. Expected colon delimiter; e.g. Header: Value")
65
- end
66
- end
67
- headers
68
- end
69
- @headers = headers_array_to_hash(options[:headers])
57
+ @headers = S3CP.headers_array_to_hash(options[:headers])
70
58
 
71
59
  url = ARGV[0]
72
60
 
@@ -77,7 +65,6 @@ fail "Your URL looks funny, doesn't it?" unless bucket
77
65
 
78
66
  # copy all of STDIN to a temp file
79
67
  temp = Tempfile.new('s3cp')
80
- f = File.new("newfile2.zip", "wb")
81
68
  while true
82
69
  begin
83
70
  data = STDIN.sysread(4 * 1024)
@@ -92,6 +79,7 @@ temp.open
92
79
  # upload temp file
93
80
  begin
94
81
  @s3.interface.put(bucket, key, temp, @headers)
82
+ STDERR.puts "s3://#{bucket}/#{key} => #{S3CP.format_filesize(temp.size)} "
95
83
  ensure
96
84
  # cleanup
97
85
  temp.close
data/lib/s3cp/utils.rb CHANGED
@@ -45,6 +45,19 @@ module S3CP
45
45
  [bucket, key]
46
46
  end
47
47
 
48
+ def headers_array_to_hash(header_array)
49
+ headers = {}
50
+ header_array.each do |header|
51
+ header_parts = header.split(": ", 2)
52
+ if header_parts.size == 2
53
+ headers[header_parts[0].downcase] = header_parts[1] # RightAWS gem expect lowercase header names :(
54
+ else
55
+ fail("Invalid header value; expected single colon delimiter; e.g. Header: Value")
56
+ end
57
+ end
58
+ headers
59
+ end
60
+
48
61
  # Round a number at some `decimals` level of precision.
49
62
  def round(n, decimals = 0)
50
63
  (n * (10.0 ** decimals)).round * (10.0 ** (-decimals))
data/lib/s3cp/version.rb CHANGED
@@ -16,5 +16,5 @@
16
16
  # the License.
17
17
 
18
18
  module S3CP
19
- VERSION = "1.0.1"
19
+ VERSION = "1.0.2"
20
20
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3cp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alex Boisvert