cconfig 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ gravatar:
2
+ enabled: true
3
+
4
+ ldap:
5
+ enabled: false
6
+ hostname: "ldap_hostname"
7
+ port: 389
8
+ base: ""
9
+ authentication:
10
+ enabled: false
11
+ bind_dn: ""
12
+ password: "mypassword"
13
+
14
+ email:
15
+ smtp:
16
+ enabled: true
@@ -0,0 +1,7 @@
1
+ ldap:
2
+ enabled: true
3
+ hostname: "ldap.example.com"
4
+ port: 389
5
+ base: "ou=users,dc=example,dc=com"
6
+ unknown:
7
+ enabled: true
@@ -0,0 +1,68 @@
1
+ # coding: utf-8
2
+
3
+ # Copyright (C) 2017 Miquel Sabaté Solà <msabate@suse.com>
4
+ #
5
+ # This file is part of CConfig.
6
+ #
7
+ # CConfig is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # CConfig is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with CConfig. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ class ConfigMock
21
+ include ::CConfig::HashUtils
22
+
23
+ def strict_merge_with_env_test(default:, local:, prefix:)
24
+ strict_merge_with_env(default: default, local: local, prefix: prefix)
25
+ end
26
+ end
27
+
28
+ describe ::CConfig::HashUtils do
29
+ after do
30
+ ["TEST_LDAP_COUNT", "TEST_ANOTHER_ENABLED", "TEST_LDAP_STRING"].each do |key|
31
+ ENV[key] = nil
32
+ end
33
+ end
34
+
35
+ let(:default) do
36
+ {
37
+ "gravatar" => { "enabled" => true },
38
+ "another" => { "enabled" => true },
39
+ "ldap" => {
40
+ "enabled" => false,
41
+ "count" => 0,
42
+ "string" => ""
43
+ }
44
+ }.freeze
45
+ end
46
+
47
+ let(:local) do
48
+ {
49
+ "ldap" => {
50
+ "enabled" => true,
51
+ "count" => 1
52
+ }
53
+ }.freeze
54
+ end
55
+
56
+ it "merges hashes in a strict manner while evaluating env variables first" do
57
+ ENV["TEST_LDAP_COUNT"] = "2"
58
+ ENV["TEST_ANOTHER_ENABLED"] = "false"
59
+ ENV["TEST_LDAP_STRING"] = "string"
60
+
61
+ cfg = ConfigMock.new.strict_merge_with_env_test(default: default, local: local, prefix: "test")
62
+ expect(cfg["gravatar"]["enabled"]).to be true # default
63
+ expect(cfg["another"]["enabled"]).to be false # env
64
+ expect(cfg["ldap"]["enabled"]).to be true # local
65
+ expect(cfg["ldap"]["count"]).to eq 2 # env
66
+ expect(cfg["ldap"]["string"]).to eq "string" # env
67
+ end
68
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+
3
+ # Copyright (C) 2017 Miquel Sabaté Solà <msabate@suse.com>
4
+ #
5
+ # This file is part of CConfig.
6
+ #
7
+ # CConfig is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # CConfig is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with CConfig. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ require "codeclimate-test-reporter"
21
+ CodeClimate::TestReporter.start
22
+
23
+ require "simplecov"
24
+
25
+ SimpleCov.minimum_coverage 100
26
+ SimpleCov.start do
27
+ add_group "lib", "lib"
28
+ end
29
+
30
+ RSpec.configure do |config|
31
+ config.order = :random
32
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cconfig
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - mssola
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-08-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: safe_yaml
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.0
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 1.0.0
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.0.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '3.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rubocop
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 0.49.1
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 0.49.1
89
+ - !ruby/object:Gem::Dependency
90
+ name: rubocop-rspec
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ description: Configuration management for container-aware applications
104
+ email:
105
+ - mssola@suse.com
106
+ executables: []
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - ".gitignore"
111
+ - ".rspec"
112
+ - ".rubocop.yml"
113
+ - ".ruby-version"
114
+ - ".travis.yml"
115
+ - CHANGELOG.md
116
+ - CONTRIBUTING.md
117
+ - COPYING
118
+ - COPYING.LESSER
119
+ - Gemfile
120
+ - Gemfile.lock
121
+ - README.md
122
+ - Rakefile
123
+ - cconfig.gemspec
124
+ - config/rubocop-suse.yml
125
+ - lib/cconfig.rb
126
+ - lib/cconfig/cconfig.rb
127
+ - lib/cconfig/errors.rb
128
+ - lib/cconfig/hash_utils.rb
129
+ - lib/cconfig/railtie.rb
130
+ - lib/cconfig/version.rb
131
+ - lib/tasks/info.rake
132
+ - spec/config_spec.rb
133
+ - spec/fixtures/bad.yml
134
+ - spec/fixtures/config.yml
135
+ - spec/fixtures/local.yml
136
+ - spec/hash_utils_spec.rb
137
+ - spec/spec_helper.rb
138
+ homepage: https://github.com/mssola/cconfig
139
+ licenses:
140
+ - LGPL-3.0
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '2.1'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.6.12
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: Configuration management for container-aware applications.
162
+ test_files: []