Module: Build::Environment::System

Defined in:
lib/build/environment/system.rb

Class Method Summary collapse

Class Method Details

.convert_to_shell(environment) ⇒ Object


53
54
55
56
57
58
59
60
# File 'lib/build/environment/system.rb', line 53

def self.convert_to_shell(environment)
	values = environment.values.select{|key, value| valid_for_export(value)}
	
	Hash[values.map{|key, value| [
		key.to_s.upcase,
		shell_escape(value)
	]}]
end

.shell_escape(value) ⇒ Object


24
25
26
27
28
29
30
31
32
# File 'lib/build/environment/system.rb', line 24

def self.shell_escape(value)
	case value
	when Array
		value.flatten.collect{|argument| shell_escape(argument)}.join(' ')
	else
		# Ensure that any whitespace has been escaped:
		value.to_s.gsub(/ /, '\ ')
	end
end

.valid_for_export(value) ⇒ Object


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/build/environment/system.rb', line 34

def self.valid_for_export(value)
	case value
	when Array
		true
	when Symbol
		false
	when Proc
		false
	when Default
		false
	when Replace
		false
	when Define
		false
	else
		true
	end
end