deimos-ruby 1.4.0.pre.beta1 → 1.4.0.pre.beta2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b4c2a6f41276ada5bf402ac01c6cf445a014a155bbcc6fe48e83bbb9aa1d8a2
4
- data.tar.gz: 1041a4c5051900134f66893e86564c0ef896df269d0af9973aaf7f1f7cecb733
3
+ metadata.gz: af6aca3bfdec091463dfbc9774d0c3f41e38020c2f8c634609d2471dc327479e
4
+ data.tar.gz: 727a05937a6814e650898fd239aa53075b16d354600909cd76308aa6b697226a
5
5
  SHA512:
6
- metadata.gz: fdea52b89a1b788d9bdd5b6244d4f278139fb01e10b201720dd2afe052a418251a784d2756624cb3896d705016dbca0252206b27163a2c5e2c7eb200294b5979
7
- data.tar.gz: 5df060deb523e4b4879f47a18034960afb905edde95da9ac98f7dd5f5e0a022e1e8be3b81c13685c26c6837ed3ef6505394607469b075b8e2b1068ddabf61bcb
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deimos-ruby (1.4.0.pre.beta1)
4
+ deimos-ruby (1.4.0.pre.beta2)
5
5
  avro-patches (~> 0.3)
6
6
  avro_turf (~> 0.8)
7
7
  phobos (~> 1.8.2.pre.beta2)
@@ -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].value
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Deimos
4
- VERSION = '1.4.0-beta1'
4
+ VERSION = '1.4.0-beta2'
5
5
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deimos-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0.pre.beta1
4
+ version: 1.4.0.pre.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner