collapsium-config 0.2.0 → 0.2.1
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/collapsium-config/configuration.rb +2 -2
- data/lib/collapsium-config/version.rb +1 -1
- data/spec/configuration_spec.rb +1 -2
- data/spec/data/global.yml +2 -0
- data/spec/module_spec.rb +16 -0
- 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: 831b6eb064c405db8797886058469fb8f613c0fc
|
4
|
+
data.tar.gz: c38ef78dd89d8a009e01719aa6860c4b6d953697
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f97ddbf8c8973f5d2590d45da0ab07778295dccc7078836002d899bc41920e75b8e423440af56ec516567fabbf71f3c35b9310634f2e640d6e75f50ec87e36d2
|
7
|
+
data.tar.gz: f0181fba285ca14f6153713316683a0b218bb7709814d01d89039b07c8d74f3f308f1bc71cf5d30c456b6033b1074eba3943cacbf41f8f8416035eb556e8ad3a
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
collapsium-config (0.2.
|
4
|
+
collapsium-config (0.2.1)
|
5
5
|
collapsium (~> 0.4)
|
6
6
|
|
7
7
|
GEM
|
@@ -10,7 +10,7 @@ GEM
|
|
10
10
|
ast (2.3.0)
|
11
11
|
codeclimate-test-reporter (0.6.0)
|
12
12
|
simplecov (>= 0.7.1, < 1.0.0)
|
13
|
-
collapsium (0.4.
|
13
|
+
collapsium (0.4.1)
|
14
14
|
diff-lcs (1.2.5)
|
15
15
|
docile (1.1.5)
|
16
16
|
json (2.0.2)
|
@@ -147,7 +147,7 @@ module Collapsium
|
|
147
147
|
# Parse the contents.
|
148
148
|
config = parse(base.extname, contents, template_data)
|
149
149
|
|
150
|
-
return base,
|
150
|
+
return base, Configuration.new(hashify(config))
|
151
151
|
end
|
152
152
|
|
153
153
|
def load_local_config(base, template_data)
|
@@ -166,7 +166,7 @@ module Collapsium
|
|
166
166
|
|
167
167
|
local_config = parse(base.extname, contents, template_data)
|
168
168
|
|
169
|
-
return local,
|
169
|
+
return local, Configuration.new(hashify(local_config))
|
170
170
|
end
|
171
171
|
|
172
172
|
def hashify(data)
|
data/spec/configuration_spec.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative '../lib/collapsium-config/configuration'
|
|
4
4
|
describe Collapsium::Config::Configuration do
|
5
5
|
before do
|
6
6
|
@data_path = File.join(File.dirname(__FILE__), 'data')
|
7
|
+
ENV.delete("BAZ")
|
7
8
|
end
|
8
9
|
|
9
10
|
describe "basic file loading" do
|
@@ -81,7 +82,6 @@ describe Collapsium::Config::Configuration do
|
|
81
82
|
ENV["BAZ"] = "override"
|
82
83
|
expect(cfg["foo"]).to eql "bar"
|
83
84
|
expect(cfg["baz"]).to eql "override"
|
84
|
-
ENV.delete("BAZ")
|
85
85
|
end
|
86
86
|
|
87
87
|
it "parses JSON when overriding from the environment" do
|
@@ -92,7 +92,6 @@ describe Collapsium::Config::Configuration do
|
|
92
92
|
expect(cfg["foo"]).to eql "bar"
|
93
93
|
expect(cfg["baz"].is_a?(Hash)).to be_truthy
|
94
94
|
expect(cfg["baz.json_key"]).to eql "json_value"
|
95
|
-
ENV.delete("BAZ")
|
96
95
|
end
|
97
96
|
end
|
98
97
|
|
data/spec/data/global.yml
CHANGED
data/spec/module_spec.rb
CHANGED
@@ -6,6 +6,9 @@ include Collapsium::Config
|
|
6
6
|
describe Collapsium::Config do
|
7
7
|
before do
|
8
8
|
@data_path = File.join(File.dirname(__FILE__), 'data')
|
9
|
+
ENV.delete("SOME_PATH")
|
10
|
+
ENV.delete("SOME")
|
11
|
+
ENV.delete("PATH")
|
9
12
|
end
|
10
13
|
|
11
14
|
it "fails to load configuration from the default path (it does not exist)" do
|
@@ -39,5 +42,18 @@ describe Collapsium::Config do
|
|
39
42
|
|
40
43
|
expect(cfg1.object_id).to eql cfg2.object_id
|
41
44
|
end
|
45
|
+
|
46
|
+
it "returns a config hash capable of environment overrides" do
|
47
|
+
Collapsium::Config.config_file = File.join(@data_path, 'global.yml')
|
48
|
+
|
49
|
+
# Pre environment manipulation
|
50
|
+
expect(config["some.path"]).to eql 123
|
51
|
+
|
52
|
+
# With environment manipulation
|
53
|
+
ENV["SOME_PATH"] = "override"
|
54
|
+
|
55
|
+
expect(config["some.path"]).to eql "override"
|
56
|
+
expect(config["some"]["path"]).to eql "override"
|
57
|
+
end
|
42
58
|
end
|
43
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collapsium-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Finkhaeuser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|