hiera-router 0.2.3 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f008fd079d6bf63f1a897eb53b1d42338152aa6b
4
- data.tar.gz: adcbbf85adce23472dc99cfcf36689711a9f26a9
3
+ metadata.gz: c260f8ab76b316611f8cfc8dd504abd1cc551ef8
4
+ data.tar.gz: 6243a808c495352baa3ac4fd0df35ddd565b299b
5
5
  SHA512:
6
- metadata.gz: 7674d2308f350a7a1defddca3acf39025f1faf745dc9a9a18088366e815d25b091016ec20323b7dff84921bceee47f5a9870689e4472c40f548b5ecd4ba5a973
7
- data.tar.gz: 4e208e39b5841e419d394ad4df518829a3db737844bd5cca2d878c6445fe1213ebbf04470057601a9eadf79a74a91c01b6703885141bf4fd3314c451ff3d88e9
6
+ metadata.gz: eaa8cf281a46d1eae42d209a6d7ed52a3f7b94100de324435a6e79f27ea601ce3f0515ead9422aec405e90cd9629f47ec851bc344f6be0168d017bfb4a9b0b63
7
+ data.tar.gz: a2ae9d18a0f10b8f0b2094cc82494737f34514eb5b7d89af2f1c5b3765cd960d5979e46953629456830bfccfcfc0ff9c602dc4fb1f068415e9ff940de4e25469
@@ -67,29 +67,30 @@ class Hiera
67
67
  return answer
68
68
  end
69
69
 
70
- def hash_key(hash, path)
71
- puts hash.inspect
72
- puts path.join('>')
73
- my_hash = hash
70
+ def recursive_key_from_hash(hash, path)
71
+ focus = hash
74
72
  path.each do |key|
75
- my_hash = my_hash[key] if my_hash.include?(key)
73
+ if focus.is_a?(Hash) and focus.include?(key)
74
+ focus = focus[key]
75
+ else
76
+ return nil
77
+ end
76
78
  end
77
79
 
78
- puts "result: #{my_hash}"
79
- return my_hash
80
+ return focus
80
81
  end
81
82
 
82
83
  def parse_answer(data, scope, options, path = [])
83
84
  if data.is_a?(Numeric) or data.is_a?(TrueClass) or data.is_a?(FalseClass)
84
85
  return data
85
86
  elsif data.is_a?(String)
86
- return parse_string(data, scope, options)
87
+ return parse_string(data, scope, options, path)
87
88
  elsif data.is_a?(Hash)
88
89
  answer = {}
89
90
  data.each_pair do |key, val|
90
91
  interpolated_key = Backend.parse_string(key, scope)
91
92
  subpath = path + [interpolated_key]
92
- answer[interpolated_key] = hash_key(parse_answer(val, scope, options, subpath), subpath)
93
+ answer[interpolated_key] = parse_answer(val, scope, options, subpath)
93
94
  end
94
95
 
95
96
  return answer
@@ -103,7 +104,7 @@ class Hiera
103
104
  end
104
105
  end
105
106
 
106
- def parse_string(data, scope, options)
107
+ def parse_string(data, scope, options, path = [])
107
108
  if match = data.match(/^backend\[([^,]+)(?:,(.*))?\]$/)
108
109
  backend_name, backend_parameters = match.captures
109
110
  backend_options = options
@@ -116,7 +117,7 @@ class Hiera
116
117
  result = data
117
118
  end
118
119
  Hiera.debug("[hiera-router] Call to '#{backend_name}' finished.")
119
- return result
120
+ return recursive_key_from_hash(result, path)
120
121
  else
121
122
  Backend.parse_string(data, scope)
122
123
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiera-router
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jo Vandeginste