complex_config 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/COPYING +202 -0
- data/Gemfile +1 -0
- data/README.md +3 -0
- data/Rakefile +0 -1
- data/VERSION +1 -1
- data/complex_config.gemspec +6 -9
- data/lib/complex_config/provider.rb +2 -2
- data/lib/complex_config/settings.rb +19 -15
- data/lib/complex_config/version.rb +1 -1
- data/spec/complex_config/settings_spec.rb +21 -4
- data/spec/spec_helper.rb +4 -1
- metadata +45 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b175641fd384e29ffa459e658396e2072515c54
|
4
|
+
data.tar.gz: ffb159b7ccdd67e5efab55439bde4cc0f965ea31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ac3edb1965508240e00e2f1388f6de495dbad3a5b9a9d75f1e61c184c47a378076cd8f869ec40eba7498d651f64a3b052ad38c03b62ead39ed06063cd07867e
|
7
|
+
data.tar.gz: 9b9302e80fb991a37f81e51c0b3a6b440ab0c72eccf047248aa6570b6a62da5f4d1aa9aee563b4cb2dd7a11783d4919568f067f7f1cb9d5f477e93f8136c243b
|
data/.travis.yml
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
rvm:
|
2
|
-
- 2.0
|
2
|
+
- 2.0
|
3
3
|
- 2.1
|
4
|
+
- 2.2
|
4
5
|
- ruby-head
|
5
|
-
- jruby
|
6
|
+
- jruby
|
6
7
|
matrix:
|
7
8
|
allow_failures:
|
8
9
|
- rvm: ruby-head
|
9
|
-
- rvm: jruby-head
|
10
10
|
env:
|
11
11
|
- RAILS_ENV=development CODECLIMATE_REPO_TOKEN=b2d573b4ad139331f307e536679084a8ec269d721e31b0afe81c503a7ab0c683
|
data/COPYING
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright [2014-2015] [Florian Frank]
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -114,6 +114,9 @@ Here is the `ComplexConfig::Plugins::MONEY` plugin for example:
|
|
114
114
|
|
115
115
|
## Changes
|
116
116
|
|
117
|
+
* 2015-01-27 Release 0.2.0
|
118
|
+
* Fix for attributes named like Enumerable methods
|
119
|
+
* Make tests run on JRuby
|
117
120
|
* 2015-01-01 Release 0.1.1
|
118
121
|
* Some small fixes for handling of arrays
|
119
122
|
* 2014-12-15 Release 0.1.0
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/complex_config.gemspec
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: complex_config 0.
|
2
|
+
# stub: complex_config 0.2.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "complex_config"
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.2.0"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
|
-
s.require_paths = ["lib"]
|
10
9
|
s.authors = ["Florian Frank"]
|
11
|
-
s.date = "2015-01-
|
10
|
+
s.date = "2015-01-27"
|
12
11
|
s.description = "This library allows you to access configuration files via a simple interface"
|
13
12
|
s.email = "flori@ping.de"
|
14
13
|
s.extra_rdoc_files = ["README.md", "lib/complex_config.rb", "lib/complex_config/errors.rb", "lib/complex_config/plugins.rb", "lib/complex_config/plugins/enable.rb", "lib/complex_config/plugins/money.rb", "lib/complex_config/plugins/uri.rb", "lib/complex_config/provider.rb", "lib/complex_config/rude.rb", "lib/complex_config/settings.rb", "lib/complex_config/shortcuts.rb", "lib/complex_config/version.rb"]
|
15
|
-
s.files = [".gitignore", ".rspec", ".travis.yml", ".utilsrc", "Gemfile", "README.md", "Rakefile", "TODO.md", "VERSION", "complex_config.gemspec", "lib/complex_config.rb", "lib/complex_config/errors.rb", "lib/complex_config/plugins.rb", "lib/complex_config/plugins/enable.rb", "lib/complex_config/plugins/money.rb", "lib/complex_config/plugins/uri.rb", "lib/complex_config/provider.rb", "lib/complex_config/rude.rb", "lib/complex_config/settings.rb", "lib/complex_config/shortcuts.rb", "lib/complex_config/version.rb", "spec/complex_config/plugins_spec.rb", "spec/complex_config/provider_spec.rb", "spec/complex_config/settings_spec.rb", "spec/complex_config/shortcuts_spec.rb", "spec/config/broken_config.yml", "spec/config/config.yml", "spec/spec_helper.rb"]
|
14
|
+
s.files = [".gitignore", ".rspec", ".travis.yml", ".utilsrc", "COPYING", "Gemfile", "README.md", "Rakefile", "TODO.md", "VERSION", "complex_config.gemspec", "lib/complex_config.rb", "lib/complex_config/errors.rb", "lib/complex_config/plugins.rb", "lib/complex_config/plugins/enable.rb", "lib/complex_config/plugins/money.rb", "lib/complex_config/plugins/uri.rb", "lib/complex_config/provider.rb", "lib/complex_config/rude.rb", "lib/complex_config/settings.rb", "lib/complex_config/shortcuts.rb", "lib/complex_config/version.rb", "spec/complex_config/plugins_spec.rb", "spec/complex_config/provider_spec.rb", "spec/complex_config/settings_spec.rb", "spec/complex_config/shortcuts_spec.rb", "spec/config/broken_config.yml", "spec/config/config.yml", "spec/spec_helper.rb"]
|
16
15
|
s.homepage = "https://github.com/flori/complex_config"
|
17
16
|
s.licenses = ["Apache-2.0"]
|
18
17
|
s.rdoc_options = ["--title", "ComplexConfig -- configuration library", "--main", "README.md"]
|
19
|
-
s.
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
s.rubygems_version = "2.1.9"
|
20
20
|
s.summary = "configuration library"
|
21
21
|
s.test_files = ["spec/complex_config/plugins_spec.rb", "spec/complex_config/provider_spec.rb", "spec/complex_config/settings_spec.rb", "spec/complex_config/shortcuts_spec.rb", "spec/spec_helper.rb"]
|
22
22
|
|
@@ -28,7 +28,6 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_development_dependency(%q<rake>, [">= 0"])
|
29
29
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
30
30
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
31
|
-
s.add_development_dependency(%q<byebug>, [">= 0"])
|
32
31
|
s.add_runtime_dependency(%q<json>, [">= 0"])
|
33
32
|
s.add_runtime_dependency(%q<monetize>, [">= 0"])
|
34
33
|
else
|
@@ -36,7 +35,6 @@ Gem::Specification.new do |s|
|
|
36
35
|
s.add_dependency(%q<rake>, [">= 0"])
|
37
36
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
38
37
|
s.add_dependency(%q<rspec>, [">= 0"])
|
39
|
-
s.add_dependency(%q<byebug>, [">= 0"])
|
40
38
|
s.add_dependency(%q<json>, [">= 0"])
|
41
39
|
s.add_dependency(%q<monetize>, [">= 0"])
|
42
40
|
end
|
@@ -45,7 +43,6 @@ Gem::Specification.new do |s|
|
|
45
43
|
s.add_dependency(%q<rake>, [">= 0"])
|
46
44
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
47
45
|
s.add_dependency(%q<rspec>, [">= 0"])
|
48
|
-
s.add_dependency(%q<byebug>, [">= 0"])
|
49
46
|
s.add_dependency(%q<json>, [">= 0"])
|
50
47
|
s.add_dependency(%q<monetize>, [">= 0"])
|
51
48
|
end
|
@@ -14,7 +14,7 @@ class ComplexConfig::Provider
|
|
14
14
|
attr_reader :plugins
|
15
15
|
|
16
16
|
def add_plugin(plugin)
|
17
|
-
|
17
|
+
plugins.add plugin
|
18
18
|
self
|
19
19
|
end
|
20
20
|
|
@@ -25,7 +25,7 @@ class ComplexConfig::Provider
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def apply_plugins(setting, id)
|
28
|
-
|
28
|
+
plugins.find do |plugin|
|
29
29
|
catch :skip do
|
30
30
|
value = setting.instance_exec(id, &plugin) and return value
|
31
31
|
end
|
@@ -6,11 +6,6 @@ class ComplexConfig::Settings < JSON::GenericObject
|
|
6
6
|
from_hash *a
|
7
7
|
end
|
8
8
|
|
9
|
-
def each(&block)
|
10
|
-
table.each(&block)
|
11
|
-
end
|
12
|
-
include Enumerable
|
13
|
-
|
14
9
|
def attribute_set?(name)
|
15
10
|
table.key?(name.to_sym)
|
16
11
|
end
|
@@ -24,14 +19,15 @@ class ComplexConfig::Settings < JSON::GenericObject
|
|
24
19
|
end
|
25
20
|
|
26
21
|
def to_h
|
27
|
-
each_with_object({}) do |(k, v), h|
|
28
|
-
h[k] =
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
22
|
+
table_enumerator.each_with_object({}) do |(k, v), h|
|
23
|
+
h[k] =
|
24
|
+
if Array === v
|
25
|
+
v.to_ary.map { |x| (x.ask_and_send(:to_h) rescue x) || x }
|
26
|
+
elsif v.respond_to?(:to_h)
|
27
|
+
v.ask_and_send(:to_h) rescue v
|
28
|
+
else
|
29
|
+
v
|
30
|
+
end
|
35
31
|
end
|
36
32
|
end
|
37
33
|
|
@@ -39,12 +35,14 @@ class ComplexConfig::Settings < JSON::GenericObject
|
|
39
35
|
to_h.to_yaml
|
40
36
|
end
|
41
37
|
|
42
|
-
|
38
|
+
def to_ary(*a, &b)
|
39
|
+
table_enumerator.__send__(:to_a, *a, &b)
|
40
|
+
end
|
43
41
|
|
44
42
|
alias inspect to_s
|
45
43
|
|
46
44
|
def deep_freeze
|
47
|
-
each do |_, v|
|
45
|
+
table_enumerator.each do |_, v|
|
48
46
|
v.ask_and_send(:deep_freeze) || (v.freeze rescue v)
|
49
47
|
end
|
50
48
|
freeze
|
@@ -52,6 +50,10 @@ class ComplexConfig::Settings < JSON::GenericObject
|
|
52
50
|
|
53
51
|
private
|
54
52
|
|
53
|
+
def table_enumerator
|
54
|
+
table.enum_for(:each)
|
55
|
+
end
|
56
|
+
|
55
57
|
def respond_to_missing?(id, include_private = false)
|
56
58
|
id =~ /\?\z/ || super
|
57
59
|
end
|
@@ -75,6 +77,8 @@ class ComplexConfig::Settings < JSON::GenericObject
|
|
75
77
|
else
|
76
78
|
if attribute_set?(id)
|
77
79
|
super
|
80
|
+
elsif table.respond_to?(id)
|
81
|
+
table.__send__(id, *a, &b)
|
78
82
|
else
|
79
83
|
raise ComplexConfig::AttributeMissing, "no attribute named #{id.inspect}"
|
80
84
|
end
|
@@ -1,6 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe ComplexConfig::Settings do
|
4
|
+
before do
|
5
|
+
# Disable all plugins for this spec b/c they interfere with how rspec works
|
6
|
+
allow(ComplexConfig::Provider.instance).to receive(:plugins).and_return([])
|
7
|
+
end
|
8
|
+
|
4
9
|
let :settings do
|
5
10
|
ComplexConfig::Settings[
|
6
11
|
foo: {
|
@@ -12,8 +17,12 @@ RSpec.describe ComplexConfig::Settings do
|
|
12
17
|
]
|
13
18
|
end
|
14
19
|
|
20
|
+
it "can return an attribute's value" do
|
21
|
+
expect(settings.foo.bar.baz).to eq true
|
22
|
+
end
|
23
|
+
|
15
24
|
it 'can display its attribute_names' do
|
16
|
-
expect(settings.foo.attribute_names).to eq
|
25
|
+
expect(settings.foo.attribute_names).to eq [ :bar, :qux ]
|
17
26
|
end
|
18
27
|
|
19
28
|
it 'can display its attribute_values' do
|
@@ -46,7 +55,6 @@ EOT
|
|
46
55
|
end
|
47
56
|
|
48
57
|
it 'raises exception if expected attribute is missing' do
|
49
|
-
pending "still doesn't work"
|
50
58
|
expect { settings.nix }.to raise_error(ComplexConfig::AttributeMissing)
|
51
59
|
end
|
52
60
|
|
@@ -54,12 +62,21 @@ EOT
|
|
54
62
|
expect(settings.foo.attribute_set?(:bar)).to eq true
|
55
63
|
expect(settings.foo.bar?).to be_truthy
|
56
64
|
expect(settings.foo.attribute_set?(:baz)).to eq false
|
57
|
-
|
65
|
+
expect(settings.foo.baz?).to be_falsy
|
58
66
|
end
|
59
67
|
|
60
68
|
it 'handles arrays correctly' do
|
61
69
|
settings = ComplexConfig::Settings[ary: [ 1, { hsh: 2 }, 3 ]]
|
62
70
|
expect(settings.to_h).to eq(ary: [ 1, { hsh: 2 }, 3 ])
|
63
71
|
end
|
64
|
-
end
|
65
72
|
|
73
|
+
it 'returns zip if it was set' do
|
74
|
+
settings = ComplexConfig::Settings[zip: 'a string']
|
75
|
+
expect(settings.zip).to eq 'a string'
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'zips the hash if zip was not set' do
|
79
|
+
settings = ComplexConfig::Settings[not_zip: 'a string']
|
80
|
+
expect(settings.zip([1])).to eq [ [ [ :not_zip, 'a string' ], 1 ] ]
|
81
|
+
end
|
82
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,113 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: complex_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.0
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
15
|
version_requirements: !ruby/object:Gem::Requirement
|
23
16
|
requirements:
|
24
|
-
- -
|
17
|
+
- - ~>
|
25
18
|
- !ruby/object:Gem::Version
|
26
19
|
version: 1.0.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
20
|
requirement: !ruby/object:Gem::Requirement
|
30
21
|
requirements:
|
31
|
-
- -
|
22
|
+
- - ~>
|
32
23
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
type: :development
|
24
|
+
version: 1.0.0
|
35
25
|
prerelease: false
|
26
|
+
type: :development
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
36
29
|
version_requirements: !ruby/object:Gem::Requirement
|
37
30
|
requirements:
|
38
|
-
- -
|
31
|
+
- - '>='
|
39
32
|
- !ruby/object:Gem::Version
|
40
33
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: simplecov
|
43
34
|
requirement: !ruby/object:Gem::Requirement
|
44
35
|
requirements:
|
45
|
-
- -
|
36
|
+
- - '>='
|
46
37
|
- !ruby/object:Gem::Version
|
47
38
|
version: '0'
|
48
|
-
type: :development
|
49
39
|
prerelease: false
|
40
|
+
type: :development
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: simplecov
|
50
43
|
version_requirements: !ruby/object:Gem::Requirement
|
51
44
|
requirements:
|
52
|
-
- -
|
45
|
+
- - '>='
|
53
46
|
- !ruby/object:Gem::Version
|
54
47
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
48
|
requirement: !ruby/object:Gem::Requirement
|
58
49
|
requirements:
|
59
|
-
- -
|
50
|
+
- - '>='
|
60
51
|
- !ruby/object:Gem::Version
|
61
52
|
version: '0'
|
62
|
-
type: :development
|
63
53
|
prerelease: false
|
54
|
+
type: :development
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
64
57
|
version_requirements: !ruby/object:Gem::Requirement
|
65
58
|
requirements:
|
66
|
-
- -
|
59
|
+
- - '>='
|
67
60
|
- !ruby/object:Gem::Version
|
68
61
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: byebug
|
71
62
|
requirement: !ruby/object:Gem::Requirement
|
72
63
|
requirements:
|
73
|
-
- -
|
64
|
+
- - '>='
|
74
65
|
- !ruby/object:Gem::Version
|
75
66
|
version: '0'
|
76
|
-
type: :development
|
77
67
|
prerelease: false
|
68
|
+
type: :development
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json
|
78
71
|
version_requirements: !ruby/object:Gem::Requirement
|
79
72
|
requirements:
|
80
|
-
- -
|
73
|
+
- - '>='
|
81
74
|
- !ruby/object:Gem::Version
|
82
75
|
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: json
|
85
76
|
requirement: !ruby/object:Gem::Requirement
|
86
77
|
requirements:
|
87
|
-
- -
|
78
|
+
- - '>='
|
88
79
|
- !ruby/object:Gem::Version
|
89
80
|
version: '0'
|
90
|
-
type: :runtime
|
91
81
|
prerelease: false
|
82
|
+
type: :runtime
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: monetize
|
92
85
|
version_requirements: !ruby/object:Gem::Requirement
|
93
86
|
requirements:
|
94
|
-
- -
|
87
|
+
- - '>='
|
95
88
|
- !ruby/object:Gem::Version
|
96
89
|
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: monetize
|
99
90
|
requirement: !ruby/object:Gem::Requirement
|
100
91
|
requirements:
|
101
|
-
- -
|
92
|
+
- - '>='
|
102
93
|
- !ruby/object:Gem::Version
|
103
94
|
version: '0'
|
104
|
-
type: :runtime
|
105
95
|
prerelease: false
|
106
|
-
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
96
|
+
type: :runtime
|
111
97
|
description: This library allows you to access configuration files via a simple interface
|
112
98
|
email: flori@ping.de
|
113
99
|
executables: []
|
@@ -126,10 +112,11 @@ extra_rdoc_files:
|
|
126
112
|
- lib/complex_config/shortcuts.rb
|
127
113
|
- lib/complex_config/version.rb
|
128
114
|
files:
|
129
|
-
-
|
130
|
-
-
|
131
|
-
-
|
132
|
-
-
|
115
|
+
- .gitignore
|
116
|
+
- .rspec
|
117
|
+
- .travis.yml
|
118
|
+
- .utilsrc
|
119
|
+
- COPYING
|
133
120
|
- Gemfile
|
134
121
|
- README.md
|
135
122
|
- Rakefile
|
@@ -158,28 +145,28 @@ homepage: https://github.com/flori/complex_config
|
|
158
145
|
licenses:
|
159
146
|
- Apache-2.0
|
160
147
|
metadata: {}
|
161
|
-
post_install_message:
|
148
|
+
post_install_message:
|
162
149
|
rdoc_options:
|
163
|
-
-
|
150
|
+
- --title
|
164
151
|
- ComplexConfig -- configuration library
|
165
|
-
-
|
152
|
+
- --main
|
166
153
|
- README.md
|
167
154
|
require_paths:
|
168
155
|
- lib
|
169
156
|
required_ruby_version: !ruby/object:Gem::Requirement
|
170
157
|
requirements:
|
171
|
-
- -
|
158
|
+
- - '>='
|
172
159
|
- !ruby/object:Gem::Version
|
173
160
|
version: '0'
|
174
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
162
|
requirements:
|
176
|
-
- -
|
163
|
+
- - '>='
|
177
164
|
- !ruby/object:Gem::Version
|
178
165
|
version: '0'
|
179
166
|
requirements: []
|
180
|
-
rubyforge_project:
|
181
|
-
rubygems_version: 2.
|
182
|
-
signing_key:
|
167
|
+
rubyforge_project:
|
168
|
+
rubygems_version: 2.1.9
|
169
|
+
signing_key:
|
183
170
|
specification_version: 4
|
184
171
|
summary: configuration library
|
185
172
|
test_files:
|