puppet_fixtures 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/puppet_fixtures.rb +21 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51def025c96199c880126b67e000d17adaf4983209cd2fd34020c094e00877a0
4
- data.tar.gz: cf4b77f4291d6b2a9aec9243d08a8732b6e7e4b7f27bba86b468f771da387ce9
3
+ metadata.gz: 8d24577830ba1301365cd8feb34ffa656ab740cb068ba8e9057f1fe096b245b2
4
+ data.tar.gz: e07d6945cc6c4b10d666d87a84a03497885f206237c07ad71bfaa4e4a08118fa
5
5
  SHA512:
6
- metadata.gz: 6f2112523ec0c5602bd961c4c0a117b7d776344068dad25a4d3dc1925851a9edb73e722c8a37597e938cea486487c693eeb08de24736f54dcf5423903da97bd1
7
- data.tar.gz: 87dd05abaed4fada6bcb5fa0523d850ed901855ffd269751d08d5b9d5f1b81fab5676d033a71cdf2b303522e2204e667b55a94369cd1c46e25eaf7e7b176fa1a
6
+ metadata.gz: ce3079f6bcbbbb0909f574817c583b4f487182f80492c09964258f85265031cdd7c4ffc7e448b90587a4b65d4591b253582ea705f8d70b536e95a2038eb89c3a
7
+ data.tar.gz: fffe903a66bb74a44c7f05033b9caa408e33439520f17c9d83cc3d7cd1c967efb54214e14e3c3321a1622d82877f3759b8bfd4893453a9ab04ca6bab6300badd
@@ -17,6 +17,24 @@ module PuppetFixtures
17
17
  !!File::ALT_SEPARATOR
18
18
  end
19
19
 
20
+ # @param value [Object]
21
+ # The value to expand environment variables in
22
+ # @return [Object]
23
+ # The value with environment variables expanded
24
+ # @api private
25
+ def self.deep_expand_env(value)
26
+ case value
27
+ when String
28
+ value.gsub(/\$\{([^}]+)\}/) { ENV.fetch(Regexp.last_match(1)) { Regexp.last_match(0) } }
29
+ when Hash
30
+ value.transform_values { |v| deep_expand_env(v) }
31
+ when Array
32
+ value.map { |v| deep_expand_env(v) }
33
+ else
34
+ value
35
+ end
36
+ end
37
+
20
38
  class Fixtures
21
39
  attr_reader :source_dir
22
40
 
@@ -308,13 +326,15 @@ module PuppetFixtures
308
326
  fixtures = nil
309
327
  if fixtures_yaml
310
328
  begin
311
- fixtures = YAML.load_file(fixtures_yaml)
329
+ raw = YAML.load_file(fixtures_yaml)
330
+ fixtures = PuppetFixtures.deep_expand_env(raw)
312
331
  rescue Errno::ENOENT
313
332
  raise "Fixtures file not found: '#{fixtures_yaml}'"
314
333
  rescue Psych::SyntaxError => e
315
334
  raise "Found malformed YAML in '#{fixtures_yaml}' on line #{e.line} column #{e.column}: #{e.problem}"
316
335
  end
317
336
  end
337
+
318
338
  fixtures ||= { 'fixtures' => {} }
319
339
 
320
340
  unless fixtures.include?('fixtures')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet_fixtures
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ewoud Kohl van Wijngaarden