build-environment 1.5.0 → 1.6.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0b7457a43d013d7685ac89c049b96c83e54f055f9899fa471c018c22abdcb79
|
4
|
+
data.tar.gz: 8288a35b0fa3184c91ed00852c055d1dd38819da00050e244416d768793028b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee2f7c0557ee02fad1cb194504cab735c400561b23b23846acb644985d2eb4253d09657aa00eb10077dba2c663fc5ba8104264dff290f9e09583daaab2105476
|
7
|
+
data.tar.gz: 5d7c45283557cbd02decf42c4cdf04e78fe0df58edf447b6a026812e1a0368b83be8fa0eade31f9710ad964dbb7f4ccbdf4282e39ed95484243267f94d318880
|
@@ -23,6 +23,7 @@ module Build
|
|
23
23
|
class Evaluator
|
24
24
|
def initialize(environment)
|
25
25
|
@environment = environment
|
26
|
+
@cache = {}
|
26
27
|
end
|
27
28
|
|
28
29
|
def respond_to?(name, include_private = false)
|
@@ -30,7 +31,7 @@ module Build
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def method_missing(name)
|
33
|
-
object_value(@environment[name])
|
34
|
+
@cache[name] ||= object_value(@environment[name])
|
34
35
|
end
|
35
36
|
|
36
37
|
# Compute the literal object value for a given key:
|
@@ -34,6 +34,23 @@ RSpec.describe Build::Environment do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
context '#include?' do
|
38
|
+
it "should not include anything" do
|
39
|
+
expect(subject.include?(:thing)).to be_falsey
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should include key" do
|
43
|
+
subject[:thing] = 42
|
44
|
+
expect(subject.include?(:thing)).to be_truthy
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should include key if parent includes key" do
|
48
|
+
subject[:thing] = 42
|
49
|
+
child = Build::Environment.new(subject)
|
50
|
+
expect(child.include?(:thing)).to be_truthy
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
37
54
|
it "should chain environments together" do
|
38
55
|
a = Build::Environment.new
|
39
56
|
a[:cflags] = ["-std=c++11"]
|
@@ -37,4 +37,16 @@ RSpec.describe Build::Environment::Evaluator do
|
|
37
37
|
|
38
38
|
expect(environment.flatten.evaluator.dinner).to be == "apples"
|
39
39
|
end
|
40
|
+
|
41
|
+
it "caches results" do
|
42
|
+
environment = Build::Environment.new do
|
43
|
+
index = 0
|
44
|
+
size {index += 1}
|
45
|
+
end
|
46
|
+
|
47
|
+
evaluator = environment.flatten.evaluator
|
48
|
+
|
49
|
+
expect(evaluator.size).to be == 1
|
50
|
+
expect(evaluator.size).to be == 1
|
51
|
+
end
|
40
52
|
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.
|
4
|
+
version: 1.6.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-03-
|
11
|
+
date: 2019-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: covered
|