remote_files 1.6.0 → 1.6.1
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.
- data/lib/remote_files/configuration.rb +12 -1
- data/lib/remote_files/file_store.rb +4 -3
- data/lib/remote_files/fog_store.rb +2 -0
- data/lib/remote_files/memory_store.rb +1 -0
- data/lib/remote_files/resque_job.rb +4 -1
- data/lib/remote_files/version.rb +1 -1
- data/test/configuration_test.rb +34 -4
- data/test/file_store_test.rb +4 -0
- data/test/fog_store_test.rb +5 -0
- data/test/memory_store_test.rb +4 -0
- metadata +2 -8
@@ -116,10 +116,21 @@ module RemoteFiles
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def delete_now!(file)
|
119
|
+
exceptions = []
|
119
120
|
file.stored_in.each do |store_identifier|
|
120
121
|
store = lookup_store(store_identifier)
|
121
|
-
|
122
|
+
begin
|
123
|
+
store.delete!(file.identifier)
|
124
|
+
rescue NotFoundError => e
|
125
|
+
exceptions << e
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
if exceptions.size == file.stored_in.size # they all failed
|
130
|
+
raise exceptions.first
|
122
131
|
end
|
132
|
+
|
133
|
+
true
|
123
134
|
end
|
124
135
|
|
125
136
|
def synchronize!(file)
|
@@ -32,13 +32,14 @@ module RemoteFiles
|
|
32
32
|
:stored_in => [self]
|
33
33
|
# what about content-type? maybe use the mime-types gem?
|
34
34
|
)
|
35
|
-
rescue Errno::ENOENT
|
36
|
-
raise NotFoundError,
|
35
|
+
rescue Errno::ENOENT
|
36
|
+
raise NotFoundError, $!.message, $!.backtrace
|
37
37
|
end
|
38
38
|
|
39
39
|
def delete!(identifier)
|
40
40
|
(directory + identifier).delete
|
41
|
-
rescue Errno::ENOENT
|
41
|
+
rescue Errno::ENOENT
|
42
|
+
raise NotFoundError, $!.message, $!.backtrace
|
42
43
|
end
|
43
44
|
|
44
45
|
def url(identifier)
|
data/lib/remote_files/version.rb
CHANGED
data/test/configuration_test.rb
CHANGED
@@ -158,11 +158,41 @@ describe RemoteFiles::Configuration do
|
|
158
158
|
end
|
159
159
|
|
160
160
|
describe '::delete_now!' do
|
161
|
-
|
161
|
+
before do
|
162
162
|
@file.stored_in.replace([:mock1, :mock2])
|
163
|
-
|
164
|
-
|
165
|
-
|
163
|
+
end
|
164
|
+
|
165
|
+
describe 'when the file is in all of stores' do
|
166
|
+
before do
|
167
|
+
@mock_store1.data[@file.identifier] = {:content_type => 'text/plain', :content => 'content'}
|
168
|
+
@mock_store2.data[@file.identifier] = {:content_type => 'text/plain', :content => 'content'}
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'should delete the file from all the stores' do
|
172
|
+
@configuration.delete_now!(@file)
|
173
|
+
@mock_store1.data.has_key?(@file.identifier).must_equal false
|
174
|
+
@mock_store2.data.has_key?(@file.identifier).must_equal false
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe 'when the file is in some of stores' do
|
179
|
+
before do
|
180
|
+
@mock_store2.data[@file.identifier] = {:content_type => 'text/plain', :content => 'content'}
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'should delete the file from all the stores' do
|
184
|
+
@configuration.delete_now!(@file)
|
185
|
+
@mock_store1.data.has_key?(@file.identifier).must_equal false
|
186
|
+
@mock_store2.data.has_key?(@file.identifier).must_equal false
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe 'when the file is in none of stores' do
|
191
|
+
it 'raises a NotFoundError' do
|
192
|
+
lambda { @configuration.delete_now!(@file) }.must_raise(RemoteFiles::NotFoundError)
|
193
|
+
@mock_store1.data.has_key?(@file.identifier).must_equal false
|
194
|
+
@mock_store2.data.has_key?(@file.identifier).must_equal false
|
195
|
+
end
|
166
196
|
end
|
167
197
|
end
|
168
198
|
|
data/test/file_store_test.rb
CHANGED
@@ -70,6 +70,10 @@ describe RemoteFiles::FileStore do
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
+
it 'raises a NotFoundError if the file does not exist' do
|
74
|
+
lambda { @store.delete!('unknown') }.must_raise(RemoteFiles::NotFoundError)
|
75
|
+
end
|
76
|
+
|
73
77
|
it 'should destroy the file' do
|
74
78
|
assert (@store.directory + 'identifier').exist?
|
75
79
|
|
data/test/fog_store_test.rb
CHANGED
@@ -165,6 +165,11 @@ describe RemoteFiles::FogStore do
|
|
165
165
|
)
|
166
166
|
end
|
167
167
|
|
168
|
+
it 'raises a NotFoundError if the file does not exist' do
|
169
|
+
@store.directory.key = 'unknown' # to force an exception out of the fog
|
170
|
+
lambda { @store.delete!('unknown') }.must_raise(RemoteFiles::NotFoundError)
|
171
|
+
end
|
172
|
+
|
168
173
|
it 'should destroy the file' do
|
169
174
|
assert @store.directory.files.get('identifier')
|
170
175
|
|
data/test/memory_store_test.rb
CHANGED
@@ -59,6 +59,10 @@ describe RemoteFiles::MemoryStore do
|
|
59
59
|
@store.data['identifier'] = {:content_type => 'text/plain', :content => 'content'}
|
60
60
|
end
|
61
61
|
|
62
|
+
it 'raises a NotFoundError if the file does not exist' do
|
63
|
+
lambda { @store.delete!('unknown') }.must_raise(RemoteFiles::NotFoundError)
|
64
|
+
end
|
65
|
+
|
62
66
|
it 'should destroy the file' do
|
63
67
|
assert @store.data['identifier']
|
64
68
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remote_files
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -146,18 +146,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
146
|
- - ! '>='
|
147
147
|
- !ruby/object:Gem::Version
|
148
148
|
version: '0'
|
149
|
-
segments:
|
150
|
-
- 0
|
151
|
-
hash: 424450237323346317
|
152
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
150
|
none: false
|
154
151
|
requirements:
|
155
152
|
- - ! '>='
|
156
153
|
- !ruby/object:Gem::Version
|
157
154
|
version: '0'
|
158
|
-
segments:
|
159
|
-
- 0
|
160
|
-
hash: 424450237323346317
|
161
155
|
requirements: []
|
162
156
|
rubyforge_project:
|
163
157
|
rubygems_version: 1.8.24
|