config 1.3.0 → 1.4.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/CHANGELOG.md +7 -1
- data/README.md +18 -0
- data/lib/config.rb +1 -0
- data/lib/config/options.rb +8 -6
- data/lib/config/sources/hash_source.rb +16 -0
- data/lib/config/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73118a0190819d693e81132bc4a2746a453dd74d
|
4
|
+
data.tar.gz: 5c6a339dcfa60f444269f0ba45da298656297471
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a28428c4f956dacbd9032fa97037819a15956eb0d694a48a4250425d3902ef9fd13bb67fcfdb011d1c67ea043476a386c2dd6e729de85a846ad13d2b772c67a5
|
7
|
+
data.tar.gz: 35fa737c860ca76a6c6aac73ccbdab4e5e399cfdf214d357e26cdd9e00fa1e3652a4701bfb73adcca498981cf67bd10c35088fe510d925605f43087f7cccee0b
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.4.0
|
4
|
+
|
5
|
+
* Added support for passing a raw ruby hash into to both `Settings.add_source!` and `Settings.prepend_source!` ([#108](https://github.com/railsconfig/config/pull/159) thanks to [@halloffame](https://github.com/halloffame))
|
6
|
+
* Added new reserved name `test` ([#158](https://github.com/railsconfig/config/pull/158) thanks to [@milushov](https://github.com/milushov))
|
7
|
+
* `to_hash` should not replace nested config objects with Hash ([#160](https://github.com/railsconfig/config/issues/160) thanks to [@seikichi](https://github.com/seikichi))
|
8
|
+
|
3
9
|
## 1.3.0
|
4
10
|
|
5
|
-
* **WARNING:** Overwrite arrays found in previously loaded settings file ([#137](https://github.com/railsconfig/config/pull/137) thanks to [@Fryguy](https://github.com/Fryguy) and [@dtaniwaki](https://github.com/dtaniwaki)) - this is a change breaking previous behaviour. If you want to keep Config to work as before, which is merging arrays found in following loaded settings file, please add `config.overwrite_arrays =
|
11
|
+
* **WARNING:** Overwrite arrays found in previously loaded settings file ([#137](https://github.com/railsconfig/config/pull/137) thanks to [@Fryguy](https://github.com/Fryguy) and [@dtaniwaki](https://github.com/dtaniwaki)) - this is a change breaking previous behaviour. If you want to keep Config to work as before, which is merging arrays found in following loaded settings file, please add `config.overwrite_arrays = false` to your Config initializer
|
6
12
|
* Changed default ENV variables loading settings to downcase variable names and parse values
|
7
13
|
* Added parsing ENV variables values to Float type
|
8
14
|
* Change method definition order in Rails integration module to prevent undefined method `preload` error (based on [@YaroSpace](https://github.com/YaroSpace) suggestion in [#111](https://github.com/railsconfig/config/issues/111)
|
data/README.md
CHANGED
@@ -64,6 +64,15 @@ set :root, File.dirname(__FILE__)
|
|
64
64
|
register Config
|
65
65
|
```
|
66
66
|
|
67
|
+
### Installing on other ruby projects
|
68
|
+
|
69
|
+
Add the gem to your `Gemfile` and run `bundle install` to install it.
|
70
|
+
Then initialize `Config` manually within your configure block.
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
Config.load_and_set_settings(Config.setting_files("/path/to/config_root", "your_project_environment"))
|
74
|
+
```
|
75
|
+
|
67
76
|
It's also possible to initialize `Config` manually within your configure block if you want to just give it some yml
|
68
77
|
paths to load from.
|
69
78
|
|
@@ -184,6 +193,15 @@ Settings.reload!
|
|
184
193
|
> Note: this is an example usage, it is easier to just use the default local files `settings.local.yml,
|
185
194
|
settings/#{Rails.env}.local.yml and environments/#{Rails.env}.local.yml` for your developer specific settings.
|
186
195
|
|
196
|
+
You also have the option to add a raw hash as a source. One use case might be storing settings in the database or in environment variables that overwrite what is in the YML files.
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
Settings.add_source!({some_secret: ENV['some_secret']})
|
200
|
+
Settings.reload!
|
201
|
+
```
|
202
|
+
|
203
|
+
You may pass a hash to `prepend_source!` as well.
|
204
|
+
|
187
205
|
## Embedded Ruby (ERB)
|
188
206
|
|
189
207
|
Embedded Ruby is allowed in the configuration files. Consider the two following config files.
|
data/lib/config.rb
CHANGED
data/lib/config/options.rb
CHANGED
@@ -15,6 +15,7 @@ module Config
|
|
15
15
|
def add_source!(source)
|
16
16
|
# handle yaml file paths
|
17
17
|
source = (Sources::YAMLSource.new(source)) if source.is_a?(String)
|
18
|
+
source = (Sources::HashSource.new(source)) if source.is_a?(Hash)
|
18
19
|
|
19
20
|
@config_sources ||= []
|
20
21
|
@config_sources << source
|
@@ -22,6 +23,7 @@ module Config
|
|
22
23
|
|
23
24
|
def prepend_source!(source)
|
24
25
|
source = (Sources::YAMLSource.new(source)) if source.is_a?(String)
|
26
|
+
source = (Sources::HashSource.new(source)) if source.is_a?(Hash)
|
25
27
|
|
26
28
|
@config_sources ||= []
|
27
29
|
@config_sources.unshift(source)
|
@@ -126,7 +128,7 @@ module Config
|
|
126
128
|
end
|
127
129
|
|
128
130
|
# Some keywords that don't play nicely with OpenStruct
|
129
|
-
SETTINGS_RESERVED_NAMES = %w{select collect}
|
131
|
+
SETTINGS_RESERVED_NAMES = %w{select collect test}
|
130
132
|
|
131
133
|
# An alternative mechanism for property access.
|
132
134
|
# This let's you do foo['bar'] along with foo.bar.
|
@@ -148,15 +150,15 @@ module Config
|
|
148
150
|
protected
|
149
151
|
|
150
152
|
def descend_array(array)
|
151
|
-
array.
|
152
|
-
value = array[i]
|
153
|
+
array.map do |value|
|
153
154
|
if value.instance_of? Config::Options
|
154
|
-
|
155
|
+
value.to_hash
|
155
156
|
elsif value.instance_of? Array
|
156
|
-
|
157
|
+
descend_array(value)
|
158
|
+
else
|
159
|
+
value
|
157
160
|
end
|
158
161
|
end
|
159
|
-
array
|
160
162
|
end
|
161
163
|
|
162
164
|
# Recursively converts Hashes to Options (including Hashes inside Arrays)
|
data/lib/config/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Kuczynski
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-12-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -265,6 +265,7 @@ files:
|
|
265
265
|
- lib/config/integrations/sinatra.rb
|
266
266
|
- lib/config/options.rb
|
267
267
|
- lib/config/rack/reloader.rb
|
268
|
+
- lib/config/sources/hash_source.rb
|
268
269
|
- lib/config/sources/yaml_source.rb
|
269
270
|
- lib/config/tasks/heroku.rake
|
270
271
|
- lib/config/version.rb
|
@@ -297,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
297
298
|
version: '0'
|
298
299
|
requirements: []
|
299
300
|
rubyforge_project:
|
300
|
-
rubygems_version: 2.
|
301
|
+
rubygems_version: 2.6.8
|
301
302
|
signing_key:
|
302
303
|
specification_version: 4
|
303
304
|
summary: Effortless multi-environment settings in Rails, Sinatra, Pandrino and others
|