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 +4 -4
- data/lib/build/environment/base.rb +8 -0
- data/lib/build/environment/system.rb +27 -1
- data/lib/build/environment/version.rb +1 -1
- data/spec/build/environment/system_spec.rb +53 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a75067001af37e60e254e389552e45fab4838436
|
4
|
+
data.tar.gz: 32da29ef60963f838c72847c18ce393f36a1b088
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32e81d1ac024530c33deeab102b52b8743f0c98020e08f8652c2d2428acdec97a9eb8847d9386bca9fa5730d870117b2c2de4c58c492b82417ca111775282f08
|
7
|
+
data.tar.gz: aa38cf0cb47d7a114e3ac9e1a347675d1c33fd610b631f245b74794f25926b8eccefea3f2e534975c793545abc645cd7326f22de827954354d1e3598049e7af2
|
@@ -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
|
-
|
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
|
@@ -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.
|
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-
|
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
|