saviour 0.2.1 → 0.2.2
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 +4 -4
- data/README.md +4 -3
- data/lib/saviour/config.rb +11 -8
- data/lib/saviour/version.rb +1 -1
- data/spec/feature/{access_to_model_and_mounted_as.rb → access_to_model_and_mounted_as_spec.rb} +3 -3
- data/spec/feature/crud_workflows_spec.rb +1 -2
- data/spec/feature/persisted_path_spec.rb +1 -2
- data/spec/feature/reload_model_spec.rb +1 -2
- data/spec/feature/validations_spec.rb +1 -2
- data/spec/feature/versions_spec.rb +1 -2
- data/spec/models/config_spec.rb +11 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68e8a4112de62c4fe7d28f634ba8b296a9c28602
|
4
|
+
data.tar.gz: 696487d7c403c9d8792825cefec5991a81f1b3dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6964d6d057e12efd48c702ad0928966c172d63f45579a8ab72df6fb07bfecf467167946b6a3267baaaee3a24f57165f2094f11937497bb64f70afe4587cd198
|
7
|
+
data.tar.gz: 29ed2dd0ffd4cc4fade49f01455b8715f24d5302a904259399f8859a6f761feab9b707f38300b7adba17878b506d9051c750f0f509864f21abf9ac8c6993f2b5
|
data/README.md
CHANGED
@@ -180,8 +180,9 @@ You must configure Saviour by providing the storage to use:
|
|
180
180
|
Saviour::Config.storage = MyStorageImplementation.new
|
181
181
|
```
|
182
182
|
|
183
|
-
The provided storage object
|
184
|
-
|
183
|
+
The provided storage object is considered a global configuration state that will be used by Saviour for all mounters.
|
184
|
+
However, this configuration is thread-safe and can be changed at runtime, allowing you in practice to work with different
|
185
|
+
storages by swapping them depending on your use case.
|
185
186
|
|
186
187
|
|
187
188
|
### public_url
|
@@ -389,7 +390,7 @@ Saviour::Config.processing_enabled = true
|
|
389
390
|
```
|
390
391
|
|
391
392
|
You can use this when running tests, for example, or if you want processors to not execute for some reason. The flag can be
|
392
|
-
changed in real time.
|
393
|
+
changed in real time and is thread-safe.
|
393
394
|
|
394
395
|
|
395
396
|
## Versions
|
data/lib/saviour/config.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
module Saviour
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
@storage || raise(RuntimeError, "You need to provide a storage! Set Saviour::Config.storage = xxx")
|
2
|
+
class Config
|
3
|
+
class NotImplemented
|
4
|
+
def method_missing(*)
|
5
|
+
raise(RuntimeError, "You need to provide a storage! Set Saviour::Config.storage = xxx")
|
6
|
+
end
|
8
7
|
end
|
9
8
|
|
10
|
-
|
11
|
-
|
9
|
+
extend ActiveSupport::PerThreadRegistry
|
10
|
+
|
11
|
+
attr_accessor :storage, :processing_enabled
|
12
|
+
|
13
|
+
self.processing_enabled = true
|
14
|
+
self.storage = NotImplemented.new
|
12
15
|
end
|
13
16
|
end
|
data/lib/saviour/version.rb
CHANGED
data/spec/feature/{access_to_model_and_mounted_as.rb → access_to_model_and_mounted_as_spec.rb}
RENAMED
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "access to model data from uploaders" do
|
4
|
-
before { Saviour::Config.storage
|
5
|
-
after { Saviour::Config.storage = nil }
|
4
|
+
before { allow(Saviour::Config).to receive(:storage).and_return(Saviour::LocalStorage.new(local_prefix: @tmpdir, public_url_prefix: "http://domain.com")) }
|
6
5
|
|
7
6
|
let(:uploader) {
|
8
7
|
Class.new(Saviour::BaseUploader) do
|
@@ -12,7 +11,8 @@ describe "access to model data from uploaders" do
|
|
12
11
|
}
|
13
12
|
|
14
13
|
let(:klass) {
|
15
|
-
a = Class.new(
|
14
|
+
a = Class.new(Test)
|
15
|
+
a.include Saviour
|
16
16
|
a.attach_file :file, uploader
|
17
17
|
a
|
18
18
|
}
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "saving a new file" do
|
4
|
-
before { Saviour::Config.storage
|
5
|
-
after { Saviour::Config.storage = nil }
|
4
|
+
before { allow(Saviour::Config).to receive(:storage).and_return(Saviour::LocalStorage.new(local_prefix: @tmpdir, public_url_prefix: "http://domain.com")) }
|
6
5
|
|
7
6
|
let(:uploader) {
|
8
7
|
Class.new(Saviour::BaseUploader) {
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "persisted path" do
|
4
|
-
before { Saviour::Config.storage
|
5
|
-
after { Saviour::Config.storage = nil }
|
4
|
+
before { allow(Saviour::Config).to receive(:storage).and_return(Saviour::LocalStorage.new(local_prefix: @tmpdir, public_url_prefix: "http://domain.com")) }
|
6
5
|
|
7
6
|
context "can change the default_path on the uploader and previous instances are not affected" do
|
8
7
|
it do
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "reload model" do
|
4
|
-
before { Saviour::Config.storage
|
5
|
-
after { Saviour::Config.storage = nil }
|
4
|
+
before { allow(Saviour::Config).to receive(:storage).and_return(Saviour::LocalStorage.new(local_prefix: @tmpdir, public_url_prefix: "http://domain.com")) }
|
6
5
|
|
7
6
|
context "updates the Saviour::File instance" do
|
8
7
|
it do
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "validations saving a new file" do
|
4
|
-
before { Saviour::Config.storage
|
5
|
-
after { Saviour::Config.storage = nil }
|
4
|
+
before { allow(Saviour::Config).to receive(:storage).and_return(Saviour::LocalStorage.new(local_prefix: @tmpdir, public_url_prefix: "http://domain.com")) }
|
6
5
|
|
7
6
|
let(:uploader) {
|
8
7
|
Class.new(Saviour::BaseUploader) {
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "saving a new file" do
|
4
|
-
before { Saviour::Config.storage
|
5
|
-
after { Saviour::Config.storage = nil }
|
4
|
+
before { allow(Saviour::Config).to receive(:storage).and_return(Saviour::LocalStorage.new(local_prefix: @tmpdir, public_url_prefix: "http://domain.com")) }
|
6
5
|
|
7
6
|
let(:uploader) {
|
8
7
|
Class.new(Saviour::BaseUploader) do
|
data/spec/models/config_spec.rb
CHANGED
@@ -1,16 +1,24 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Saviour::Config do
|
4
|
-
after { Saviour::Config.storage = nil }
|
5
|
-
|
6
4
|
describe "#storage" do
|
7
5
|
it do
|
8
|
-
expect { Saviour::Config.storage }.to raise_error(RuntimeError)
|
6
|
+
expect { Saviour::Config.storage.anything }.to raise_error(RuntimeError)
|
9
7
|
end
|
10
8
|
|
11
9
|
it do
|
12
10
|
Saviour::Config.storage = :test
|
13
11
|
expect(Saviour::Config.storage).to eq :test
|
14
12
|
end
|
13
|
+
|
14
|
+
it "is thread-safe" do
|
15
|
+
(0.upto(1_000)).map do |x|
|
16
|
+
Thread.new do
|
17
|
+
Saviour::Config.storage = x
|
18
|
+
sleep 0.05 # Simulate work
|
19
|
+
expect(Saviour::Config.storage).to eq x
|
20
|
+
end
|
21
|
+
end.each(&:join)
|
22
|
+
end
|
15
23
|
end
|
16
24
|
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.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roger Campos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -149,7 +149,7 @@ files:
|
|
149
149
|
- lib/saviour/url_source.rb
|
150
150
|
- lib/saviour/version.rb
|
151
151
|
- saviour.gemspec
|
152
|
-
- spec/feature/
|
152
|
+
- spec/feature/access_to_model_and_mounted_as_spec.rb
|
153
153
|
- spec/feature/crud_workflows_spec.rb
|
154
154
|
- spec/feature/persisted_path_spec.rb
|
155
155
|
- spec/feature/reload_model_spec.rb
|