build-environment 1.0.0 → 1.1.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
  SHA1:
3
- metadata.gz: f012093ceab4f38096a0f1b49a80b6c0de0ec75d
4
- data.tar.gz: 7be8813be74fe6f4b7708b243be04b8e2e795eb6
3
+ metadata.gz: a75067001af37e60e254e389552e45fab4838436
4
+ data.tar.gz: 32da29ef60963f838c72847c18ce393f36a1b088
5
5
  SHA512:
6
- metadata.gz: a9a8a44708e5b21e6bdcd65f4f160547b294cd6e076184b68c9230929c4564b91bf26042c8c81fe100e060619d6d2d0809aed8848128ab0207a2e0450f583139
7
- data.tar.gz: f7199c17fadd8c062c4ef47b0e5fbe96a13ff01071491ea3ef68e69c909ed4366d92af3daec0ec77df2792512d1f464116eebfb51446be8c3d45d7c298eecab4
6
+ metadata.gz: 32e81d1ac024530c33deeab102b52b8743f0c98020e08f8652c2d2428acdec97a9eb8847d9386bca9fa5730d870117b2c2de4c58c492b82417ca111775282f08
7
+ data.tar.gz: aa38cf0cb47d7a114e3ac9e1a347675d1c33fd610b631f245b74794f25926b8eccefea3f2e534975c793545abc645cd7326f22de827954354d1e3598049e7af2
@@ -45,6 +45,14 @@ module Build
45
45
  end
46
46
  end
47
47
 
48
+ def include?(key)
49
+ lookup(key) != nil
50
+ end
51
+
52
+ def size
53
+ @values.size + (@parent ? @parent.size : 0)
54
+ end
55
+
48
56
  def [] (key)
49
57
  environment = lookup(key)
50
58
 
@@ -31,8 +31,29 @@ module Build
31
31
  end
32
32
  end
33
33
 
34
+ def self.valid_for_export(value)
35
+ case value
36
+ when Array
37
+ true
38
+ when Symbol
39
+ false
40
+ when Proc
41
+ false
42
+ when Default
43
+ false
44
+ when Replace
45
+ false
46
+ when Define
47
+ false
48
+ else
49
+ true
50
+ end
51
+ end
52
+
34
53
  def self.convert_to_shell(environment)
35
- Hash[environment.values.map{|key, value| [
54
+ values = environment.values.select{|key, value| valid_for_export(value)}
55
+
56
+ Hash[values.map{|key, value| [
36
57
  key.to_s.upcase,
37
58
  shell_escape(value)
38
59
  ]}]
@@ -43,5 +64,10 @@ module Build
43
64
  def self.system_environment(env = ENV)
44
65
  self.new(Hash[env.map{|key, value| [key.downcase.to_sym, value]}])
45
66
  end
67
+
68
+ # Make a hash appropriate for a process environment
69
+ def export
70
+ System::convert_to_shell(self)
71
+ end
46
72
  end
47
73
  end
@@ -1,5 +1,5 @@
1
1
  module Build
2
2
  class Environment
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -0,0 +1,53 @@
1
+ # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require 'build/environment'
22
+ require 'build/environment/system'
23
+
24
+ module Build::Environment::SystemSpec
25
+ class Rule
26
+ def initialize(process_name, type)
27
+ @process_name = process_name
28
+ @type = type
29
+ end
30
+
31
+ attr :process_name
32
+ attr :type
33
+ end
34
+
35
+ describe Build::Environment do
36
+ it "should not export rule" do
37
+ a = Build::Environment.new do
38
+ cflags "-fPIC"
39
+
40
+ define Rule, "compile.foo" do
41
+ end
42
+ end
43
+
44
+ expect(a).to include(:cflags)
45
+ expect(a).to include('compile.foo')
46
+
47
+ exported = a.export
48
+
49
+ expect(exported.size).to be == 1
50
+ expect(exported).to_not include('COMPILE.FOO')
51
+ end
52
+ end
53
+ 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.0.0
4
+ version: 1.1.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: 2015-06-28 00:00:00.000000000 Z
11
+ date: 2015-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -74,6 +74,7 @@ files:
74
74
  - lib/build/environment/system.rb
75
75
  - lib/build/environment/version.rb
76
76
  - spec/build/environment/environment_spec.rb
77
+ - spec/build/environment/system_spec.rb
77
78
  homepage: ''
78
79
  licenses:
79
80
  - MIT
@@ -100,3 +101,4 @@ specification_version: 4
100
101
  summary: A nested hash data structure for controlling build environments.
101
102
  test_files:
102
103
  - spec/build/environment/environment_spec.rb
104
+ - spec/build/environment/system_spec.rb