config_hound 1.4.3 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/test.yaml +20 -0
- data/README.md +2 -2
- data/config_hound.gemspec +4 -2
- data/lib/config_hound/interpolation.rb +1 -1
- data/lib/config_hound/parser.rb +1 -1
- data/lib/config_hound/resource.rb +2 -2
- data/lib/config_hound/version.rb +1 -1
- data/spec/features/expansion_spec.rb +32 -0
- data/spec/features/formats_spec.rb +12 -0
- data/spec/spec_helper.rb +5 -1
- metadata +13 -14
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 33f4e286668dbf7171c50d313cd9339cbb1ccbdc34d9b68c1e732c7a84d0acb9
|
4
|
+
data.tar.gz: 007b751b55b1b1463db129e754572e966f937a890636a16d3506d3b9ca2801b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdaa8f5cd09e6a5aee6c35b5a9116e2f7f28b7553472c1b10ece292028d5553ffdfeda9c4358a79729589c33f565b58a4439c42f431cd1a7e9ad0878bba376e4
|
7
|
+
data.tar.gz: b084ffc0661eaf04af3ff1c22bc762158e660a5a0ab0658d9b71b89b1700cb402515c5a2ea01520b2b8d61e0cbe682e5425939e5499e45b5cf0736b600fec0f1
|
@@ -0,0 +1,20 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby: ['2.7', '3.0', '3.1']
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v3
|
15
|
+
- uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
bundler-cache: true
|
18
|
+
ruby-version: ${{ matrix.ruby }}
|
19
|
+
- run: bundle install
|
20
|
+
- run: bundle exec rake
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# ConfigHound
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/config_hound.
|
4
|
-
[![Build Status](https://
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/config_hound.svg)](http://badge.fury.io/rb/config_hound)
|
4
|
+
[![Build Status](https://github.com/mdub/config_hound/actions/workflows/test.yaml/badge.svg?branch=master)](https://github.com/mdub/config_hound/actions/workflows/test.yaml)
|
5
5
|
|
6
6
|
ConfigHound makes it easy to load configuration data.
|
7
7
|
|
data/config_hound.gemspec
CHANGED
@@ -19,9 +19,11 @@ 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.required_ruby_version = '>= 2.7'
|
23
|
+
|
22
24
|
spec.add_runtime_dependency "dig_rb"
|
23
25
|
|
24
|
-
spec.add_development_dependency "bundler", "~>
|
25
|
-
spec.add_development_dependency "rake", "~>
|
26
|
+
spec.add_development_dependency "bundler", "~> 2.2"
|
27
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
26
28
|
|
27
29
|
end
|
data/lib/config_hound/parser.rb
CHANGED
@@ -48,7 +48,7 @@ module ConfigHound
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def read
|
51
|
-
open(uri.scheme == "file" ? uri.path : uri.to_s) do |io|
|
51
|
+
URI.open(uri.scheme == "file" ? uri.path : uri.to_s) do |io|
|
52
52
|
io.read
|
53
53
|
end
|
54
54
|
rescue Errno::ENOENT
|
@@ -56,7 +56,7 @@ module ConfigHound
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def format
|
59
|
-
File.extname(uri.to_s)[1..-1]
|
59
|
+
File.extname(uri.path.to_s)[1..-1]
|
60
60
|
end
|
61
61
|
|
62
62
|
def load
|
data/lib/config_hound/version.rb
CHANGED
@@ -16,6 +16,38 @@ describe ConfigHound, "expansion" do
|
|
16
16
|
expect(config["address"]).to eq("host:5678")
|
17
17
|
end
|
18
18
|
|
19
|
+
context "with key expansion" do
|
20
|
+
|
21
|
+
given_resource "config-with-key-expansion.yml", %{
|
22
|
+
var:
|
23
|
+
account_id: "123"
|
24
|
+
<(var.account_id)>: value
|
25
|
+
}
|
26
|
+
|
27
|
+
let(:config) { ConfigHound.load("config-with-key-expansion.yml", :expand_refs => true) }
|
28
|
+
|
29
|
+
it "expands key references" do
|
30
|
+
expect(config["123"]).to eq("value")
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
context "with key and value expansion" do
|
36
|
+
|
37
|
+
given_resource "config-with-key-and-value-expansion.yml", %{
|
38
|
+
var:
|
39
|
+
account_id: "123"
|
40
|
+
port: 5678
|
41
|
+
<(var.account_id)>: host:<(var.port)>
|
42
|
+
}
|
43
|
+
let(:config) { ConfigHound.load("config-with-key-and-value-expansion.yml", :expand_refs => true) }
|
44
|
+
|
45
|
+
it "expands key references" do
|
46
|
+
expect(config["123"]).to eq("host:5678")
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
19
51
|
context "with overrides" do
|
20
52
|
|
21
53
|
given_resource "overrides.yml", %{
|
@@ -20,6 +20,18 @@ describe ConfigHound, "formats" do
|
|
20
20
|
)
|
21
21
|
end
|
22
22
|
|
23
|
+
given_resource "s3://s3-test-bucket/config.yml?versionId=123456", %{
|
24
|
+
foo: 1
|
25
|
+
bar: 2
|
26
|
+
}
|
27
|
+
|
28
|
+
it "loads YAML from s3 with version id" do
|
29
|
+
expect(load("s3://s3-test-bucket/config.yml?versionId=123456")).to eq(
|
30
|
+
"foo" => 1,
|
31
|
+
"bar" => 2
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
23
35
|
given_resource "config-with-aliases.yml", %{
|
24
36
|
foo: &foo
|
25
37
|
bar: 1
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require "open-uri"
|
2
|
+
require "uri"
|
3
|
+
|
1
4
|
module GivenResource
|
2
5
|
|
3
6
|
def inputs
|
@@ -10,7 +13,7 @@ module GivenResource
|
|
10
13
|
end
|
11
14
|
content = undent(content)
|
12
15
|
before do
|
13
|
-
|
16
|
+
allow(URI).to receive(:open).with(path) do |_, _, &block|
|
14
17
|
block.call(StringIO.new(content.dup))
|
15
18
|
end
|
16
19
|
end
|
@@ -31,6 +34,7 @@ module GivenResource
|
|
31
34
|
end
|
32
35
|
|
33
36
|
RSpec.configure do |config|
|
37
|
+
config.warnings = true
|
34
38
|
|
35
39
|
config.extend(GivenResource)
|
36
40
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: config_hound
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Williams
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dig_rb
|
@@ -30,38 +30,38 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.2'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
description:
|
54
|
+
version: '13.0'
|
55
|
+
description:
|
56
56
|
email:
|
57
57
|
- mdub@dogbiscuit.org
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- ".github/workflows/test.yaml"
|
62
63
|
- ".gitignore"
|
63
64
|
- ".rspec"
|
64
|
-
- ".travis.yml"
|
65
65
|
- Gemfile
|
66
66
|
- LICENSE.txt
|
67
67
|
- README.md
|
@@ -87,7 +87,7 @@ homepage: https://github.com/mdub/config_hound
|
|
87
87
|
licenses:
|
88
88
|
- MIT
|
89
89
|
metadata: {}
|
90
|
-
post_install_message:
|
90
|
+
post_install_message:
|
91
91
|
rdoc_options: []
|
92
92
|
require_paths:
|
93
93
|
- lib
|
@@ -95,16 +95,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
95
|
requirements:
|
96
96
|
- - ">="
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version: '
|
98
|
+
version: '2.7'
|
99
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
|
-
|
106
|
-
|
107
|
-
signing_key:
|
105
|
+
rubygems_version: 3.3.7
|
106
|
+
signing_key:
|
108
107
|
specification_version: 4
|
109
108
|
summary: Sniffs out config, wherever it may be.
|
110
109
|
test_files:
|