fake_aws 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +2 -0
  4. data/README.md +24 -16
  5. data/fake_aws.gemspec +4 -1
  6. data/lib/fake_aws.rb +10 -2
  7. data/lib/fake_aws/error.rb +16 -0
  8. data/lib/fake_aws/s3/bucket_on_disk.rb +26 -0
  9. data/lib/fake_aws/s3/error_index.rb +37 -0
  10. data/lib/fake_aws/s3/object_on_disk.rb +50 -0
  11. data/lib/fake_aws/s3/operations/get_object.rb +30 -23
  12. data/lib/fake_aws/s3/operations/put_bucket.rb +38 -0
  13. data/lib/fake_aws/s3/operations/put_object.rb +22 -36
  14. data/lib/fake_aws/s3/rack_app.rb +19 -6
  15. data/lib/fake_aws/s3/request.rb +100 -0
  16. data/lib/fake_aws/s3/responses/common.rb +37 -0
  17. data/lib/fake_aws/s3/responses/empty.rb +25 -0
  18. data/lib/fake_aws/s3/responses/error.rb +50 -0
  19. data/lib/fake_aws/s3/responses/success.rb +31 -0
  20. data/lib/fake_aws/version.rb +1 -1
  21. data/spec/integration/s3/get_object_spec.rb +35 -12
  22. data/spec/integration/s3/put_bucket_spec.rb +40 -0
  23. data/spec/integration/s3/put_object_spec.rb +12 -4
  24. data/spec/integration/s3/request_styles_spec.rb +54 -0
  25. data/spec/spec_helper.rb +1 -16
  26. data/spec/support/common_header_examples.rb +16 -0
  27. data/spec/support/s3_integration_helpers.rb +18 -0
  28. data/spec/support/xml_parsing_helper.rb +7 -0
  29. data/spec/unit/s3/bucket_on_disk_spec.rb +39 -0
  30. data/spec/unit/s3/error_index_spec.rb +17 -0
  31. data/spec/unit/s3/object_on_disk_spec.rb +82 -0
  32. data/spec/unit/s3/request_spec.rb +92 -0
  33. data/spec/unit/s3/responses/empty_spec.rb +14 -0
  34. data/spec/unit/s3/responses/error_spec.rb +49 -0
  35. data/spec/unit/s3/responses/success_spec.rb +25 -0
  36. metadata +82 -26
  37. data/lib/fake_aws/s3/object_store.rb +0 -66
  38. data/lib/fake_aws/s3/xml_error_response.rb +0 -29
  39. data/spec/unit/s3/object_store_spec.rb +0 -75
  40. data/spec/unit/s3/xml_error_response_spec.rb +0 -9
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fake_aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Yandell
@@ -9,78 +9,106 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-09 00:00:00.000000000 Z
12
+ date: 2014-07-29 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: finer_struct
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 0.0.5
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 0.0.5
14
28
  - !ruby/object:Gem::Dependency
15
29
  name: bundler
16
30
  requirement: !ruby/object:Gem::Requirement
17
31
  requirements:
18
- - - ~>
32
+ - - "~>"
19
33
  - !ruby/object:Gem::Version
20
34
  version: '1.3'
21
35
  type: :development
22
36
  prerelease: false
23
37
  version_requirements: !ruby/object:Gem::Requirement
24
38
  requirements:
25
- - - ~>
39
+ - - "~>"
26
40
  - !ruby/object:Gem::Version
27
41
  version: '1.3'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: rake
30
44
  requirement: !ruby/object:Gem::Requirement
31
45
  requirements:
32
- - - '>='
46
+ - - ">="
33
47
  - !ruby/object:Gem::Version
34
48
  version: '0'
35
49
  type: :development
36
50
  prerelease: false
37
51
  version_requirements: !ruby/object:Gem::Requirement
38
52
  requirements:
39
- - - '>='
53
+ - - ">="
40
54
  - !ruby/object:Gem::Version
