s3 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,11 +11,7 @@ It supports both: European and US buckets through {REST API}[http://docs.amazonw
11
11
 
12
12
  == Installation
13
13
 
14
- If you don't have the {Gemcutter sources}[http://gemcutter.org/pages/gem_docs] yet:
15
- gem sources -a http://gemcutter.org
16
-
17
- To install the gem type:
18
- gem install s3
14
+ gem install s3 --source http://gemcutter.org
19
15
 
20
16
  == Usage
21
17
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
@@ -151,10 +151,10 @@ module S3
151
151
  object_attributes = parse_copy_object_result(response.body)
152
152
 
153
153
  object = Object.send(:new, bucket, object_attributes.merge(:key => key, :size => size))
154
- object.acl = response[:x_amz_acl]
155
- object.content_type = response[:content_type]
156
- object.content_encoding = response[:content_encoding]
157
- object.content_disposition = response[:content_disposition]
154
+ object.acl = response["x-amz-acl"]
155
+ object.content_type = response["content-type"]
156
+ object.content_encoding = response["content-encoding"]
157
+ object.content_disposition = response["content-disposition"]
158
158
  object
159
159
  end
160
160
 
@@ -111,11 +111,13 @@ module S3
111
111
  # 'x-amz-meta-username: fred' and 'x-amz-meta-username: barney'
112
112
  # would be combined into the single header 'x-amz-meta-username:
113
113
  # fred,barney'.
114
- groupped_headers = headers.group_by { |i| i.first }
115
- #=> {"a"=>[["a", 1], ["a", 2]], "b"=>[["b", 3]], "c"=>[["c", 0]]}
116
- combined_headers = groupped_headers.map do |key, value|
117
- values = value.map { |e| e.last }
118
- [key, values.join(",")]
114
+ combined_headers = headers.inject([]) do |new_headers, header|
115
+ existing_header = new_headers.find { |h| h.first == header.first }
116
+ if existing_header
117
+ existing_header.last << ",#{header.last}"
118
+ else
119
+ new_headers << header
120
+ end
119
121
  end
120
122
  #=> [["a", "1,2"], ["b", "3"], ["c", "0"]]
121
123
 
@@ -0,0 +1,82 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{s3}
8
+ s.version = "0.2.6"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jakub Ku\305\272ma", "Miros\305\202aw Boruta"]
12
+ s.date = %q{2010-02-07}
13
+ s.default_executable = %q{s3}
14
+ s.description = %q{S3 library provides access to Amazon's Simple Storage Service. It supports both: European and US buckets through REST API.}
15
+ s.email = %q{qoobaa@gmail.com}
16
+ s.executables = ["s3"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/s3",
29
+ "extra/s3_attachment_fu.rb",
30
+ "extra/s3_paperclip.rb",
31
+ "lib/s3.rb",
32
+ "lib/s3/bucket.rb",
33
+ "lib/s3/connection.rb",
34
+ "lib/s3/exceptions.rb",
35
+ "lib/s3/object.rb",
36
+ "lib/s3/parser.rb",
37
+ "lib/s3/roxy/moxie.rb",
38
+ "lib/s3/roxy/proxy.rb",
39
+ "lib/s3/service.rb",
40
+ "lib/s3/signature.rb",
41
+ "s3.gemspec",
42
+ "test/bucket_test.rb",
43
+ "test/connection_test.rb",
44
+ "test/object_test.rb",
45
+ "test/service_test.rb",
46
+ "test/signature_test.rb",
47
+ "test/test_helper.rb"
48
+ ]
49
+ s.homepage = %q{http://jah.pl/projects/s3.html}
50
+ s.rdoc_options = ["--charset=UTF-8"]
51
+ s.require_paths = ["lib"]
52
+ s.rubygems_version = %q{1.3.5}
53
+ s.summary = %q{Library for accessing S3 objects and buckets, with command line tool}
54
+ s.test_files = [
55
+ "test/object_test.rb",
56
+ "test/test_helper.rb",
57
+ "test/bucket_test.rb",
58
+ "test/connection_test.rb",
59
+ "test/service_test.rb",
60
+ "test/signature_test.rb"
61
+ ]
62
+
63
+ if s.respond_to? :specification_version then
64
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
65
+ s.specification_version = 3
66
+
67
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
68
+ s.add_runtime_dependency(%q<trollop>, [">= 1.14"])
69
+ s.add_development_dependency(%q<test-unit>, [">= 2.0"])
70
+ s.add_development_dependency(%q<mocha>, [">= 0"])
71
+ else
72
+ s.add_dependency(%q<trollop>, [">= 1.14"])
73
+ s.add_dependency(%q<test-unit>, [">= 2.0"])
74
+ s.add_dependency(%q<mocha>, [">= 0"])
75
+ end
76
+ else
77
+ s.add_dependency(%q<trollop>, [">= 1.14"])
78
+ s.add_dependency(%q<test-unit>, [">= 2.0"])
79
+ s.add_dependency(%q<mocha>, [">= 0"])
80
+ end
81
+ end
82
+
@@ -219,7 +219,7 @@ class BucketTest < Test::Unit::TestCase
219
219
  assert @bucket.objects.reload
220
220
 
221
221
  expected = @objects_list
222
- actual = @bucket.objects
222
+ actual = @bucket.objects(true)
223
223
  assert_equal expected, actual
224
224
  end
225
225
 
@@ -86,9 +86,12 @@ class ConnectionTest < Test::Unit::TestCase
86
86
  end
87
87
 
88
88
  test "parse params with and without values" do
89
- expected = "max-keys=100&prefix"
90
- actual = S3::Connection.parse_params(:max_keys => 100, :prefix => nil)
91
- assert_equal expected, actual
89
+ params = S3::Connection.parse_params(:max_keys => 100, :prefix => nil)
90
+
91
+ splitted_params = params.split("&")
92
+ assert_equal 2, splitted_params.length
93
+ assert splitted_params.include?("max-keys=100")
94
+ assert splitted_params.include?("prefix")
92
95
  end
93
96
 
94
97
  test "headers empty" do
@@ -13,7 +13,7 @@ class ObjectTest < Test::Unit::TestCase
13
13
  @object_carmen = S3::Object.send(:new, @bucket_images, :key => "Carmen.png")
14
14
 
15
15
  @response_binary = Net::HTTPOK.new("1.1", "200", "OK")
16
- @response_binary.stubs(:body).returns("test".force_encoding(Encoding::BINARY))
16
+ @response_binary.stubs(:body).returns("test".respond_to?(:force_encoding) ? "test".force_encoding(Encoding::BINARY) : "test")
17
17
  @response_binary["etag"] = ""
18
18
  @response_binary["content-type"] = "image/png"
19
19
  @response_binary["content-disposition"] = "inline"
@@ -89,9 +89,9 @@ class SignatureTest < Test::Unit::TestCase
89
89
  request["date"] = "Tue, 27 Mar 2007 21:06:08 +0000"
90
90
  request["x-amz-acl"] = "public-read"
91
91
  request["content-type"] = "application/x-download"
92
- request["content-MD5"] = "4gJE4saaMU4BqNR0kLY+lw=="
93
- # TODO:
94
- # was:
92
+ request["content-md5"] = "4gJE4saaMU4BqNR0kLY+lw=="
93
+ # FIXME: Net::HTTP doesn't allow to have multiple headers with the same name
94
+ # request.add_field add additional spaces (breaks signature)
95
95
  #request["x-amz-meta-reviewedby"] = "joe@johnsmith.net"
96
96
  #request["x-amz-meta-reviewedby"] = "jane@johnsmith.net"
97
97
  request["x-amz-meta-reviewedby"] = "joe@johnsmith.net,jane@johnsmith.net"
@@ -1,4 +1,5 @@
1
1
  require "rubygems"
2
+ gem "test-unit"
2
3
  require "test/unit"
3
4
  require "mocha"
4
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jakub Ku\xC5\xBAma"
@@ -72,6 +72,7 @@ files:
72
72
  - lib/s3/roxy/proxy.rb
73
73
  - lib/s3/service.rb
74
74
  - lib/s3/signature.rb
75
+ - s3.gemspec
75
76
  - test/bucket_test.rb
76
77
  - test/connection_test.rb
77
78
  - test/object_test.rb