centroid 1.1.0 → 1.2.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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/centroid.gemspec +1 -1
- data/test/centroid_test.rb +70 -29
- 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: 10f06b65f1456f1c80523a64b22127d10ab533da
|
4
|
+
data.tar.gz: eae5193fb97114d3b0f763c99e23dd4a15446115
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c17ec252c370dce8e8d4d8eaf23e1ba5e1f0c844cd08e52b2564b5e7b1d19f36f1b07581bb59d94a07397c543608a2d6b94b84f747cb171aa5c29f88e78dac14
|
7
|
+
data.tar.gz: e2572359d37785b43f36a1739f86df98d267a8a4fc669f97e56f229a8cd09e8a245d86f0c28e8ad5b1135240e3fcad9d9de0135edf3ce34555ac440cd29d2cf8
|
data/README.md
CHANGED
@@ -34,7 +34,7 @@ To load a string instead of a file, create an instance of `Config` by passing a
|
|
34
34
|
```rb
|
35
35
|
# from_string.rb
|
36
36
|
json = '{ "database": { "serverAddress": "my-server.local" } }'
|
37
|
-
config = Centroid::Config(json)
|
37
|
+
config = Centroid::Config.new(json)
|
38
38
|
server = config.database.server_address # => "my-server.local"
|
39
39
|
```
|
40
40
|
|
@@ -59,7 +59,7 @@ In a `Config` instance, you can use the `has_key?` method to determine if a key
|
|
59
59
|
|
60
60
|
```rb
|
61
61
|
json = '{ "database": { "serverAddress": "my-server.local" } }'
|
62
|
-
config = Centroid::Config(json)
|
62
|
+
config = Centroid::Config.new(json)
|
63
63
|
config.has_key?(:database) # => true
|
64
64
|
config.include?("DoesNotExist") # => false
|
65
65
|
```
|
data/centroid.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'centroid'
|
3
|
-
s.version = '1.
|
3
|
+
s.version = '1.2.0'
|
4
4
|
s.summary = 'A centralizaed paradigm to configuration management.'
|
5
5
|
s.description = 'Centroid is a tool for loading configuration values declared in JSON, and accessing those configuration values using object properties.'
|
6
6
|
s.author = 'Resource Data, Inc'
|
data/test/centroid_test.rb
CHANGED
@@ -95,35 +95,6 @@ class ConfigTests < Test::Unit::TestCase
|
|
95
95
|
assert_equal(config.shared, "production!")
|
96
96
|
end
|
97
97
|
|
98
|
-
def test_all_environment_is_not_case_sensitive
|
99
|
-
config = Centroid::Config.new('{"Prod": {"Shared": "production!"}, "All": {"Shared": "none", "AllOnly": "works"}}')
|
100
|
-
config = config.for_environment("Prod")
|
101
|
-
assert_equal(config.all_only, "works")
|
102
|
-
|
103
|
-
config = Centroid::Config.new('{"Prod": {"Shared": "production!"}, "all": {"Shared": "none", "AllOnly": "works"}}')
|
104
|
-
config = config.for_environment("Prod")
|
105
|
-
assert_equal(config.all_only, "works")
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_supports_deep_merge
|
109
|
-
config = Centroid::Config.new('{"Prod": {"Database": {"Server": "prod-sql"}}, "All": {"Database": {"MigrationsPath": "path/to/migrations"}}}')
|
110
|
-
config = config.for_environment("Prod")
|
111
|
-
assert_equal(config.database.server, "prod-sql")
|
112
|
-
assert_equal(config.database.migrations_path, "path/to/migrations")
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_has_key
|
116
|
-
config = Centroid::Config.new(json_config)
|
117
|
-
assert(config.has_key?("the_environment"))
|
118
|
-
assert(!config.has_key?("does_not_exist"))
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_respond_to
|
122
|
-
config = Centroid::Config.new(json_config)
|
123
|
-
assert(config.respond_to?(:the_environment))
|
124
|
-
assert(!config.respond_to?(:does_not_exist))
|
125
|
-
end
|
126
|
-
|
127
98
|
def test_indexing_json_array
|
128
99
|
config = Centroid::Config.new(json_config_with_array)
|
129
100
|
assert_equal(config.the_array[0].the_key, "Value1")
|
@@ -169,4 +140,74 @@ class ConfigTests < Test::Unit::TestCase
|
|
169
140
|
assert_equal(v.password, "secret")
|
170
141
|
end
|
171
142
|
end
|
143
|
+
|
144
|
+
def test_all_environment_is_not_case_sensitive
|
145
|
+
config = Centroid::Config.new('{"Prod": {"Shared": "production!"}, "All": {"Shared": "none", "AllOnly": "works"}}')
|
146
|
+
config = config.for_environment("Prod")
|
147
|
+
assert_equal(config.all_only, "works")
|
148
|
+
|
149
|
+
config = Centroid::Config.new('{"Prod": {"Shared": "production!"}, "all": {"Shared": "none", "AllOnly": "works"}}')
|
150
|
+
config = config.for_environment("Prod")
|
151
|
+
assert_equal(config.all_only, "works")
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_supports_deep_merge
|
155
|
+
config = Centroid::Config.new('{"Prod": {"Database": {"Server": "prod-sql"}}, "All": {"Database": {"MigrationsPath": "path/to/migrations"}}}')
|
156
|
+
config = config.for_environment("Prod")
|
157
|
+
assert_equal(config.database.server, "prod-sql")
|
158
|
+
assert_equal(config.database.migrations_path, "path/to/migrations")
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_supports_merge_override()
|
162
|
+
json = '
|
163
|
+
{
|
164
|
+
"Dev": {
|
165
|
+
"Connection": {
|
166
|
+
"server": "dev-server",
|
167
|
+
"database": "dev_database",
|
168
|
+
"SdeConnectionFile": "DEV:sde(file)"
|
169
|
+
}
|
170
|
+
},
|
171
|
+
"All": {
|
172
|
+
"Connection": {
|
173
|
+
"server": "",
|
174
|
+
"database": "",
|
175
|
+
"instance": "",
|
176
|
+
"user": "default-user",
|
177
|
+
"password": "default-password",
|
178
|
+
"version": "",
|
179
|
+
"SdeConnectionFile": ""
|
180
|
+
}
|
181
|
+
}
|
182
|
+
}'
|
183
|
+
|
184
|
+
config = Centroid::Config.new(json)
|
185
|
+
config = config.for_environment("Dev");
|
186
|
+
assert_equal(config.Connection.Server, "dev-server");
|
187
|
+
assert_equal(config.Connection.database, "dev_database");
|
188
|
+
assert_equal(config.Connection.instance, "");
|
189
|
+
assert_equal(config.Connection.user, "default-user");
|
190
|
+
assert_equal(config.Connection.password, "default-password");
|
191
|
+
assert_equal(config.Connection.version, "");
|
192
|
+
assert_equal(config.Connection.SdeConnectionFile, "DEV:sde(file)");
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_has_key
|
196
|
+
config = Centroid::Config.new(json_config)
|
197
|
+
assert(config.has_key?("the_environment"))
|
198
|
+
assert(!config.has_key?("does_not_exist"))
|
199
|
+
end
|
200
|
+
|
201
|
+
def test_key_as_index
|
202
|
+
config = Centroid::Config.new(json_config)
|
203
|
+
my_string = "thekey"
|
204
|
+
assert_equal(config.the_environment[my_string], "TheValue")
|
205
|
+
end
|
206
|
+
|
207
|
+
def test_respond_to
|
208
|
+
config = Centroid::Config.new(json_config)
|
209
|
+
assert(config.respond_to?(:the_environment))
|
210
|
+
assert(!config.respond_to?(:does_not_exist))
|
211
|
+
end
|
212
|
+
|
172
213
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: centroid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Resource Data, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Centroid is a tool for loading configuration values declared in JSON,
|
14
14
|
and accessing those configuration values using object properties.
|
@@ -41,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
41
|
version: '0'
|
42
42
|
requirements: []
|
43
43
|
rubyforge_project:
|
44
|
-
rubygems_version: 2.4.
|
44
|
+
rubygems_version: 2.4.5
|
45
45
|
signing_key:
|
46
46
|
specification_version: 4
|
47
47
|
summary: A centralizaed paradigm to configuration management.
|