41
55
  version: '0'
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: rspec
44
58
  requirement: !ruby/object:Gem::Requirement
45
59
  requirements:
46
- - - '>='
60
+ - - "~>"
47
61
  - !ruby/object:Gem::Version
48
- version: '0'
62
+ version: 3.0.0
49
63
  type: :development
50
64
  prerelease: false
51
65
  version_requirements: !ruby/object:Gem::Requirement
52
66
  requirements:
53
- - - '>='
67
+ - - "~>"
54
68
  - !ruby/object:Gem::Version
55
- version: '0'
69
+ version: 3.0.0
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: faraday
58
72
  requirement: !ruby/object:Gem::Requirement
59
73
  requirements:
60
- - - '>='
74
+ - - ">="
61
75
  - !ruby/object:Gem::Version
62
76
  version: '0'
63
77
  type: :development
64
78
  prerelease: false
65
79
  version_requirements: !ruby/object:Gem::Requirement
66
80
  requirements:
67
- - - '>='
81
+ - - ">="
68
82
  - !ruby/object:Gem::Version
69
83
  version: '0'
70
84
  - !ruby/object:Gem::Dependency
71
85
  name: rack-test
72
86
  requirement: !ruby/object:Gem::Requirement
73
87
  requirements:
74
- - - '>='
88
+ - - ">="
75
89
  - !ruby/object:Gem::Version
76
90
  version: '0'
77
91
  type: :development
78
92
  prerelease: false
79
93
  version_requirements: !ruby/object:Gem::Requirement
80
94
  requirements:
81
- - - '>='
95
+ - - ">="
82
96
  - !ruby/object:Gem::Version
83
97
  version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: nori
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: 2.3.0
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: 2.3.0
84
112
  description: A subset of AWS as a Rack app, for dev and testing
85
113
  email:
86
114
  - pete@notahat.com
@@ -89,26 +117,44 @@ executables: []
89
117
  extensions: []
90
118
  extra_rdoc_files: []
91
119
  files:
92
- - .gitignore
93
- - .rspec
94
- - .travis.yml
120
+ - ".gitignore"
121
+ - ".rspec"
122
+ - ".travis.yml"
95
123
  - Gemfile
96
124
  - LICENSE.txt
97
125
  - README.md
98
126
  - Rakefile
99
127
  - fake_aws.gemspec
100
128
  - lib/fake_aws.rb
101
- - lib/fake_aws/s3/object_store.rb
129
+ - lib/fake_aws/error.rb
130
+ - lib/fake_aws/s3/bucket_on_disk.rb
131
+ - lib/fake_aws/s3/error_index.rb
132
+ - lib/fake_aws/s3/object_on_disk.rb
102
133
  - lib/fake_aws/s3/operations/get_object.rb
134
+ - lib/fake_aws/s3/operations/put_bucket.rb
103
135
  - lib/fake_aws/s3/operations/put_object.rb
104
136
  - lib/fake_aws/s3/rack_app.rb
105
- - lib/fake_aws/s3/xml_error_response.rb
137
+ - lib/fake_aws/s3/request.rb
138
+ - lib/fake_aws/s3/responses/common.rb
139
+ - lib/fake_aws/s3/responses/empty.rb
140
+ - lib/fake_aws/s3/responses/error.rb
141
+ - lib/fake_aws/s3/responses/success.rb
106
142
  - lib/fake_aws/version.rb
107
143
  - spec/integration/s3/get_object_spec.rb
144
+ - spec/integration/s3/put_bucket_spec.rb
108
145
  - spec/integration/s3/put_object_spec.rb
146
+ - spec/integration/s3/request_styles_spec.rb
109
147
  - spec/spec_helper.rb
