bogo-config 0.1.10 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d3fb69b6897f82bdf3c449aad1af27ded1f4b70
4
- data.tar.gz: 3797393d8f40e4dbc338d7fde873b7e82ea3b36a
3
+ metadata.gz: df28c06334f917e1601e2447192762e77051b48f
4
+ data.tar.gz: ab84955b7760e680209998b3f8fef5c8adbb31fe
5
5
  SHA512:
6
- metadata.gz: 41f2a7a7f6ed477163249e4f7ff8d93edeb30c98e9fe6910632d876ba0b5aa0f60927c6d95c1d919181631573b19e21586312f515a4a25a12b2091508d0612df
7
- data.tar.gz: 899b349790ebb5f3f9cce302c0ffda2b93edcd9a32f112aa64bd1501874fe6279dc073e1c95cfd13530827fcc78f830fd11c1286921499b11a09b88ca8ab44ef
6
+ metadata.gz: a58dec6a9c1f3e4965e351b9081d7d5b01e77cfd97b65b3935da36a035902f2181f7f84905a417ec9ca476236f5e46a00c4b2ae829b02f82d53ae645e52e4140
7
+ data.tar.gz: facd21861645d92456a2dbd7029fb453d6edb300e31df7e9510f04b01d8d27d14d2e31b1b8bf3da2d22280c4b155371660b526a1189cbaebcccbd830f291fb45
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.1.12
2
+ * Allow Ruby config disable via environment variable
3
+ * Remove exclusive use during init
4
+
1
5
  ## v0.1.10
2
6
  * Gracefully handle failures of ruby files (rescue parse errors)
3
7
 
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
@@ -123,11 +123,10 @@ module Bogo
123
123
  end
124
124
  if(hash)
125
125
  is_immutable = data.frozen?
126
- Thread.exclusive do
127
- load_data(hash)
128
- @data = hash.to_smash.deep_merge(data.to_smash)
129
- @data.to_smash(:freeze) if is_immutable
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
- result = Module.new.instance_eval(
267
- IO.read(file_path), file_path, 1
268
- )
269
- result._dump.to_smash
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
@@ -1,6 +1,6 @@
1
1
  module Bogo
2
2
  class Config
3
3
  # Current library version
4
- VERSION = Gem::Version.new('0.1.10')
4
+ VERSION = Gem::Version.new('0.1.12')
5
5
  end
6
6
  end
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.10
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-03-06 00:00:00.000000000 Z
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: