hierarchical_config 0.9 → 0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/hierarchical_config/version.rb +1 -1
- data/lib/hierarchical_config.rb +14 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c30b204410cfb69963e7b0dabe5d32d8f4aed32e
|
4
|
+
data.tar.gz: a66d608b7f290a908b2f747dec58ae95477f69df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a21680799fa258505d9fff32d86f56f01ccf6c8e246229fc104c8c5703826702518e687796a2cf0e11ca4e4bbc69ba6cfa79befce47c891c78bd887b0e0f44a
|
7
|
+
data.tar.gz: d7bda2e2985a863e1a78a2ab6e7211678803df08ffe881d74ea9e7c3f855fbb9aed742eab4b8bc80c322a2492967098b1f650651c39cbca600d37a82899c0bfa
|
data/Gemfile.lock
CHANGED
data/lib/hierarchical_config.rb
CHANGED
@@ -59,14 +59,14 @@ module HierarchicalConfig
|
|
59
59
|
end
|
60
60
|
|
61
61
|
class << self
|
62
|
-
def load_config( name, dir, environment )
|
62
|
+
def load_config( name, dir, environment, preprocess_with=:erb )
|
63
63
|
primary_config_file = "#{dir}/#{name}.yml"
|
64
64
|
overrides_config_file = "#{dir}/#{name}-overrides.yml"
|
65
65
|
|
66
|
-
config_hash = load_hash_for_env( primary_config_file, environment )
|
66
|
+
config_hash = load_hash_for_env( primary_config_file, environment, preprocess_with )
|
67
67
|
|
68
68
|
if File.exists?( overrides_config_file )
|
69
|
-
overrides_config_hash = load_hash_for_env( overrides_config_file, environment )
|
69
|
+
overrides_config_hash = load_hash_for_env( overrides_config_file, environment, preprocess_with )
|
70
70
|
config_hash = deep_merge( config_hash, overrides_config_hash )
|
71
71
|
end
|
72
72
|
|
@@ -77,8 +77,17 @@ module HierarchicalConfig
|
|
77
77
|
config_hash
|
78
78
|
end
|
79
79
|
|
80
|
-
def load_hash_for_env( file, environment )
|
81
|
-
|
80
|
+
def load_hash_for_env( file, environment, preprocess_with )
|
81
|
+
file_contents = IO.read(file)
|
82
|
+
yaml_contents = case preprocess_with
|
83
|
+
when :erb
|
84
|
+
ERB.new(file_contents).result
|
85
|
+
when nil
|
86
|
+
file_contents
|
87
|
+
else
|
88
|
+
raise "Unknown preprocessor <#{preprocess_with}>"
|
89
|
+
end
|
90
|
+
yaml_config = YAML::load(yaml_contents)
|
82
91
|
|
83
92
|
ordered_stanza_labels = []
|
84
93
|
ordered_stanza_labels << 'defaults' if yaml_config.key? 'defaults'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hierarchical_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.10'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- timgaleckas
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-12-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|