deimos-ruby 1.4.0.pre.beta1 → 1.4.0.pre.beta2
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/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/deimos/config/configurable.rb +5 -3
- data/lib/deimos/version.rb +1 -1
- data/spec/config/configurable_spec.rb +16 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af6aca3bfdec091463dfbc9774d0c3f41e38020c2f8c634609d2471dc327479e
|
4
|
+
data.tar.gz: 727a05937a6814e650898fd239aa53075b16d354600909cd76308aa6b697226a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26c751b958de521c87a8824c77f3c47db65806aad257c4948f27b4be4a4b559cf768b3d0291a10060539f9306c748d3028e43c15599f87680be83d8001b751d3
|
7
|
+
data.tar.gz: 8f97fb5eb5fb8538f2fce6806f9d8a152d6b458f56da30ae0e68fa9892bfe6f86679e55b295e2b342b687a912cb7e6345e9047ec4d7d783f0e4f539f52245405
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## UNRELEASED
|
9
9
|
|
10
|
+
# [1.4.0-beta2] - 2019-11-22
|
11
|
+
- FIX: settings with default_proc were being called immediately
|
12
|
+
instead of being lazy-evaluated.
|
13
|
+
|
10
14
|
# [1.4.0-beta1] - 2019-11-22
|
11
15
|
- Complete revamp of configuration method.
|
12
16
|
|
data/Gemfile.lock
CHANGED
@@ -38,8 +38,6 @@ module Deimos
|
|
38
38
|
def reset!
|
39
39
|
if self.value.is_a?(ConfigStruct)
|
40
40
|
self.value.reset!
|
41
|
-
elsif self.default_proc
|
42
|
-
self.value = self.default_proc.call
|
43
41
|
else
|
44
42
|
self.value = self.default_value
|
45
43
|
end
|
@@ -206,7 +204,11 @@ module Deimos
|
|
206
204
|
@settings[config_key].value = args[0]
|
207
205
|
else
|
208
206
|
# Get the value
|
209
|
-
@settings[config_key]
|
207
|
+
setting = @settings[config_key]
|
208
|
+
if setting.default_proc && setting.value.nil?
|
209
|
+
setting.value = setting.default_proc.call
|
210
|
+
end
|
211
|
+
setting.value
|
210
212
|
end
|
211
213
|
end
|
212
214
|
|
data/lib/deimos/version.rb
CHANGED
@@ -29,6 +29,22 @@ describe Deimos::Configurable do
|
|
29
29
|
expect { MyConfig.config.group.set4 }.to raise_error(NameError)
|
30
30
|
end
|
31
31
|
|
32
|
+
it 'should not call the proc until it has to' do
|
33
|
+
num_calls = 0
|
34
|
+
value_proc = proc do
|
35
|
+
num_calls += 1
|
36
|
+
num_calls
|
37
|
+
end
|
38
|
+
MyConfig.configure do
|
39
|
+
setting :set_with_proc, default_proc: value_proc
|
40
|
+
end
|
41
|
+
expect(num_calls).to eq(0)
|
42
|
+
expect(MyConfig.config.set_with_proc).to eq(1)
|
43
|
+
# calling twice should not call the proc again
|
44
|
+
expect(MyConfig.config.set_with_proc).to eq(1)
|
45
|
+
expect(num_calls).to eq(1)
|
46
|
+
end
|
47
|
+
|
32
48
|
it "should raise error when setting configs that don't exist" do
|
33
49
|
expect { MyConfig.configure { set15 'some_value' } }.to raise_error(NameError)
|
34
50
|
end
|