fake-aws-sdk 0.0.1 → 0.1.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.
- checksums.yaml +15 -0
- data/.rspec +1 -0
- data/lib/fake_aws/s3.rb +17 -1
- data/lib/fake_aws/s3/bucket.rb +6 -2
- data/lib/fake_aws/s3/bucket_collection.rb +33 -0
- data/lib/fake_aws/s3/object_collection.rb +14 -5
- data/lib/fake_aws/s3/s3_object.rb +2 -4
- data/lib/fake_aws/version.rb +1 -1
- data/spec/fake-aws/s3/bucket_collection_spec.rb +39 -0
- data/spec/fake-aws/s3/bucket_spec.rb +5 -21
- data/spec/fake-aws/s3/object_collection_spec.rb +77 -0
- data/spec/fake-aws/s3/s3_object_spec.rb +1 -5
- data/spec/fake-aws/s3_spec.rb +15 -0
- metadata +13 -15
- data/spec/spec_helper.rb +0 -1
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NjEwYzgyMWM4M2ZkZTI0NDQ2NWUyMDg5Mzg4M2YxNjRiYWY2MjI1NA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YzE1ZTEzMTEzOTkwMDNjNzQ5NWRmMWU1MjMwYjA2NjFhOGY4YWViZg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
OThmODliYjJlNjQyZTk2MzY4OGM0ZmFiMWEzY2FkNDIyZTgxYzc2MGZmMGY4
|
10
|
+
MTA1MTNiNGVmMGM0N2Y2MjkwMTAxNzcyZmUxMTUyODY0MDdlYTE3YTk4NzJh
|
11
|
+
MThmM2NiNTJkNmY3NTY3NTBjOWQ2N2ExYjEzMzFlNjBjNjRjNGM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NDBkMGE4ZGRiZWI0MTZkYjMxNTJiZjc1MjJlYWRlNjdiYWUzYTEzYzVjM2Rl
|
14
|
+
ZGVlNGI0OGQ3Y2MyOTQ5ZDM2NGJjNmU1Mjc4OWViNDEyZjcwZWU5MmFlNzJm
|
15
|
+
Yzk5MWI2ZWJiZjdlZTZhM2QxNDE3OWYxYTU1MjExNmZiZDM4M2E=
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/lib/fake_aws/s3.rb
CHANGED
@@ -1,2 +1,18 @@
|
|
1
|
-
require "fake_aws/s3/
|
1
|
+
require "fake_aws/s3/bucket_collection"
|
2
2
|
require "fake_aws/s3/s3_object"
|
3
|
+
|
4
|
+
module FakeAWS
|
5
|
+
|
6
|
+
class S3
|
7
|
+
|
8
|
+
def initialize(options = {})
|
9
|
+
@options = options
|
10
|
+
@buckets = BucketCollection.new
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :buckets
|
14
|
+
attr_reader :options
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/lib/fake_aws/s3/bucket.rb
CHANGED
@@ -1,18 +1,22 @@
|
|
1
1
|
require "fake_aws/s3/object_collection"
|
2
2
|
|
3
3
|
module FakeAWS
|
4
|
-
|
4
|
+
class S3
|
5
5
|
|
6
6
|
class Bucket
|
7
7
|
|
8
8
|
def initialize(name)
|
9
9
|
@name = name
|
10
|
-
@objects = ObjectCollection.new
|
10
|
+
@objects = ObjectCollection.new
|
11
11
|
end
|
12
12
|
|
13
13
|
attr_reader :name
|
14
14
|
attr_reader :objects
|
15
15
|
|
16
|
+
def exists?
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
16
20
|
end
|
17
21
|
|
18
22
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "fake_aws/s3/bucket"
|
2
|
+
require "forwardable"
|
3
|
+
|
4
|
+
module FakeAWS
|
5
|
+
class S3
|
6
|
+
|
7
|
+
class BucketCollection
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@buckets = Hash.new do |h, name|
|
11
|
+
h[name] = Bucket.new(name)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def [](name)
|
16
|
+
name = name.to_s
|
17
|
+
@buckets[name]
|
18
|
+
end
|
19
|
+
|
20
|
+
extend Forwardable
|
21
|
+
|
22
|
+
def_delegators :@buckets, :empty?
|
23
|
+
|
24
|
+
include Enumerable
|
25
|
+
|
26
|
+
def each(&block)
|
27
|
+
@buckets.each_value(&block)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -2,14 +2,13 @@ require "fake_aws/s3/s3_object"
|
|
2
2
|
require "forwardable"
|
3
3
|
|
4
4
|
module FakeAWS
|
5
|
-
|
5
|
+
class S3
|
6
6
|
|
7
7
|
class ObjectCollection
|
8
8
|
|
9
|
-
def initialize
|
10
|
-
@bucket = bucket
|
9
|
+
def initialize
|
11
10
|
@objects = Hash.new do |h, key|
|
12
|
-
h[key] = S3Object.new(
|
11
|
+
h[key] = S3Object.new(key)
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
@@ -20,7 +19,17 @@ module FakeAWS
|
|
20
19
|
|
21
20
|
extend Forwardable
|
22
21
|
|
23
|
-
|
22
|
+
include Enumerable
|
23
|
+
|
24
|
+
def each
|
25
|
+
@objects.each_value do |object|
|
26
|
+
yield object if object.exists?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def empty?
|
31
|
+
!@objects.values.any?(&:exists?)
|
32
|
+
end
|
24
33
|
|
25
34
|
end
|
26
35
|
|
data/lib/fake_aws/version.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
require "fake_aws/s3/bucket_collection"
|
2
|
+
|
3
|
+
describe FakeAWS::S3::BucketCollection do
|
4
|
+
|
5
|
+
let(:buckets) { FakeAWS::S3::BucketCollection.new }
|
6
|
+
|
7
|
+
it "starts empty" do
|
8
|
+
buckets.should be_empty
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#[]" do
|
12
|
+
|
13
|
+
it "returns a Bucket" do
|
14
|
+
buckets["foo"].should be_kind_of(FakeAWS::S3::Bucket)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "always returns the same Bucket" do
|
18
|
+
buckets["foo"].should equal(buckets["foo"])
|
19
|
+
end
|
20
|
+
|
21
|
+
it "converts Symbol names to String" do
|
22
|
+
buckets["foo"].should equal(buckets[:foo])
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
it "is Enumerable" do
|
28
|
+
buckets.should be_kind_of(Enumerable)
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#each" do
|
32
|
+
it "yields all buckets" do
|
33
|
+
buckets["a"]
|
34
|
+
buckets["b"]
|
35
|
+
buckets.map(&:name).should eq(%w(a b))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
1
|
require "fake_aws/s3/bucket"
|
4
2
|
|
5
3
|
describe FakeAWS::S3::Bucket do
|
@@ -10,28 +8,14 @@ describe FakeAWS::S3::Bucket do
|
|
10
8
|
bucket.name.should eq("foo")
|
11
9
|
end
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
describe "#objects" do
|
16
|
-
|
17
|
-
it "starts empty" do
|
18
|
-
objects.count.should be_zero
|
19
|
-
end
|
20
|
-
|
11
|
+
it "implicitly exists" do
|
12
|
+
bucket.should exist
|
21
13
|
end
|
22
14
|
|
23
|
-
describe "#objects
|
24
|
-
|
25
|
-
it "returns an S3Object" do
|
26
|
-
objects["foo"].should be_kind_of(FakeAWS::S3::S3Object)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "always returns the same S3Object" do
|
30
|
-
objects["foo"].should equal(objects["foo"])
|
31
|
-
end
|
15
|
+
describe "#objects" do
|
32
16
|
|
33
|
-
it "
|
34
|
-
objects
|
17
|
+
it "returns an ObjectCollection" do
|
18
|
+
bucket.objects.should be_kind_of(FakeAWS::S3::ObjectCollection)
|
35
19
|
end
|
36
20
|
|
37
21
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require "fake_aws/s3/object_collection"
|
2
|
+
|
3
|
+
describe FakeAWS::S3::ObjectCollection do
|
4
|
+
|
5
|
+
let(:objects) { FakeAWS::S3::ObjectCollection.new }
|
6
|
+
|
7
|
+
it "starts empty" do
|
8
|
+
objects.should be_empty
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#[]" do
|
12
|
+
|
13
|
+
it "returns an S3Object" do
|
14
|
+
objects["foo"].should be_kind_of(FakeAWS::S3::S3Object)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "always returns the same S3Object" do
|
18
|
+
objects["foo"].should equal(objects["foo"])
|
19
|
+
end
|
20
|
+
|
21
|
+
it "passes along the object key" do
|
22
|
+
objects["foo"].key.should eq("foo")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "converts Symbol keys to String" do
|
26
|
+
objects["foo"].should equal(objects[:foo])
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
it "is Enumerable" do
|
32
|
+
objects.should be_kind_of(Enumerable)
|
33
|
+
end
|
34
|
+
|
35
|
+
context "after writing some objects" do
|
36
|
+
|
37
|
+
before do
|
38
|
+
objects["a"].write("CONTENT")
|
39
|
+
objects["b"].write("CONTENT")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "is no longer empty" do
|
43
|
+
objects.should_not be_empty
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#each" do
|
47
|
+
|
48
|
+
it "yields the objects with content" do
|
49
|
+
objects.map(&:key).should eq(%w(a b))
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
context "after referencing some objects (without writing content)" do
|
57
|
+
|
58
|
+
before do
|
59
|
+
objects["a"]
|
60
|
+
objects["b"]
|
61
|
+
end
|
62
|
+
|
63
|
+
it "is still considered empty" do
|
64
|
+
objects.should be_empty
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#each" do
|
68
|
+
|
69
|
+
it "yields nothing" do
|
70
|
+
objects.map(&:key).should be_empty
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -1,13 +1,9 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
1
|
require "fake_aws/s3/bucket"
|
4
2
|
require "fake_aws/s3/s3_object"
|
5
3
|
|
6
4
|
describe FakeAWS::S3::S3Object do
|
7
5
|
|
8
|
-
let(:
|
9
|
-
|
10
|
-
let(:object) { FakeAWS::S3::S3Object.new(bucket, "test-object") }
|
6
|
+
let(:object) { FakeAWS::S3::S3Object.new("test-object") }
|
11
7
|
|
12
8
|
subject { object }
|
13
9
|
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fake-aws-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.0.1
|
4
|
+
version: 0.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Mike Williams
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
11
|
+
date: 2013-02-27 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: Fake implementation of AWS SDK
|
15
14
|
email:
|
@@ -19,6 +18,7 @@ extensions: []
|
|
19
18
|
extra_rdoc_files: []
|
20
19
|
files:
|
21
20
|
- .gitignore
|
21
|
+
- .rspec
|
22
22
|
- Gemfile
|
23
23
|
- LICENSE.txt
|
24
24
|
- README.md
|
@@ -28,43 +28,41 @@ files:
|
|
28
28
|
- lib/fake_aws.rb
|
29
29
|
- lib/fake_aws/s3.rb
|
30
30
|
- lib/fake_aws/s3/bucket.rb
|
31
|
+
- lib/fake_aws/s3/bucket_collection.rb
|
31
32
|
- lib/fake_aws/s3/object_collection.rb
|
32
33
|
- lib/fake_aws/s3/s3_object.rb
|
33
34
|
- lib/fake_aws/version.rb
|
35
|
+
- spec/fake-aws/s3/bucket_collection_spec.rb
|
34
36
|
- spec/fake-aws/s3/bucket_spec.rb
|
37
|
+
- spec/fake-aws/s3/object_collection_spec.rb
|
35
38
|
- spec/fake-aws/s3/s3_object_spec.rb
|
36
|
-
- spec/
|
39
|
+
- spec/fake-aws/s3_spec.rb
|
37
40
|
homepage: http://github.com/cogent/fake-aws-sdk
|
38
41
|
licenses: []
|
42
|
+
metadata: {}
|
39
43
|
post_install_message:
|
40
44
|
rdoc_options: []
|
41
45
|
require_paths:
|
42
46
|
- lib
|
43
47
|
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
-
none: false
|
45
48
|
requirements:
|
46
49
|
- - ! '>='
|
47
50
|
- !ruby/object:Gem::Version
|
48
|
-
segments:
|
49
|
-
- 0
|
50
|
-
hash: 4095608689954055844
|
51
51
|
version: '0'
|
52
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
-
none: false
|
54
53
|
requirements:
|
55
54
|
- - ! '>='
|
56
55
|
- !ruby/object:Gem::Version
|
57
|
-
segments:
|
58
|
-
- 0
|
59
|
-
hash: 4095608689954055844
|
60
56
|
version: '0'
|
61
57
|
requirements: []
|
62
58
|
rubyforge_project:
|
63
|
-
rubygems_version:
|
59
|
+
rubygems_version: 2.0.0
|
64
60
|
signing_key:
|
65
|
-
specification_version:
|
61
|
+
specification_version: 4
|
66
62
|
summary: Fake implementation of AWS SDK
|
67
63
|
test_files:
|
64
|
+
- spec/fake-aws/s3/bucket_collection_spec.rb
|
68
65
|
- spec/fake-aws/s3/bucket_spec.rb
|
66
|
+
- spec/fake-aws/s3/object_collection_spec.rb
|
69
67
|
- spec/fake-aws/s3/s3_object_spec.rb
|
70
|
-
- spec/
|
68
|
+
- spec/fake-aws/s3_spec.rb
|
data/spec/spec_helper.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "aws-sdk"
|