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: dc378a4e1ebc51b575e509352a328e0782d353f726da735d347d0afbdd0b1b96
4
- data.tar.gz: 6e013d9a197e0b6b78c2c59f7c000734a3949028ca81c23b0defe1fdcf5518f7
3
+ metadata.gz: a0b7457a43d013d7685ac89c049b96c83e54f055f9899fa471c018c22abdcb79
4
+ data.tar.gz: 8288a35b0fa3184c91ed00852c055d1dd38819da00050e244416d768793028b8
5
5
  SHA512:
6
- metadata.gz: 65e8b37760528ce3f79b58c12def6db4b09cfbd5ac46623a5db514981a234e7824960585739bcbc64daa8d3ecebd8c940fc6179827b8d26e1ae11a8bc4d1897a
7
- data.tar.gz: 33750cd643a337a5051a955c7fb76347e430515884777afd0d843603cf615eb70c49bb780078e4279dc62c6d618095d75eb342b6861340daabbf0d32857d76a2
6
+ metadata.gz: ee2f7c0557ee02fad1cb194504cab735c400561b23b23846acb644985d2eb4253d09657aa00eb10077dba2c663fc5ba8104264dff290f9e09583daaab2105476
7
+ data.tar.gz: 5d7c45283557cbd02decf42c4cdf04e78fe0df58edf447b6a026812e1a0368b83be8fa0eade31f9710ad964dbb7f4ccbdf4282e39ed95484243267f94d318880
@@ -63,7 +63,11 @@ module Build
63
63
  end
64
64
 
65
65
  def include?(key)
66
- lookup(key) != nil
66
+ if @values.include?(key)
67
+ true
68
+ elsif @parent
69
+ @parent.include?(key)
70
+ end
67
71
  end
68
72
 
69
73
  def size
@@ -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:
@@ -1,5 +1,5 @@
1
1
  module Build
2
2
  class Environment
3
- VERSION = "1.5.0"
3
+ VERSION = "1.6.0"
4
4
  end
5
5
  end
@@ -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.5.0
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-02 00:00:00.000000000 Z
11
+ date: 2019-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: covered