autoproj 1.8.2.rc3 → 1.8.2.rc4

Sign up to get free protection for your applications and to get access to all the features.
@@ -366,8 +366,17 @@ module Autoproj
366
366
  end
367
367
  definitions = { 'HOME' => ENV['HOME'] }.merge(definitions)
368
368
 
369
- data = data.gsub /\$(\w+)/ do |constant_name|
370
- constant_name = constant_name[1..-1]
369
+ data = data.gsub /(.|^)\$(\w+)/ do |constant_name|
370
+ prefix = constant_name[0, 1]
371
+ if prefix == "\\"
372
+ next(constant_name[1..-1])
373
+ end
374
+ if prefix == "$"
375
+ prefix, constant_name = "", constant_name[1..-1]
376
+ else
377
+ constant_name = constant_name[2..-1]
378
+ end
379
+
371
380
  if !(value = definitions[constant_name])
372
381
  if !(value = Autoproj.user_config(constant_name))
373
382
  if !block_given? || !(value = yield(constant_name))
@@ -375,11 +384,15 @@ module Autoproj
375
384
  end
376
385
  end
377
386
  end
378
- value
387
+ "#{prefix}#{value}"
379
388
  end
380
389
  data
381
390
  end
382
391
 
392
+ # Expand constants within +value+
393
+ #
394
+ # The list of constants is given in +definitions+. It raises ConfigError if
395
+ # some values are not found
383
396
  def self.expand(value, definitions = Hash.new)
384
397
  if value.respond_to?(:to_hash)
385
398
  value.dup.each do |name, definition|
@@ -1,3 +1,3 @@
1
1
  module Autoproj
2
- VERSION = "1.8.2.rc3"
2
+ VERSION = "1.8.2.rc4"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__))
2
2
  require 'test/unit'
3
3
  require 'autoproj'
4
+ require 'flexmock/test_unit'
4
5
  require 'set'
5
6
 
6
7
  class TC_Manifest < Test::Unit::TestCase
@@ -34,7 +35,22 @@ class TC_Manifest < Test::Unit::TestCase
34
35
  end
35
36
  end
36
37
 
37
- def test_update_sources
38
+ def test_single_expansion_uses_provided_definitions
39
+ flexmock(Autoproj).should_receive(:user_config).never
40
+ assert_equal "a_variable=val", Autoproj.single_expansion("a_variable=$CONST", 'CONST' => 'val')
41
+ assert_equal "val", Autoproj.single_expansion("$CONST", 'CONST' => 'val')
42
+ end
43
+
44
+ def test_single_expansion_uses_user_config
45
+ flexmock(Autoproj).should_receive(:user_config).with("CONST").and_return("val")
46
+ assert_equal "a_variable=val", Autoproj.single_expansion("a_variable=$CONST", Hash.new)
47
+ assert_equal "val", Autoproj.single_expansion("$CONST", Hash.new)
48
+ end
49
+
50
+ def test_single_expansion_handle_quoted_dollar_sign
51
+ flexmock(Autoproj).should_receive(:user_config).with("CONST").and_return("val")
52
+ assert_equal "a_variable=$CONST", Autoproj.single_expansion("a_variable=\\$CONST", Hash.new)
53
+ assert_equal "$CONST", Autoproj.single_expansion("\\$CONST", Hash.new)
38
54
  end
39
55
  end
40
56
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoproj
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.2.rc3
4
+ version: 1.8.2.rc4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-18 00:00:00.000000000 Z
12
+ date: 2012-10-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: autobuild
16
- requirement: &5581420 !ruby/object:Gem::Requirement
16
+ requirement: &11665920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.6.0.rc1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *5581420
24
+ version_requirements: *11665920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: utilrb
27
- requirement: &5579600 !ruby/object:Gem::Requirement
27
+ requirement: &11664080 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.6.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *5579600
35
+ version_requirements: *11664080
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: highline
38
- requirement: &5577880 !ruby/object:Gem::Requirement
38
+ requirement: &11662380 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.5.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *5577880
46
+ version_requirements: *11662380
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &5576660 !ruby/object:Gem::Requirement
49
+ requirement: &11661100 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '3.10'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *5576660
57
+ version_requirements: *11661100
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: hoe
60
- requirement: &5574700 !ruby/object:Gem::Requirement
60
+ requirement: &11659100 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '3.1'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *5574700
68
+ version_requirements: *11659100
69
69
  description: autoproj is a manager for sets of software packages. It allows the user
70
70
  to import and build packages from source, still using the underlying distribution's
71
71
  native package manager for software that is available on it.