config_hound 1.3.0 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/README.md +2 -0
- data/config_hound.gemspec +2 -0
- data/lib/config_hound/interpolation.rb +1 -0
- data/lib/config_hound/loader.rb +1 -5
- data/lib/config_hound/version.rb +1 -1
- data/lib/config_hound.rb +6 -1
- data/spec/features/expansion_spec.rb +19 -2
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c9d095029273d13356b6ca01b179ebb1a96e0a3
|
4
|
+
data.tar.gz: e3a485583a06cda2ed86bef8fb293cd239c96623
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1b3d7b5dd354e1a01794275c786054182018b158d07a1fb942bdc23dd9bba1e23fb8feb74193e36d598f618530bcaec17a9ef23413813ae07e72d5b6da85148
|
7
|
+
data.tar.gz: b7e76f0b580e107aada88783fcc844c4dfb3ce30625a6dae2803702a67b081bf595b59a92ddab475c179c1180aed03e21540f74fb447e1f7525d24c2faaceac9
|
data/.travis.yml
ADDED
data/README.md
CHANGED
data/config_hound.gemspec
CHANGED
@@ -19,6 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^spec/})
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
+
spec.add_runtime_dependency "dig_rb"
|
23
|
+
|
22
24
|
spec.add_development_dependency "bundler", "~> 1.7"
|
23
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
26
|
|
data/lib/config_hound/loader.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "config_hound/deep_merge"
|
2
|
-
require "config_hound/interpolation"
|
3
2
|
require "config_hound/resource"
|
4
3
|
|
5
4
|
module ConfigHound
|
@@ -9,7 +8,6 @@ module ConfigHound
|
|
9
8
|
DEFAULT_INCLUDE_KEY = "_include"
|
10
9
|
|
11
10
|
attr_accessor :include_key
|
12
|
-
attr_accessor :expand_refs
|
13
11
|
|
14
12
|
def initialize(options = {})
|
15
13
|
@include_key = DEFAULT_INCLUDE_KEY
|
@@ -20,9 +18,7 @@ module ConfigHound
|
|
20
18
|
|
21
19
|
def load(sources)
|
22
20
|
raw_hashes = Array(sources).map(&method(:load_source))
|
23
|
-
|
24
|
-
result = Interpolation.expand(result) if expand_refs
|
25
|
-
result
|
21
|
+
raw_hashes.reverse.reduce({}, &ConfigHound.method(:deep_merge_into))
|
26
22
|
end
|
27
23
|
|
28
24
|
private
|
data/lib/config_hound/version.rb
CHANGED
data/lib/config_hound.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
|
+
require "config_hound/interpolation"
|
1
2
|
require "config_hound/loader"
|
2
3
|
require "config_hound/version"
|
3
4
|
|
4
5
|
module ConfigHound
|
5
6
|
|
6
7
|
def self.load(paths, options = {})
|
7
|
-
|
8
|
+
options = Hash[options]
|
9
|
+
expand_refs = options.delete(:expand_refs)
|
10
|
+
result = Loader.new(options).load(paths)
|
11
|
+
result = Interpolation.expand(result) if expand_refs
|
12
|
+
result
|
8
13
|
end
|
9
14
|
|
10
15
|
end
|
@@ -4,16 +4,33 @@ require "config_hound"
|
|
4
4
|
|
5
5
|
describe ConfigHound, "expansion" do
|
6
6
|
|
7
|
-
let(:config) { ConfigHound.load("config.yml", :expand_refs => true) }
|
8
|
-
|
9
7
|
given_resource "config.yml", %{
|
10
8
|
var:
|
11
9
|
port: 5678
|
12
10
|
address: host:<(var.port)>
|
13
11
|
}
|
14
12
|
|
13
|
+
let(:config) { ConfigHound.load("config.yml", :expand_refs => true) }
|
14
|
+
|
15
15
|
it "expands references" do
|
16
16
|
expect(config["address"]).to eq("host:5678")
|
17
17
|
end
|
18
18
|
|
19
|
+
context "with overrides" do
|
20
|
+
|
21
|
+
given_resource "overrides.yml", %{
|
22
|
+
_include:
|
23
|
+
- config.yml
|
24
|
+
var:
|
25
|
+
port: 9999
|
26
|
+
}
|
27
|
+
|
28
|
+
let(:config) { ConfigHound.load("overrides.yml", :expand_refs => true) }
|
29
|
+
|
30
|
+
it "merges before expanding" do
|
31
|
+
expect(config["address"]).to eq("host:9999")
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
19
36
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: config_hound
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dig_rb
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -47,6 +61,7 @@ extra_rdoc_files: []
|
|
47
61
|
files:
|
48
62
|
- ".gitignore"
|
49
63
|
- ".rspec"
|
64
|
+
- ".travis.yml"
|
50
65
|
- Gemfile
|
51
66
|
- LICENSE.txt
|
52
67
|
- README.md
|