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.
- checksums.yaml +4 -4
- data/lib/puppet_fixtures.rb +21 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8d24577830ba1301365cd8feb34ffa656ab740cb068ba8e9057f1fe096b245b2
|
|
4
|
+
data.tar.gz: e07d6945cc6c4b10d666d87a84a03497885f206237c07ad71bfaa4e4a08118fa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ce3079f6bcbbbb0909f574817c583b4f487182f80492c09964258f85265031cdd7c4ffc7e448b90587a4b65d4591b253582ea705f8d70b536e95a2038eb89c3a
|
|
7
|
+
data.tar.gz: fffe903a66bb74a44c7f05033b9caa408e33439520f17c9d83cc3d7cd1c967efb54214e14e3c3321a1622d82877f3759b8bfd4893453a9ab04ca6bab6300badd
|
data/lib/puppet_fixtures.rb
CHANGED
|
@@ -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
|
-
|
|
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')
|