build-environment 1.12.1 → 1.13.0

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: c59a041f9e185733886e13a24f4e434369a5e6a88d4203454cd2132e4adcc433
4
- data.tar.gz: 8114f0fb6b0810ea9211d1d4c2644340fd6e1d048f7feefe2187984f1af49532
3
+ metadata.gz: 9b0a2e29f0f56710ef70f68f29274237dcdb9fe0a37425280adb8fadf11ded99
4
+ data.tar.gz: 1c9f18a94aeaca0a1a484b9a3f0ac97068074dd737311634325a5a200e2ace0a
5
5
  SHA512:
6
- metadata.gz: f529b8c0a93eca654f45079fa54785a7d7bedd50dff9c04257b430bee65b3ce122fa0fe2db18a691d81ec95275fc083e21171534be1e9943a261035324736275
7
- data.tar.gz: 34f5d39bec20b91d6ef7204420fad4ff4ab74cb85ed4e70fa8a34cec64e695b908b8fd78cdbe5147e2e7f106a32ecf7bbb9dcbed5c9be8281b318f151bcdc446
6
+ metadata.gz: 42ae4a31779fc52ecfc4aaa8616c1948c80c1cd2a9fd6c76a48832ba870f0e2c6e8613bd0c743484c46b7a7be259659b2c638c1e75341cda39ae688130282e01
7
+ data.tar.gz: 1337f8d7706cc6461c850b801e07ce7a68ac11571ec3af92f137a95d5384a6dbcb36f805e779b0ad8017ca0259442176c86bc513490af6fbf038af376fe055ee
@@ -26,6 +26,13 @@ module Build
26
26
  @cache = {}
27
27
  end
28
28
 
29
+ def initialize_dup(other)
30
+ @environment = other.instance_variable_get(:@environment)
31
+ @cache = other.instance_variable_get(:@cache).dup
32
+
33
+ super
34
+ end
35
+
29
36
  def respond_to?(name, include_private = false)
30
37
  @environment.include?(name) || super
31
38
  end
@@ -1,5 +1,5 @@
1
1
  module Build
2
2
  class Environment
3
- VERSION = "1.12.1"
3
+ VERSION = "1.13.0"
4
4
  end
5
5
  end
@@ -20,33 +20,45 @@
20
20
 
21
21
  require 'build/environment'
22
22
 
23
+ require 'securerandom'
24
+
23
25
  RSpec.describe Build::Environment::Evaluator do
24
- it "can evaluate procs" do
25
- environment = Build::Environment.new do
26
+ let(:environment) do
27
+ Build::Environment.new do
26
28
  fruit {"apples"}
29
+ dinner :fruit
27
30
  end
28
-
29
- expect(environment.flatten.evaluator.fruit).to be == "apples"
30
31
  end
31
32
 
32
- it "can evaluate symbols" do
33
- environment = Build::Environment.new do
34
- fruit {"apples"}
35
- dinner :fruit
36
- end
37
-
38
- expect(environment.flatten.evaluator.dinner).to be == "apples"
33
+ subject {environment.flatten.evaluator}
34
+
35
+ it "can evaluate procs" do
36
+ expect(subject.fruit).to be == "apples"
39
37
  end
40
38
 
41
- it "caches results" do
42
- environment = Build::Environment.new do
43
- index = 0
44
- size {index += 1}
39
+ it "can dereference symbols" do
40
+ expect(subject.dinner).to be == "apples"
41
+ end
42
+
43
+ context "computed values" do
44
+ let(:environment) do
45
+ Build::Environment.new do
46
+ secret {SecureRandom.hex(32)}
47
+ end
45
48
  end
46
49
 
47
- evaluator = environment.flatten.evaluator
50
+ it "caches the computed value" do
51
+ secret = subject.secret
52
+
53
+ expect(subject.secret).to be == secret
54
+ end
48
55
 
49
- expect(evaluator.size).to be == 1
50
- expect(evaluator.size).to be == 1
56
+ describe '#dup' do
57
+ it "retains existing cache" do
58
+ secret = subject.secret
59
+
60
+ expect(subject.dup.secret).to be == secret
61
+ end
62
+ end
51
63
  end
52
64
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: build-environment
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.1
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-07 00:00:00.000000000 Z
11
+ date: 2020-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: covered
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
120
- rubygems_version: 3.0.4
120
+ rubygems_version: 3.1.2
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: A nested hash data structure for controlling build environments.