storage 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -1
- data/Gemfile.lock +69 -137
- data/lib/storage/config.rb +4 -1
- data/lib/storage/strategies/s3.rb +2 -1
- data/lib/storage/version.rb +1 -1
- data/spec/storage/strategies/s3_spec.rb +103 -80
- data/storage.gemspec +1 -2
- metadata +6 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4d8b072280f92e4e745df2bb3180fd1e8640f75
|
4
|
+
data.tar.gz: 3f88505cdc2bbdcf4af9f727caab88014a226d7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8045b230b182476fb49ec5491a3a03a36454bb8f268a735b4cd935bd562b0de93b27239d5b62e324bc7b591108282a4a87ce51068f1e01078ea7d98af8eadc85
|
7
|
+
data.tar.gz: a91613e6bcc193464ca5b1f19ec8a820ee08f61419480e9a3cfd99b59081fb51234235863c0e65168b2d14bdc065733c432356eec34d98b3b38a6776c4a494e8
|
data/.rspec
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--color
|
1
|
+
--color
|
data/Gemfile.lock
CHANGED
@@ -1,62 +1,31 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
storage (0.
|
4
|
+
storage (0.3.0)
|
5
5
|
fog
|
6
|
+
mime-types
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
10
|
-
CFPropertyList (2.3.
|
11
|
-
actionmailer (3.2.22)
|
12
|
-
actionpack (= 3.2.22)
|
13
|
-
mail (~> 2.5.4)
|
14
|
-
actionpack (3.2.22)
|
15
|
-
activemodel (= 3.2.22)
|
16
|
-
activesupport (= 3.2.22)
|
17
|
-
builder (~> 3.0.0)
|
18
|
-
erubis (~> 2.7.0)
|
19
|
-
journey (~> 1.0.4)
|
20
|
-
rack (~> 1.4.5)
|
21
|
-
rack-cache (~> 1.2)
|
22
|
-
rack-test (~> 0.6.1)
|
23
|
-
sprockets (~> 2.2.1)
|
24
|
-
activemodel (3.2.22)
|
25
|
-
activesupport (= 3.2.22)
|
26
|
-
builder (~> 3.0.0)
|
27
|
-
activerecord (3.2.22)
|
28
|
-
activemodel (= 3.2.22)
|
29
|
-
activesupport (= 3.2.22)
|
30
|
-
arel (~> 3.0.2)
|
31
|
-
tzinfo (~> 0.3.29)
|
32
|
-
activeresource (3.2.22)
|
33
|
-
activemodel (= 3.2.22)
|
34
|
-
activesupport (= 3.2.22)
|
35
|
-
activesupport (3.2.22)
|
36
|
-
i18n (~> 0.6, >= 0.6.4)
|
37
|
-
multi_json (~> 1.0)
|
38
|
-
arel (3.0.3)
|
39
|
-
ast (2.0.0)
|
40
|
-
astrolabe (1.3.0)
|
41
|
-
parser (>= 2.2.0.pre.3, < 3.0)
|
11
|
+
CFPropertyList (2.3.2)
|
42
12
|
awesome_print (1.6.1)
|
43
|
-
builder (3.
|
44
|
-
byebug (
|
45
|
-
|
46
|
-
coderay (1.1.0)
|
47
|
-
columnize (0.9.0)
|
13
|
+
builder (3.2.2)
|
14
|
+
byebug (8.2.2)
|
15
|
+
coderay (1.1.1)
|
48
16
|
diff-lcs (1.2.5)
|
49
|
-
|
50
|
-
excon (0.45.3)
|
17
|
+
excon (0.47.0)
|
51
18
|
fission (0.5.0)
|
52
19
|
CFPropertyList (~> 2.2)
|
53
|
-
fog (1.
|
20
|
+
fog (1.37.0)
|
21
|
+
fog-aliyun (>= 0.1.0)
|
54
22
|
fog-atmos
|
55
|
-
fog-aws (
|
23
|
+
fog-aws (>= 0.6.0)
|
56
24
|
fog-brightbox (~> 0.4)
|
57
|
-
fog-core (~> 1.
|
58
|
-
fog-
|
59
|
-
fog-
|
25
|
+
fog-core (~> 1.32)
|
26
|
+
fog-dynect (~> 0.0.2)
|
27
|
+
fog-ecloud (~> 0.1)
|
28
|
+
fog-google (<= 0.1.0)
|
60
29
|
fog-json
|
61
30
|
fog-local
|
62
31
|
fog-powerdns (>= 0.1.1)
|
@@ -70,32 +39,39 @@ GEM
|
|
70
39
|
fog-terremark
|
71
40
|
fog-vmfusion
|
72
41
|
fog-voxel
|
42
|
+
fog-vsphere (>= 0.4.0)
|
43
|
+
fog-xenserver
|
73
44
|
fog-xml (~> 0.1.1)
|
74
45
|
ipaddress (~> 0.5)
|
75
|
-
|
46
|
+
fog-aliyun (0.1.0)
|
47
|
+
fog-core (~> 1.27)
|
48
|
+
fog-json (~> 1.0)
|
49
|
+
ipaddress (~> 0.8)
|
50
|
+
xml-simple (~> 1.1)
|
76
51
|
fog-atmos (0.1.0)
|
77
52
|
fog-core
|
78
53
|
fog-xml
|
79
|
-
fog-aws (0.
|
54
|
+
fog-aws (0.8.1)
|
80
55
|
fog-core (~> 1.27)
|
81
56
|
fog-json (~> 1.0)
|
82
57
|
fog-xml (~> 0.1)
|
83
58
|
ipaddress (~> 0.8)
|
84
|
-
fog-brightbox (0.
|
59
|
+
fog-brightbox (0.10.1)
|
85
60
|
fog-core (~> 1.22)
|
86
61
|
fog-json
|
87
62
|
inflecto (~> 0.0.2)
|
88
|
-
fog-core (1.
|
63
|
+
fog-core (1.36.0)
|
89
64
|
builder
|
90
65
|
excon (~> 0.45)
|
91
66
|
formatador (~> 0.2)
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
67
|
+
fog-dynect (0.0.2)
|
68
|
+
fog-core
|
69
|
+
fog-json
|
70
|
+
fog-xml
|
71
|
+
fog-ecloud (0.3.0)
|
96
72
|
fog-core
|
97
73
|
fog-xml
|
98
|
-
fog-google (0.0
|
74
|
+
fog-google (0.1.0)
|
99
75
|
fog-core
|
100
76
|
fog-json
|
101
77
|
fog-xml
|
@@ -108,11 +84,11 @@ GEM
|
|
108
84
|
fog-core (~> 1.27)
|
109
85
|
fog-json (~> 1.0)
|
110
86
|
fog-xml (~> 0.1)
|
111
|
-
fog-profitbricks (0.0.
|
87
|
+
fog-profitbricks (0.0.5)
|
112
88
|
fog-core
|
113
89
|
fog-xml
|
114
90
|
nokogiri
|
115
|
-
fog-radosgw (0.0.
|
91
|
+
fog-radosgw (0.0.5)
|
116
92
|
fog-core (>= 1.21.0)
|
117
93
|
fog-json
|
118
94
|
fog-xml (>= 0.0.1)
|
@@ -120,13 +96,13 @@ GEM
|
|
120
96
|
fog-core
|
121
97
|
fog-json
|
122
98
|
fog-xml
|
123
|
-
fog-sakuracloud (1.
|
99
|
+
fog-sakuracloud (1.7.5)
|
124
100
|
fog-core
|
125
101
|
fog-json
|
126
102
|
fog-serverlove (0.1.2)
|
127
103
|
fog-core
|
128
104
|
fog-json
|
129
|
-
fog-softlayer (
|
105
|
+
fog-softlayer (1.1.0)
|
130
106
|
fog-core
|
131
107
|
fog-json
|
132
108
|
fog-storm_on_demand (0.1.1)
|
@@ -141,37 +117,30 @@ GEM
|
|
141
117
|
fog-voxel (0.1.0)
|
142
118
|
fog-core
|
143
119
|
fog-xml
|
120
|
+
fog-vsphere (0.6.0)
|
121
|
+
fog-core
|
122
|
+
rbvmomi (~> 1.8)
|
123
|
+
fog-xenserver (0.2.3)
|
124
|
+
fog-core
|
125
|
+
fog-xml
|
144
126
|
fog-xml (0.1.2)
|
145
127
|
fog-core
|
146
128
|
nokogiri (~> 1.5, >= 1.5.11)
|
147
129
|
formatador (0.2.5)
|
148
|
-
hike (1.2.3)
|
149
|
-
i18n (0.7.0)
|
150
130
|
inflecto (0.0.2)
|
151
|
-
ipaddress (0.8.
|
152
|
-
journey (1.0.4)
|
153
|
-
json (1.8.3)
|
154
|
-
mail (2.5.4)
|
155
|
-
mime-types (~> 1.16)
|
156
|
-
treetop (~> 1.4.8)
|
131
|
+
ipaddress (0.8.3)
|
157
132
|
method_source (0.8.2)
|
158
|
-
mime-types (
|
159
|
-
|
160
|
-
multi_json (1.11.
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
nokogiri (1.6.6.2)
|
165
|
-
mini_portile (~> 0.6.0)
|
166
|
-
parser (2.3.0.pre.2)
|
167
|
-
ast (>= 1.1, < 3.0)
|
168
|
-
polyglot (0.3.5)
|
169
|
-
pry (0.10.1)
|
133
|
+
mime-types (2.99.1)
|
134
|
+
mini_portile2 (2.0.0)
|
135
|
+
multi_json (1.11.2)
|
136
|
+
nokogiri (1.6.7.2)
|
137
|
+
mini_portile2 (~> 2.0.0.rc2)
|
138
|
+
pry (0.10.3)
|
170
139
|
coderay (~> 1.1.0)
|
171
140
|
method_source (~> 0.8.1)
|
172
141
|
slop (~> 3.4)
|
173
|
-
pry-byebug (3.
|
174
|
-
byebug (~>
|
142
|
+
pry-byebug (3.3.0)
|
143
|
+
byebug (~> 8.0)
|
175
144
|
pry (~> 0.10)
|
176
145
|
pry-meta (0.0.10)
|
177
146
|
awesome_print
|
@@ -181,71 +150,34 @@ GEM
|
|
181
150
|
pry-remote (0.1.8)
|
182
151
|
pry (~> 0.9)
|
183
152
|
slop (~> 3.0)
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
activeresource (= 3.2.22)
|
196
|
-
activesupport (= 3.2.22)
|
197
|
-
bundler (~> 1.0)
|
198
|
-
railties (= 3.2.22)
|
199
|
-
railties (3.2.22)
|
200
|
-
actionpack (= 3.2.22)
|
201
|
-
activesupport (= 3.2.22)
|
202
|
-
rack-ssl (~> 1.3.2)
|
203
|
-
rake (>= 0.8.7)
|
204
|
-
rdoc (~> 3.4)
|
205
|
-
thor (>= 0.14.6, < 2.0)
|
206
|
-
rainbow (2.0.0)
|
207
|
-
rake (10.4.2)
|
208
|
-
rdoc (3.12.2)
|
209
|
-
json (~> 1.4)
|
210
|
-
rspec (3.3.0)
|
211
|
-
rspec-core (~> 3.3.0)
|
212
|
-
rspec-expectations (~> 3.3.0)
|
213
|
-
rspec-mocks (~> 3.3.0)
|
214
|
-
rspec-core (3.3.1)
|
215
|
-
rspec-support (~> 3.3.0)
|
216
|
-
rspec-expectations (3.3.0)
|
153
|
+
rbvmomi (1.8.2)
|
154
|
+
builder
|
155
|
+
nokogiri (>= 1.4.1)
|
156
|
+
trollop
|
157
|
+
rspec (3.4.0)
|
158
|
+
rspec-core (~> 3.4.0)
|
159
|
+
rspec-expectations (~> 3.4.0)
|
160
|
+
rspec-mocks (~> 3.4.0)
|
161
|
+
rspec-core (3.4.3)
|
162
|
+
rspec-support (~> 3.4.0)
|
163
|
+
rspec-expectations (3.4.0)
|
217
164
|
diff-lcs (>= 1.2.0, < 2.0)
|
218
|
-
rspec-support (~> 3.
|
219
|
-
rspec-mocks (3.
|
165
|
+
rspec-support (~> 3.4.0)
|
166
|
+
rspec-mocks (3.4.1)
|
220
167
|
diff-lcs (>= 1.2.0, < 2.0)
|
221
|
-
rspec-support (~> 3.
|
222
|
-
rspec-support (3.
|
168
|
+
rspec-support (~> 3.4.0)
|
169
|
+
rspec-support (3.4.1)
|
223
170
|
slop (3.6.0)
|
224
|
-
|
225
|
-
|
226
|
-
multi_json (~> 1.0)
|
227
|
-
rack (~> 1.0)
|
228
|
-
tilt (~> 1.1, != 1.3.0)
|
229
|
-
thor (0.19.1)
|
230
|
-
tilt (1.4.1)
|
231
|
-
transpec (3.1.0)
|
232
|
-
activesupport (>= 3.0, < 5.0)
|
233
|
-
astrolabe (~> 1.2)
|
234
|
-
bundler (~> 1.3)
|
235
|
-
json (~> 1.8)
|
236
|
-
parser (~> 2.2)
|
237
|
-
rainbow (>= 1.99.1, < 3.0)
|
238
|
-
treetop (1.4.15)
|
239
|
-
polyglot
|
240
|
-
polyglot (>= 0.3.1)
|
241
|
-
tzinfo (0.3.44)
|
171
|
+
trollop (2.1.2)
|
172
|
+
xml-simple (1.1.5)
|
242
173
|
|
243
174
|
PLATFORMS
|
244
175
|
ruby
|
245
176
|
|
246
177
|
DEPENDENCIES
|
247
178
|
pry-meta
|
248
|
-
rails (~> 3.1)
|
249
179
|
rspec
|
250
180
|
storage!
|
251
|
-
|
181
|
+
|
182
|
+
BUNDLED WITH
|
183
|
+
1.11.2
|
data/lib/storage/config.rb
CHANGED
@@ -19,9 +19,12 @@ module Storage
|
|
19
19
|
# Set the S3 access key.
|
20
20
|
attr_accessor :access_key
|
21
21
|
|
22
|
-
# Set the S3 secret key
|
22
|
+
# Set the S3 secret key.
|
23
23
|
attr_accessor :secret_key
|
24
24
|
|
25
|
+
# Set the S3 region.
|
26
|
+
attr_accessor :region
|
27
|
+
|
25
28
|
# Set the FileSystem storage path.
|
26
29
|
attr_accessor :path
|
27
30
|
end
|
@@ -9,7 +9,8 @@ module Storage
|
|
9
9
|
@connection ||= Fog::Storage.new({
|
10
10
|
:provider => 'AWS',
|
11
11
|
:aws_access_key_id => Storage::Config.access_key,
|
12
|
-
:aws_secret_access_key => Storage::Config.secret_key
|
12
|
+
:aws_secret_access_key => Storage::Config.secret_key,
|
13
|
+
:region => Storage::Config.region
|
13
14
|
})
|
14
15
|
end
|
15
16
|
|
data/lib/storage/version.rb
CHANGED
@@ -1,111 +1,134 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Storage::Strategies::S3 do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
4
|
+
context "region" do
|
5
|
+
before do
|
6
|
+
Storage.setup do |c|
|
7
|
+
c.strategy = :s3
|
8
|
+
c.access_key = "AKIAIOSFODNN7EXAMPLE"
|
9
|
+
c.secret_key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "sets default region" do
|
14
|
+
Storage::Config.region = nil
|
15
|
+
expect(Storage::Strategies::S3.connection.region).to eq("us-east-1")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "sets custom region" do
|
19
|
+
Storage::Config.region = "eu-west-1"
|
20
|
+
expect(Storage::Strategies::S3.connection.region).to eq("eu-west-1")
|
17
21
|
end
|
18
22
|
end
|
19
23
|
|
20
|
-
|
21
|
-
|
24
|
+
context "general" do
|
25
|
+
before do
|
26
|
+
@adapter = Storage::Strategies::S3
|
27
|
+
@source = RESOURCES.join("file.txt")
|
28
|
+
@destiny = TMP.join("lorem.txt")
|
29
|
+
@connection = double("connection")
|
30
|
+
@bucket = double("bucket")
|
31
|
+
|
32
|
+
allow(@adapter).to receive(:connection).and_return(@connection)
|
33
|
+
|
34
|
+
Storage.setup do |c|
|
35
|
+
c.strategy = :s3
|
36
|
+
c.access_key = "abc"
|
37
|
+
c.secret_key = "123"
|
38
|
+
c.region = "us-east-1"
|
39
|
+
end
|
40
|
+
end
|
22
41
|
|
23
|
-
|
24
|
-
|
25
|
-
expect(@bucket).to receive_message_chain('files.create').with(:key => 'lorem.txt', :body => handler, :public => true)
|
42
|
+
it "should save a file using file handler" do
|
43
|
+
handler = File.open(@source)
|
26
44
|
|
27
|
-
|
28
|
-
|
45
|
+
expect(@connection).to receive_message_chain('directories.get').with('files').and_return(@bucket)
|
46
|
+
expect(@adapter).to receive_message_chain('find_object').and_return(nil)
|
47
|
+
expect(@bucket).to receive_message_chain('files.create').with(:key => 'lorem.txt', :body => handler, :public => true)
|
29
48
|
|
30
|
-
|
31
|
-
|
32
|
-
expect(@adapter).to receive_message_chain('find_object').and_return(nil)
|
33
|
-
expect(@bucket).to receive_message_chain('files.create').with(:key => 'lorem.txt', :body => kind_of(File), :public => true)
|
49
|
+
Storage.store(handler, :name => "lorem.txt", :bucket => "files")
|
50
|
+
end
|
34
51
|
|
35
|
-
|
36
|
-
|
52
|
+
it "should save a file using a path" do
|
53
|
+
expect(@connection).to receive_message_chain('directories.get').with('files').and_return(@bucket)
|
54
|
+
expect(@adapter).to receive_message_chain('find_object').and_return(nil)
|
55
|
+
expect(@bucket).to receive_message_chain('files.create').with(:key => 'lorem.txt', :body => kind_of(File), :public => true)
|
37
56
|
|
38
|
-
|
39
|
-
|
40
|
-
expect(@connection).to receive_message_chain('directories.get').with('files').and_return(@bucket)
|
41
|
-
expect(@bucket).to receive_message_chain('files.get').with('lorem.txt').and_return(object)
|
42
|
-
expect(object).to receive(:destroy).and_return(true)
|
57
|
+
Storage.store(@source, :name => "lorem.txt", :bucket => "files")
|
58
|
+
end
|
43
59
|
|
44
|
-
|
45
|
-
|
60
|
+
it "should remove an existing file" do
|
61
|
+
object = double("object")
|
62
|
+
expect(@connection).to receive_message_chain('directories.get').with('files').and_return(@bucket)
|
63
|
+
expect(@bucket).to receive_message_chain('files.get').with('lorem.txt').and_return(object)
|
64
|
+
expect(object).to receive(:destroy).and_return(true)
|
46
65
|
|
47
|
-
|
48
|
-
|
49
|
-
expect(@bucket).to receive_message_chain('files.get').with('lorem.txt').and_return(nil)
|
66
|
+
expect(Storage.remove("lorem.txt", :bucket => "files")).to be_truthy
|
67
|
+
end
|
50
68
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
69
|
+
it "should raise when trying to removing an unexesting file" do
|
70
|
+
expect(@connection).to receive_message_chain('directories.get').with('files').and_return(@bucket)
|
71
|
+
expect(@bucket).to receive_message_chain('files.get').with('lorem.txt').and_return(nil)
|
55
72
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
73
|
+
expect {
|
74
|
+
Storage.remove("lorem.txt", :bucket => "files")
|
75
|
+
}.to raise_error(Storage::MissingFileError)
|
76
|
+
end
|
60
77
|
|
61
|
-
|
62
|
-
|
78
|
+
it "should retrieve an existing file (public url)" do
|
79
|
+
object = double("object", public_url: 'PUBLIC_URL')
|
80
|
+
expect(@connection).to receive_message_chain('directories.get').with('files').and_return(@bucket)
|
81
|
+
expect(@bucket).to receive_message_chain('files.get').with('lorem.txt').and_return(object)
|
63
82
|
|
64
|
-
|
65
|
-
|
83
|
+
expect(Storage.get("lorem.txt", :bucket => "files")).to eq('PUBLIC_URL')
|
84
|
+
end
|
66
85
|
|
67
|
-
|
68
|
-
|
69
|
-
expect(@bucket).to receive_message_chain('files.get').with('lorem.txt').and_return(object)
|
86
|
+
it "should retrieve an existing file (private url)" do
|
87
|
+
object = double("object", public_url: nil)
|
70
88
|
|
71
|
-
|
72
|
-
|
89
|
+
expect(object).to receive_message_chain('url').with(Time.now.to_i + 3600).and_return('PRIVATE_URL')
|
90
|
+
expect(@connection).to receive_message_chain('directories.get').with('files').and_return(@bucket)
|
91
|
+
expect(@bucket).to receive_message_chain('files.get').with('lorem.txt').and_return(object)
|
73
92
|
|
74
|
-
|
75
|
-
|
76
|
-
expect(@bucket).to receive_message_chain('files.get').with('lorem.txt').and_return(nil)
|
93
|
+
expect(Storage.get("lorem.txt", :bucket => "files")).to eq('PRIVATE_URL')
|
94
|
+
end
|
77
95
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
96
|
+
it "should raise when trying to retrieve an missing file" do
|
97
|
+
expect(@connection).to receive_message_chain('directories.get').with('files').and_return(@bucket)
|
98
|
+
expect(@bucket).to receive_message_chain('files.get').with('lorem.txt').and_return(nil)
|
99
|
+
|
100
|
+
expect {
|
101
|
+
Storage.get("lorem.txt", :bucket => "files")
|
102
|
+
}.to raise_error(Storage::MissingFileError)
|
103
|
+
end
|
82
104
|
|
83
|
-
|
84
|
-
|
105
|
+
it "should raise when trying to retrieve an missing bucket" do
|
106
|
+
expect(@connection).to receive_message_chain('directories.get').with('files').and_return(nil)
|
85
107
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
108
|
+
expect {
|
109
|
+
Storage.get("lorem.txt", :bucket => "files")
|
110
|
+
}.to raise_error(Storage::MissingFileError)
|
111
|
+
end
|
90
112
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
113
|
+
it "should create a bucket and trying to store a file on a missing bucket" do
|
114
|
+
expect(@adapter).to receive_message_chain('find_object').and_return(nil)
|
115
|
+
allow(@connection).to receive_message_chain('directories.get').and_return(nil)
|
116
|
+
expect(@connection).to receive_message_chain('directories.create').with(key: 'files', public: false).and_return(@bucket)
|
95
117
|
|
96
|
-
|
118
|
+
@bucket.as_null_object
|
97
119
|
|
98
|
-
|
99
|
-
|
120
|
+
Storage.store(@source, :name => 'lorem.txt', :bucket => "files")
|
121
|
+
end
|
100
122
|
|
101
|
-
|
102
|
-
|
123
|
+
it "should raise when saving a file that already exists" do
|
124
|
+
object = double("object")
|
103
125
|
|
104
|
-
|
105
|
-
|
126
|
+
expect(@connection).to receive_message_chain('directories.get').with('files').and_return(@bucket)
|
127
|
+
expect(@bucket).to receive_message_chain('files.get').with('lorem.txt').and_return(object)
|
106
128
|
|
107
|
-
|
108
|
-
|
109
|
-
|
129
|
+
expect {
|
130
|
+
Storage.store(@source, :name => 'lorem.txt', :bucket => 'files')
|
131
|
+
}.to raise_error(Storage::FileAlreadyExistsError)
|
132
|
+
end
|
110
133
|
end
|
111
134
|
end
|
data/storage.gemspec
CHANGED
@@ -16,9 +16,8 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.require_paths = ["lib"]
|
17
17
|
|
18
18
|
s.add_dependency "fog"
|
19
|
+
s.add_dependency "mime-types"
|
19
20
|
|
20
|
-
s.add_development_dependency "rails" , "~> 3.1"
|
21
21
|
s.add_development_dependency "rspec"
|
22
|
-
s.add_development_dependency "transpec"
|
23
22
|
s.add_development_dependency "pry-meta"
|
24
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: storage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog
|
@@ -25,27 +25,13 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '3.1'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '3.1'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
28
|
+
name: mime-types
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
31
|
- - ">="
|
46
32
|
- !ruby/object:Gem::Version
|
47
33
|
version: '0'
|
48
|
-
type: :
|
34
|
+
type: :runtime
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
@@ -53,7 +39,7 @@ dependencies:
|
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
42
|
+
name: rspec
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - ">="
|
@@ -126,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
112
|
version: '0'
|
127
113
|
requirements: []
|
128
114
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
115
|
+
rubygems_version: 2.5.1
|
130
116
|
signing_key:
|
131
117
|
specification_version: 4
|
132
118
|
summary: 'This gem provides a simple API for multiple storage backends. Supported
|