cconfig 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/lib/cconfig/cconfig.rb +3 -3
- data/lib/cconfig/hash_utils.rb +9 -7
- data/lib/cconfig/version.rb +1 -1
- data/spec/config_spec.rb +3 -2
- data/spec/hash_utils_spec.rb +10 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ea447e81e322d1bf22dddca71e18e2eab21760d
|
4
|
+
data.tar.gz: 003941dd51eebfa38fea464be15f861bcc49f28c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 841ebc1ec251e9490865f5e7f918ef38051402898e604b3b8e2c93ed42fbb2c74609a1b6f39b344d367ad779892e29440840eb218c3a11f122adcea105d98aeb
|
7
|
+
data.tar.gz: 2a18d68a5ea16c626e1d245549d67425c4fe6a0c301e6476f032f562730c3e7484e36acfb8935a5c8d4f8c90a604951013866f9d25e47a4620b3368f33af60bc
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.1.1
|
4
|
+
|
5
|
+
- Fixed crash on nested values on the `#enabled?` method. See [#3](https://github.com/mssola/cconfig/issues/3).
|
6
|
+
- The `prefix` argument from the constructor now takes a default
|
7
|
+
(`cconfig`). This will make things more predictable I hope.
|
8
|
+
|
3
9
|
## 1.1.0
|
4
10
|
|
5
11
|
- Added the `disabled?` method, which is a shorthand for `enabled?`.
|
data/Gemfile.lock
CHANGED
data/lib/cconfig/cconfig.rb
CHANGED
@@ -30,14 +30,14 @@ module CConfig
|
|
30
30
|
|
31
31
|
# Instantiate an object with `default` as the path to the default
|
32
32
|
# configuration, `local` as the alternate file, and `prefix` as the prefix
|
33
|
-
# for environment variables.
|
33
|
+
# for environment variables. The `prefix` will take "cconfig" as the default.
|
34
34
|
#
|
35
35
|
# Note: the `local` value will be discarded in favor of the
|
36
36
|
# `#{prefix}_LOCAL_CONFIG_PATH` environment variable if it was set.
|
37
37
|
def initialize(default:, local:, prefix:)
|
38
38
|
@default = default
|
39
|
-
@
|
40
|
-
@
|
39
|
+
@prefix = prefix || "cconfig"
|
40
|
+
@local = ENV["#{@prefix.upcase}_LOCAL_CONFIG_PATH"] || local
|
41
41
|
end
|
42
42
|
|
43
43
|
# Returns a hash with the app configuration contained in it.
|
data/lib/cconfig/hash_utils.rb
CHANGED
@@ -31,14 +31,16 @@ module CConfig
|
|
31
31
|
# b:
|
32
32
|
# enabled: true
|
33
33
|
def enabled?(feature)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
return false if !
|
40
|
-
|
34
|
+
cur = self
|
35
|
+
parts = feature.split(".")
|
36
|
+
|
37
|
+
parts.each do |part|
|
38
|
+
cur = cur[part]
|
39
|
+
return false if !cur || cur.empty?
|
40
|
+
return true if cur.key?("enabled") && cur["enabled"].eql?(true)
|
41
41
|
end
|
42
|
+
|
43
|
+
false
|
42
44
|
end
|
43
45
|
|
44
46
|
# Returns true if the given feature is disabled or doesn't exist. This is
|
data/lib/cconfig/version.rb
CHANGED
data/spec/config_spec.rb
CHANGED
@@ -84,9 +84,10 @@ describe CConfig::Config do
|
|
84
84
|
# the local.yml file.
|
85
85
|
base = File.join(File.dirname(__FILE__), "fixtures")
|
86
86
|
local = File.join(base, "bad.yml")
|
87
|
-
ENV["
|
87
|
+
ENV["CCONFIG_LOCAL_CONFIG_PATH"] = File.join(base, "local.yml")
|
88
88
|
|
89
|
-
|
89
|
+
# Passing nil to the prefix on purpose (see SUSE/Portus#1379)
|
90
|
+
cfg = ::CConfig::Config.new(default: "config.yml", local: local, prefix: nil)
|
90
91
|
expect { cfg.fetch }.not_to raise_error
|
91
92
|
end
|
92
93
|
end
|
data/spec/hash_utils_spec.rb
CHANGED
@@ -65,4 +65,14 @@ describe ::CConfig::HashUtils do
|
|
65
65
|
expect(cfg["ldap"]["count"]).to eq 2 # env
|
66
66
|
expect(cfg["ldap"]["string"]).to eq "string" # env
|
67
67
|
end
|
68
|
+
|
69
|
+
# See issue #3
|
70
|
+
it "does not crash on nested default that doesn't exist" do
|
71
|
+
cfg = ConfigMock.new.strict_merge_with_env_test(default: default, local: local, prefix: "test")
|
72
|
+
|
73
|
+
cfg.extend(::CConfig::HashUtils::Extensions)
|
74
|
+
expect(cfg.enabled?("gravatar")).to be_truthy
|
75
|
+
expect(cfg.enabled?("oauth.google_oauth2")).to be_falsey
|
76
|
+
expect(cfg.enabled?("something.that.does.not.exist")).to be_falsey
|
77
|
+
end
|
68
78
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cconfig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mssola
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: safe_yaml
|
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
155
|
version: '0'
|
156
156
|
requirements: []
|
157
157
|
rubyforge_project:
|
158
|
-
rubygems_version: 2.
|
158
|
+
rubygems_version: 2.4.8
|
159
159
|
signing_key:
|
160
160
|
specification_version: 4
|
161
161
|
summary: Configuration management for container-aware applications.
|