aws-ext 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +2 -0
- data/README.rdoc +7 -3
- data/VERSION +1 -1
- data/aws-ext.gemspec +4 -3
- data/lib/aws-ext.rb +8 -1
- data/spec/aws-ext_spec.rb +33 -16
- metadata +29 -13
data/.rvmrc
ADDED
data/README.rdoc
CHANGED
@@ -4,7 +4,7 @@ Extensions for the aws-s3 gem
|
|
4
4
|
|
5
5
|
== Installing
|
6
6
|
|
7
|
-
%
|
7
|
+
% gem install aws-ext
|
8
8
|
|
9
9
|
== S3Object
|
10
10
|
|
@@ -12,12 +12,16 @@ Extensions for the aws-s3 gem
|
|
12
12
|
|
13
13
|
Copies arbitrary S3Object across buckets using the Amazon S3 copy option. ACLs default to :public_read. Passing :copy as the ACL will copy the sources ACL.
|
14
14
|
|
15
|
-
=== #copy_to_bucket(dest_bucket, dest_key = nil, acl_policy = :copy
|
15
|
+
=== #copy_to_bucket(dest_bucket, dest_key = nil, acl_policy = :copy)
|
16
16
|
|
17
17
|
Copies this S3Object across buckets using the Amazon S3 copy option. Destination key defaults to Source key.ACLs default to :public_read. Passing :copy as the ACL will copy the sources ACL.
|
18
18
|
|
19
19
|
== Bucket
|
20
20
|
|
21
|
+
=== #copy_to_bucket(copy_bucket)
|
22
|
+
|
23
|
+
Copy all objects in this bucket to the copy_bucket.
|
24
|
+
|
21
25
|
=== #exists?(key)
|
22
26
|
|
23
27
|
Does key exist in this bucket?
|
@@ -42,4 +46,4 @@ Paginates over all objects in the bucket. :max_keys defaults to 100.
|
|
42
46
|
|
43
47
|
== Copyright
|
44
48
|
|
45
|
-
Copyright (c)
|
49
|
+
Copyright (c) 2010 Les Hill. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/aws-ext.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{aws-ext}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Les Hill"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2010-05-31}
|
13
13
|
s.description = %q{Extensions for aws-s3}
|
14
14
|
s.email = %q{leshill@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
21
|
".gitignore",
|
22
|
+
".rvmrc",
|
22
23
|
"LICENSE",
|
23
24
|
"README.rdoc",
|
24
25
|
"Rakefile",
|
@@ -32,7 +33,7 @@ Gem::Specification.new do |s|
|
|
32
33
|
s.homepage = %q{http://github.com/leshill/aws-ext}
|
33
34
|
s.rdoc_options = ["--charset=UTF-8"]
|
34
35
|
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.3.
|
36
|
+
s.rubygems_version = %q{1.3.6}
|
36
37
|
s.summary = %q{Extensions for aws-s3}
|
37
38
|
s.test_files = [
|
38
39
|
"spec/aws-ext_spec.rb",
|
data/lib/aws-ext.rb
CHANGED
@@ -21,6 +21,12 @@ module AWS
|
|
21
21
|
end
|
22
22
|
|
23
23
|
class Bucket
|
24
|
+
def copy_to_bucket(copy_bucket)
|
25
|
+
each_object do |obj|
|
26
|
+
obj.copy_to_bucket(copy_bucket)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
24
30
|
def each_object(opts = {}, &block)
|
25
31
|
opts = { :max_keys => 100 }.merge(opts)
|
26
32
|
while (response = objects(opts).each {|obj| yield obj }).any? do
|
@@ -37,4 +43,5 @@ module AWS
|
|
37
43
|
end
|
38
44
|
end
|
39
45
|
end
|
40
|
-
end
|
46
|
+
end
|
47
|
+
|
data/spec/aws-ext_spec.rb
CHANGED
@@ -2,30 +2,47 @@ require File.expand_path(File.join(File.dirname(__FILE__), '/spec_helper'))
|
|
2
2
|
|
3
3
|
describe 'aws_ext' do
|
4
4
|
context "AWS::S3::Bucket" do
|
5
|
+
let(:key) { 'key' }
|
6
|
+
let(:name) { 'bucket' }
|
7
|
+
let(:bucket) { AWS::S3::Bucket.new(:name => name) }
|
8
|
+
|
5
9
|
it "#exists? delegates to S3Object.exists?" do
|
6
|
-
key = 'key'
|
7
|
-
name = 'bucket'
|
8
10
|
AWS::S3::S3Object.should_receive(:exists?).with(key, name)
|
9
|
-
|
11
|
+
bucket.exists?(key)
|
10
12
|
end
|
11
13
|
|
12
14
|
it "#find delegates to S3Object.find" do
|
13
|
-
key = 'key'
|
14
|
-
name = 'bucket'
|
15
15
|
AWS::S3::S3Object.should_receive(:find).with(key, name)
|
16
|
-
|
16
|
+
bucket.find(key)
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
19
|
+
describe "#each_object" do
|
20
|
+
let(:objects_options_1) { {:max_keys => 1} }
|
21
|
+
let(:objects_returned_1) { [stub('object', :key => key)] }
|
22
|
+
let(:objects_options_2) { objects_options_1[:marker] = key; objects_options_1 }
|
23
|
+
let(:objects_returned_2) { [] }
|
24
|
+
|
25
|
+
it "iterates objects with max_keys and marker set" do
|
26
|
+
bucket.should_receive(:objects).with(objects_options_1).and_return(objects_returned_1)
|
27
|
+
bucket.should_receive(:objects).with(objects_options_2).and_return(objects_returned_2)
|
28
|
+
bucket.each_object(objects_options_1) {}
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#copy_to_bucket" do
|
32
|
+
let(:copy_bucket) { AWS::S3::Bucket.new(:name => 'copy_bucket') }
|
33
|
+
let(:s3object) { stub }
|
34
|
+
|
35
|
+
it "iterates over each object" do
|
36
|
+
bucket.should_receive(:each_object)
|
37
|
+
bucket.copy_to_bucket(copy_bucket)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "copies each object to the destination bucket" do
|
41
|
+
s3object.should_receive(:copy_to_bucket).with(copy_bucket)
|
42
|
+
bucket.stub(:each_object).and_yield(s3object)
|
43
|
+
bucket.copy_to_bucket(copy_bucket)
|
44
|
+
end
|
45
|
+
end
|
29
46
|
end
|
30
47
|
end
|
31
48
|
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Les Hill
|
@@ -9,29 +14,37 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-05-31 00:00:00 -04:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: aws-s3
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 6
|
30
|
+
- 2
|
23
31
|
version: 0.6.2
|
24
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
- !ruby/object:Gem::Dependency
|
26
35
|
name: rspec
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
38
|
requirements:
|
31
39
|
- - ">="
|
32
40
|
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 1
|
43
|
+
- 2
|
44
|
+
- 9
|
33
45
|
version: 1.2.9
|
34
|
-
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
35
48
|
description: Extensions for aws-s3
|
36
49
|
email: leshill@gmail.com
|
37
50
|
executables: []
|
@@ -44,6 +57,7 @@ extra_rdoc_files:
|
|
44
57
|
files:
|
45
58
|
- .document
|
46
59
|
- .gitignore
|
60
|
+
- .rvmrc
|
47
61
|
- LICENSE
|
48
62
|
- README.rdoc
|
49
63
|
- Rakefile
|
@@ -66,18 +80,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
80
|
requirements:
|
67
81
|
- - ">="
|
68
82
|
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 0
|
69
85
|
version: "0"
|
70
|
-
version:
|
71
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
87
|
requirements:
|
73
88
|
- - ">="
|
74
89
|
- !ruby/object:Gem::Version
|
90
|
+
segments:
|
91
|
+
- 0
|
75
92
|
version: "0"
|
76
|
-
version:
|
77
93
|
requirements: []
|
78
94
|
|
79
95
|
rubyforge_project:
|
80
|
-
rubygems_version: 1.3.
|
96
|
+
rubygems_version: 1.3.6
|
81
97
|
signing_key:
|
82
98
|
specification_version: 3
|
83
99
|
summary: Extensions for aws-s3
|