yaml_configuration 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,13 @@
1
1
  module YamlConfiguration
2
2
  class Configuration
3
+ attr_reader :placeholders_preprocessor
4
+
3
5
  def initialize(hash_configuration, parent=nil, name=nil)
4
6
  @config = hash_configuration
5
7
  @name = name
6
8
  @parent = parent
7
- @placeholders_preprocessor = PlaceholdersPreprocessor.new(self)
9
+ parent_preprocessor = @parent.placeholders_preprocessor unless @parent.nil?
10
+ @placeholders_preprocessor = parent_preprocessor || PlaceholdersPreprocessor.new(self)
8
11
  end
9
12
 
10
13
  def full_name(setting_name)
@@ -8,7 +8,12 @@ module YamlConfiguration
8
8
  if value.respond_to?(:each)
9
9
  value.map {|v| self.parse(v)}
10
10
  else
11
- value.gsub(/\${([^}]*)}/) { @configuration.instance_eval($1) }
11
+ begin
12
+ value.to_s.gsub(/\${([^}]*)}/) { @configuration.instance_eval($1) }
13
+ rescue Exception => ex
14
+ puts @configuration.inspect
15
+ raise ex
16
+ end
12
17
  end
13
18
  end
14
19
  end
@@ -1,3 +1,3 @@
1
1
  module YamlConfiguration
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
@@ -39,11 +39,11 @@ module YamlConfiguration
39
39
  end
40
40
 
41
41
  def test_that_placeholder_get_replaced_correctly
42
- configuration = Configuration.new({'host' => 'localhost', 'port' => '23',
43
- 'base_url' => '${host}:${port}/${database.name}',
44
- 'database' => { 'name' => 'mysql'}})
42
+ configuration = Configuration.new({'host' => 'localhost', 'port' => 23,
43
+ 'database' => { 'name' => 'mysql',
44
+ 'base_url' => '${host}:${port}/${database.name}'}})
45
45
 
46
- assert_equal 'localhost:23/mysql', configuration.base_url
46
+ assert_equal 'localhost:23/mysql', configuration.database.base_url
47
47
  end
48
48
 
49
49
  def test_that_placeholders_get_replaced_correctly_in_arrays
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaml_configuration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-12-08 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &83297040 !ruby/object:Gem::Requirement
16
+ requirement: &74992270 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *83297040
24
+ version_requirements: *74992270
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: turn
27
- requirement: &83296760 !ruby/object:Gem::Requirement
27
+ requirement: &74991990 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *83296760
35
+ version_requirements: *74991990
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ansi
38
- requirement: &83296330 !ruby/object:Gem::Requirement
38
+ requirement: &74991560 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *83296330
46
+ version_requirements: *74991560
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: hash-deep-merge
49
- requirement: &83295850 !ruby/object:Gem::Requirement
49
+ requirement: &74990870 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *83295850
57
+ version_requirements: *74990870
58
58
  description: Load, merge and provide sensible error messages when using yaml based
59
59
  configuration
60
60
  email: