autobuild 1.7.11.rc3 → 1.7.11.rc4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/autobuild/environment.rb +39 -7
- data/lib/autobuild/version.rb +1 -1
- metadata +2 -2
@@ -34,6 +34,10 @@ module Autobuild
|
|
34
34
|
if windows? then "set %s=%s"
|
35
35
|
else "%s=%s"
|
36
36
|
end
|
37
|
+
SHELL_CONDITIONAL_SET_COMMAND =
|
38
|
+
if windows? then "set %s=%s"
|
39
|
+
else "if test -z \"$%1$s\"; then\n %1$s=%3$s\nelse\n %1$s=%2$s\nfi"
|
40
|
+
end
|
37
41
|
SHELL_UNSET_COMMAND =
|
38
42
|
if windows? then "unset %s"
|
39
43
|
else "unset %s"
|
@@ -206,14 +210,39 @@ module Autobuild
|
|
206
210
|
env_update_var(name)
|
207
211
|
end
|
208
212
|
|
209
|
-
|
213
|
+
# Returns an environment variable value
|
214
|
+
#
|
215
|
+
# @param [String] name the environment variable name
|
216
|
+
# @option options [Symbol] inheritance_mode (:expand) controls how
|
217
|
+
# environment variable inheritance should be done. If :expand, the current
|
218
|
+
# envvar value is inserted in the generated value. If :keep, the name of
|
219
|
+
# the envvar is inserted (as e.g. $NAME). If :ignore, inheritance is
|
220
|
+
# disabled in the generated value. Not that this applies only for the
|
221
|
+
# environment variables for which inheritance has been enabled with
|
222
|
+
# #env_inherit, other variables always behave as if :ignore was selected.
|
223
|
+
# @return [nil,Array<String>] either nil if this environment variable is not
|
224
|
+
# set, or an array of values. How the values should be joined to form the
|
225
|
+
# actual value is OS-specific, and not handled by this method
|
226
|
+
def self.env_value(name, options = Hash.new)
|
227
|
+
# For backward compatibility only
|
228
|
+
if !options.respond_to?(:to_hash)
|
229
|
+
if options
|
230
|
+
options = Hash[:inheritance_mode => :expand]
|
231
|
+
else
|
232
|
+
options = Hash[:inheritance_mode => :keep]
|
233
|
+
end
|
234
|
+
end
|
235
|
+
options = Kernel.validate_options options,
|
236
|
+
inheritance_mode: :expand
|
237
|
+
inheritance_mode = options[:inheritance_mode]
|
238
|
+
|
210
239
|
if !environment[name] && !inherited_environment[name] && !SYSTEM_ENV[name]
|
211
240
|
nil
|
212
241
|
else
|
213
242
|
inherited =
|
214
|
-
if
|
243
|
+
if inheritance_mode == :expand
|
215
244
|
inherited_environment[name] || []
|
216
|
-
elsif env_inherit?(name)
|
245
|
+
elsif inheritance_mode == :keep && env_inherit?(name)
|
217
246
|
["$#{name}"]
|
218
247
|
else []
|
219
248
|
end
|
@@ -301,12 +330,15 @@ module Autobuild
|
|
301
330
|
variables = []
|
302
331
|
Autobuild.environment.each do |name, _|
|
303
332
|
variables << name
|
304
|
-
|
333
|
+
value_with_inheritance = env_value(name, inheritance_mode: :keep)
|
334
|
+
value_without_inheritance = env_value(name, inheritance_mode: :ignore)
|
305
335
|
|
306
|
-
if
|
307
|
-
shell_line = SHELL_SET_COMMAND % [name, value.join(ENV_LIST_SEPARATOR)]
|
308
|
-
else
|
336
|
+
if !value_with_inheritance
|
309
337
|
shell_line = SHELL_UNSET_COMMAND % [name]
|
338
|
+
elsif value_with_inheritance == value_without_inheritance # no inheritance
|
339
|
+
shell_line = SHELL_SET_COMMAND % [name, value_with_inheritance.join(ENV_LIST_SEPARATOR)]
|
340
|
+
else
|
341
|
+
shell_line = SHELL_CONDITIONAL_SET_COMMAND % [name, value_with_inheritance.join(ENV_LIST_SEPARATOR), value_without_inheritance.join(ENV_LIST_SEPARATOR)]
|
310
342
|
end
|
311
343
|
io.puts shell_line
|
312
344
|
end
|
data/lib/autobuild/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: autobuild
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.11.
|
4
|
+
version: 1.7.11.rc4
|
5
5
|
prerelease: 7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|