saviour 0.4.8 → 0.4.9
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52d3e1c76ad21adf351834a7d0dd101582e9a835
|
4
|
+
data.tar.gz: 2ac25be01722c1432e8f75408be8a448b0505761
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ace50b4dfc8bfc04ab889fcbf92955d0815eb9f48fa97900ca3f9227d80deabba9f8e74e79f1ee4258f288058268d34faeab0f0563e3ece363c868e53d637195
|
7
|
+
data.tar.gz: b7b9b71f3150a8142a84ddcf9979ba3be6cea056692d42f580e2496db2525103368ceb158e9fadba150292103573998e82488ba0ca29af654efabfaed3273da9
|
data/lib/saviour/version.rb
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "file information" do
|
4
|
+
before { allow(Saviour::Config).to receive(:storage).and_return(Saviour::LocalStorage.new(local_prefix: @tmpdir, public_url_prefix: "http://domain.com")) }
|
5
|
+
|
6
|
+
let(:uploader) {
|
7
|
+
Class.new(Saviour::BaseUploader) do
|
8
|
+
store_dir { "/store/dir/#{model.id}" }
|
9
|
+
process_with_file do |file, name|
|
10
|
+
model.result1 = file.stat.size
|
11
|
+
|
12
|
+
path = file.path
|
13
|
+
|
14
|
+
# Assign new contents on the same path, forcing a new inode
|
15
|
+
::File.delete(path)
|
16
|
+
::File.write(path, "SOME NEW DATA, LONGER")
|
17
|
+
|
18
|
+
[file, name]
|
19
|
+
end
|
20
|
+
|
21
|
+
process_with_file do |file, name|
|
22
|
+
model.result2 = file.stat.size # This must be the size of the new contents
|
23
|
+
|
24
|
+
[file, name]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
}
|
28
|
+
|
29
|
+
let(:klass) {
|
30
|
+
klass = Class.new(Test) {
|
31
|
+
attr_accessor :result1, :result2
|
32
|
+
include Saviour::Model
|
33
|
+
}
|
34
|
+
klass.attach_file :file, uploader
|
35
|
+
klass
|
36
|
+
}
|
37
|
+
|
38
|
+
it "is renewed at every process_with_file, clearing stale data on the file instance" do
|
39
|
+
f = Tempfile.new("test")
|
40
|
+
f.write("original") # 8 bytes
|
41
|
+
f.flush
|
42
|
+
|
43
|
+
a = klass.create! file: f
|
44
|
+
expect(a.result1).to eq 8
|
45
|
+
expect(a.result2).to eq 21
|
46
|
+
|
47
|
+
f.close!
|
48
|
+
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saviour
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roger Campos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -195,6 +195,7 @@ files:
|
|
195
195
|
- spec/feature/persisted_path_spec.rb
|
196
196
|
- spec/feature/processors_api_spec.rb
|
197
197
|
- spec/feature/reload_model_spec.rb
|
198
|
+
- spec/feature/reopens_file_at_every_process_spec.rb
|
198
199
|
- spec/feature/rewind_source_before_read_spec.rb
|
199
200
|
- spec/feature/transactional_behavior_spec.rb
|
200
201
|
- spec/feature/uploader_declaration_spec.rb
|