110
- - spec/unit/s3/object_store_spec.rb
111
- - spec/unit/s3/xml_error_response_spec.rb
148
+ - spec/support/common_header_examples.rb
149
+ - spec/support/s3_integration_helpers.rb
150
+ - spec/support/xml_parsing_helper.rb
151
+ - spec/unit/s3/bucket_on_disk_spec.rb
152
+ - spec/unit/s3/error_index_spec.rb
153
+ - spec/unit/s3/object_on_disk_spec.rb
154
+ - spec/unit/s3/request_spec.rb
155
+ - spec/unit/s3/responses/empty_spec.rb
156
+ - spec/unit/s3/responses/error_spec.rb
157
+ - spec/unit/s3/responses/success_spec.rb
112
158
  homepage: https://github.com/envato/fake_aws
113
159
  licenses:
114
160
  - MIT
@@ -119,24 +165,34 @@ require_paths:
119
165
  - lib
120
166
  required_ruby_version: !ruby/object:Gem::Requirement
121
167
  requirements:
122
- - - '>='
168
+ - - ">="
123
169
  - !ruby/object:Gem::Version
124
170
  version: '0'
125
171
  required_rubygems_version: !ruby/object:Gem::Requirement
126
172
  requirements:
127
- - - '>='
173
+ - - ">="
128
174
  - !ruby/object:Gem::Version
129
175
  version: '0'
130
176
  requirements: []
131
177
  rubyforge_project:
132
- rubygems_version: 2.0.3
178
+ rubygems_version: 2.2.2
133
179
  signing_key:
134
180
  specification_version: 4
135
181
  summary: A subset of AWS (so far just a small proportion of S3) implemented as a Rack
136
182
  app, useful for development and testing.
137
183
  test_files:
138
184
  - spec/integration/s3/get_object_spec.rb
185
+ - spec/integration/s3/put_bucket_spec.rb
139
186
  - spec/integration/s3/put_object_spec.rb
187
+ - spec/integration/s3/request_styles_spec.rb
140
188
  - spec/spec_helper.rb
