bogo-config 0.1.10 → 0.1.12
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/CHANGELOG.md +4 -0
- data/README.md +13 -2
- data/lib/bogo-config/config.rb +23 -10
- data/lib/bogo-config/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df28c06334f917e1601e2447192762e77051b48f
|
4
|
+
data.tar.gz: ab84955b7760e680209998b3f8fef5c8adbb31fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a58dec6a9c1f3e4965e351b9081d7d5b01e77cfd97b65b3935da36a035902f2181f7f84905a417ec9ca476236f5e46a00c4b2ae829b02f82d53ae645e52e4140
|
7
|
+
data.tar.gz: facd21861645d92456a2dbd7029fb453d6edb300e31df7e9510f04b01d8d27d14d2e31b1b8bf3da2d22280c4b155371660b526a1189cbaebcccbd830f291fb45
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -79,7 +79,7 @@ JSON example could also be written as:
|
|
79
79
|
|
80
80
|
```ruby
|
81
81
|
# /tmp/bogo-config.rb
|
82
|
-
Configuration do
|
82
|
+
Configuration.new do
|
83
83
|
bind do
|
84
84
|
address '0.0.0.0'
|
85
85
|
port 8080
|
@@ -123,5 +123,16 @@ The path provided on initialization can also be a directory.
|
|
123
123
|
The contents of the directory will be read in string sorted
|
124
124
|
order and deep merged. Files can be a mix of supported types.
|
125
125
|
|
126
|
+
### Ruby evaluation
|
127
|
+
|
128
|
+
Ruby evaluation is super awesome, except when you don't want
|
129
|
+
it and then it's not super awesome. If a running process needs
|
130
|
+
to disable Ruby based evaluation (a service perhaps), this
|
131
|
+
can be done with an environment variable:
|
132
|
+
|
133
|
+
```
|
134
|
+
export BOGO_CONFIG_DISABLE_EVAL=true
|
135
|
+
```
|
136
|
+
|
126
137
|
## Info
|
127
|
-
* Repository: https://github.com/spox/bogo-config
|
138
|
+
* Repository: https://github.com/spox/bogo-config
|
data/lib/bogo-config/config.rb
CHANGED
@@ -123,11 +123,10 @@ module Bogo
|
|
123
123
|
end
|
124
124
|
if(hash)
|
125
125
|
is_immutable = data.frozen?
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
end
|
126
|
+
# TODO: synchronize here
|
127
|
+
load_data(hash)
|
128
|
+
@data = hash.to_smash.deep_merge(data.to_smash)
|
129
|
+
@data.to_smash(:freeze) if is_immutable
|
131
130
|
end
|
132
131
|
self
|
133
132
|
end
|
@@ -178,7 +177,7 @@ module Bogo
|
|
178
177
|
json_load(file_path)
|
179
178
|
when '.xml'
|
180
179
|
xml_load(file_path)
|
181
|
-
when '.rb'
|
180
|
+
when '.rb' && eval_enabled?
|
182
181
|
struct_load(file_path)
|
183
182
|
else
|
184
183
|
result = [:struct_load, :json_load, :yaml_load, :xml_load].map do |loader|
|
@@ -263,10 +262,24 @@ module Bogo
|
|
263
262
|
# @param file_path
|
264
263
|
# @return [Smash]
|
265
264
|
def struct_load(file_path)
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
265
|
+
if(eval_disabled?)
|
266
|
+
raise 'Ruby based configuration evaluation is currently disabled!'
|
267
|
+
else
|
268
|
+
result = Module.new.instance_eval(
|
269
|
+
IO.read(file_path), file_path, 1
|
270
|
+
)
|
271
|
+
result._dump.to_smash
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
# @return [TrueClass, FalseClass]
|
276
|
+
def eval_enabled?
|
277
|
+
ENV['BOGO_CONFIG_DISABLE_EVAL'].to_s.downcase != 'true'
|
278
|
+
end
|
279
|
+
|
280
|
+
# @return [TrueClass, FalseClass]
|
281
|
+
def eval_disabled?
|
282
|
+
!eval_enabled?
|
270
283
|
end
|
271
284
|
|
272
285
|
end
|
data/lib/bogo-config/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bogo-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bogo
|
@@ -112,4 +112,3 @@ signing_key:
|
|
112
112
|
specification_version: 4
|
113
113
|
summary: Configuration helper library
|
114
114
|
test_files: []
|
115
|
-
has_rdoc:
|