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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 876182cbec6fa89633e1fd3b2fdbed37b88a714a
4
- data.tar.gz: 9c342ccc39c549785c660c4b13b9ab52d17a6024
3
+ metadata.gz: 5c9d095029273d13356b6ca01b179ebb1a96e0a3
4
+ data.tar.gz: e3a485583a06cda2ed86bef8fb293cd239c96623
5
5
  SHA512:
6
- metadata.gz: c05735b52a238ba1fd28189880ee341b95f61cbebc96ac733e6411531ec197e433ba931acdf660d98958c297db0c3396c3aae4141b5b4388f1ded3f162d290ee
7
- data.tar.gz: b9a148f6097f6c42849845a8881367716629d7a97709efab0393ba95c89e01b177abbdcd1654783aeaeabe33c77eed3201c687c9a1d8de42fa23908573eb9b25
6
+ metadata.gz: e1b3d7b5dd354e1a01794275c786054182018b158d07a1fb942bdc23dd9bba1e23fb8feb74193e36d598f618530bcaec17a9ef23413813ae07e72d5b6da85148
7
+ data.tar.gz: b7e76f0b580e107aada88783fcc844c4dfb3ce30625a6dae2803702a67b081bf595b59a92ddab475c179c1180aed03e21540f74fb447e1f7525d24c2faaceac9
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2
4
+ - 2.4
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # ConfigHound
2
2
 
3
+ [![Build Status](https://travis-ci.org/mdub/config_hound.svg?branch=master)](https://travis-ci.org/mdub/config_hound)
4
+
3
5
  ConfigHound makes it easy to load configuration data.
4
6
 
5
7
  ## Usage
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
 
@@ -1,4 +1,5 @@
1
1
  require "config_hound/error"
2
+ require "dig_rb"
2
3
 
3
4
  module ConfigHound
4
5
 
@@ -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
- result = raw_hashes.reverse.reduce({}, &ConfigHound.method(:deep_merge_into))
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
@@ -1,3 +1,3 @@
1
1
  module ConfigHound
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.2"
3
3
  end
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
- Loader.new(options).load(paths)
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.0
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-13 00:00:00.000000000 Z
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