build-environment 1.3.0 → 1.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cbde2dd7a4e40677186a1f5dc82e2c415fdff1738ef54a2ee1f2da0de8c8d18
4
- data.tar.gz: ee888276adefea980f5c940a423790f4cf575879287e7eba21f7ca86a1608f21
3
+ metadata.gz: bb1a640db22cdf5b234170fa80d39fcd85556586e106253fa1ddccfbbf2587ef
4
+ data.tar.gz: 522ad2c4f2bcb93aeabd3ae4886129cb8b258483e80538558a7e70c84b146c36
5
5
  SHA512:
6
- metadata.gz: 04c258214eb2ca8130ba7f2069aadb59a78f2e9489855f42bbc0f324f654befac0c5d6d14247fdd3bb7c77698449458e51395f083378b52394008ac0830c980f
7
- data.tar.gz: 9516af2a70aae05dd2548502f321c6e140ecb0144b2f7944fd5ae5cde4cd8e438d45f9f2bec5d9292941892a876a20013fac436c66ceb370361797564f168645
6
+ metadata.gz: ac43aff420aac34dbb0ba55764a3da8fd3d1a61a11d1951bfe08e7e58362582a788e21e90b4ca43774326d00beaa49bc5738f66b4f0c032fb73d3ab0787735c7
7
+ data.tar.gz: 379f5ad46b9ed1e7bd5a26228d14d684c8f0da67ea5d3b49e28a053944fffedc6205d2582691a156bcf0f8becb4fc505c3811cb176f9f4df3813e22d398f0f61
@@ -18,6 +18,8 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
+ require 'ostruct'
22
+
21
23
  module Build
22
24
  class Environment
23
25
  Default = Struct.new(:value)
@@ -54,7 +56,7 @@ module Build
54
56
  @environment[name] = block
55
57
 
56
58
  return name
57
- elsif !block_given? and args.any?
59
+ elsif !block_given? and !args.empty?
58
60
  if args.count == 1
59
61
  @environment[name] = args.first
60
62
  else
@@ -88,6 +90,10 @@ module Build
88
90
  @environment.parent
89
91
  end
90
92
 
93
+ def hash(**options)
94
+ OpenStruct.new(options)
95
+ end
96
+
91
97
  def default(name)
92
98
  @environment[name] = Default.new(@environment[name])
93
99
 
@@ -91,6 +91,8 @@ module Build
91
91
  elsif Array === previous
92
92
  # Merge with the parent value
93
93
  hash[key] = previous + Array(value)
94
+ elsif OpenStruct === value
95
+ hash[key] = value.to_h
94
96
  else
95
97
  hash[key] = value
96
98
  end
@@ -1,5 +1,5 @@
1
1
  module Build
2
2
  class Environment
3
- VERSION = "1.3.0"
3
+ VERSION = "1.4.0"
4
4
  end
5
5
  end
@@ -120,4 +120,28 @@ RSpec.describe Build::Environment do
120
120
  architectures: ["-march", "i386"]
121
121
  }
122
122
  end
123
+
124
+ it "can make key with nil value" do
125
+ environment = Build::Environment.new do
126
+ thing nil
127
+ end
128
+
129
+ expect(environment.to_h).to be == {thing: nil}
130
+ end
131
+
132
+ it "can make key with false value" do
133
+ environment = Build::Environment.new do
134
+ thing false
135
+ end
136
+
137
+ expect(environment.to_h).to be == {thing: false}
138
+ end
139
+
140
+ it "can make key with hash value" do
141
+ environment = Build::Environment.new do
142
+ thing hash(foo: 10)
143
+ end
144
+
145
+ expect(environment.to_h).to be == {thing: {foo: 10}}
146
+ end
123
147
  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.3.0
4
+ version: 1.4.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-02-15 00:00:00.000000000 Z
11
+ date: 2019-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: covered