141
- - spec/unit/s3/object_store_spec.rb
142
- - spec/unit/s3/xml_error_response_spec.rb
189
+ - spec/support/common_header_examples.rb
190
+ - spec/support/s3_integration_helpers.rb
191
+ - spec/support/xml_parsing_helper.rb
192
+ - spec/unit/s3/bucket_on_disk_spec.rb
193
+ - spec/unit/s3/error_index_spec.rb
194
+ - spec/unit/s3/object_on_disk_spec.rb
195
+ - spec/unit/s3/request_spec.rb
196
+ - spec/unit/s3/responses/empty_spec.rb
197
+ - spec/unit/s3/responses/error_spec.rb
198
+ - spec/unit/s3/responses/success_spec.rb
@@ -1,66 +0,0 @@
1
- require 'json'
2
-
3
- module FakeAWS
4
- module S3
5
-
6
- # Read and write S3 objects and metadata about them in the filesystem.
7
- class ObjectStore
8
-
9
- def initialize(root_directory, path_info)
10
- @root_directory = root_directory
11
- @path_info = path_info
12
-
13
- path_components = @path_info.split("/")
14
- _, @bucket, *@directories, @file_name = path_components
15
- end
16
-
17
- attr_reader :bucket
18
-
19
- def bucket_exists?
20
- Dir.exists?(bucket_path)
21
- end
22
-
23
- def object_exists?
24
- File.exists?(file_path)
25
- end
26
-
27
- def write_object(content, metadata)
28
- FileUtils.mkdir_p(directory_path)
29
- File.write(file_path, content)
30
- File.write(metadata_file_path, metadata.to_json)
31
- end
32
-
33
- def read_object
34
- File.new(file_path)
35
- end
36
-
37
- def read_metadata
38
- if File.exists?(metadata_file_path)
39
- JSON.parse(File.read(metadata_file_path))
40
- else
41
- {}
42
- end
43
- end
44
-
45
- private
46
-
47
- def bucket_path
48
- @bucket_path ||= File.join(@root_directory, @bucket)
49
- end
50
-
51
- def file_path
52
- @file_path ||= File.join(@root_directory, @path_info)
53
- end
54
-
55
- def metadata_file_path
56
- "#{file_path}.metadata.json"
57
- end
58
-
59
- def directory_path
60
- @directory_path ||= File.join(@root_directory, @bucket, *@directories)
61
- end
62
-
63
- end
64
-
65
- end
66
- end
@@ -1,29 +0,0 @@
1
- module FakeAWS
2
- module S3
3
-
4
- class XMLErrorResponse
5
- def initialize(code, message, resource)
6
- @code = code
7
- @message = message
8
- @resource = resource
9
- end
10
-
11
- def to_str
12
- # TODO: Fill out the bits of the XML response that we haven't yet.
13
- "".tap do |xml|
14
- xml << %q{<?xml version="1.0" encoding="UTF-8"?>\n}
15
- xml << %q{<Error>}
16
-
17
- xml << " <Code>#{@code}</Code>"
18
- xml << " <Message>#{@message}</Message>"
19
- xml << " <Resource>#{@resource}</Resource>"
20
- xml << " <RequestId></RequestId>"
21
-
22
- xml << %q{</Error>}
23
- end
24
- end
25
-
26
- end
27
-
28
- end
29
- end
@@ -1,75 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FakeAWS::S3::ObjectStore do
4
- let(:root_directory) { "tmp" }
5
- let(:path_info) { "/mah-bucket/mah-file.txt" }
6
-
7
- subject { described_class.new(root_directory, path_info) }
8
-
9
- let(:bucket_path) { "tmp/mah-bucket" }
10
- let(:object_file_path) { "tmp/mah-bucket/mah-file.txt" }
11
- let(:metadata_file_path) { "tmp/mah-bucket/mah-file.txt.metadata.json" }
12
-
13
- before do
14
- FileUtils.rm_r(root_directory) rescue Errno::ENOENT
15
- FileUtils.mkdir_p(bucket_path)
16
- end
17
-
18
- describe "#bucket_exists?" do
19
- it "returns true if the bucket directory exists" do
20
- expect(subject.bucket_exists?).to be_true
21
- end
22
-
23
- it "returns false if the bucket directory doesn't exist" do
24
- FileUtils.rmdir(bucket_path)
25
- expect(subject.bucket_exists?).to be_false
26
- end
27
- end
28
-
29
- describe "#object_exists?" do
30
- it "returns true if the object file exists" do
31
- File.write(object_file_path, "Hello, world!")
32
- expect(subject.object_exists?).to be_true
33
- end
34
-
35
- it "returns file if the object file doesn't exist" do
36
- expect(subject.object_exists?).to be_false
37
- end
38
- end
39
-
40
- describe "#write_object" do
41
- it "writes the content to the object file" do
42
- subject.write_object("Hello, world!", { "bunnies" => "scary" })
43
-
44
- expect(File.read(object_file_path)).to eq("Hello, world!")
45
- end
46
-
47
- it "writes the metadata to the metadata file as JSON" do
48
- subject.write_object("Hello, world!", { "bunnies" => "scary" })
49
-
50
- expect(File.read(metadata_file_path)).to eq('{"bunnies":"scary"}')
51
- end
52
- end
53
-
54
- describe "#read_object" do
55
- it "reads the contents of the object file" do
56
- File.write(object_file_path, "Hello, world!")
57
-
58
- expect(subject.read_object.read).to eq("Hello, world!")
59
- end
60
- end
61
-
62
- describe "#read_metadata" do
63
- it "returns an empty hash if there's no metadata file" do
64
- expect(subject.read_metadata).to eq({})
65
- end
66
-
67
- it "returns the JSON from the metadata file converted to a hash" do
68
- File.write(metadata_file_path, '{"bunnies":"scary"}')
69
-
70
- expect(subject.read_metadata).to eq("bunnies" => "scary")
71
- end
72
- end
73
-
74
- end
75
-
@@ -1,9 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FakeAWS::S3::XMLErrorResponse do
4
-
5
- it "puts the code in the response"
6
- it "puts the message in the response"
7
- it "puts the resource in the response"
8
-
9
- end