config 1.2.0 → 1.2.1
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 +8 -4
- data/lib/config/integrations/rails/engine.rb +6 -2
- data/lib/config/integrations/rails/railtie.rb +24 -26
- data/lib/config/options.rb +24 -15
- data/lib/config/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34f4e737856626cc5203879e2d02a960d462c98a
|
4
|
+
data.tar.gz: 19ad725186dca0e04f6df5e3cc19233f4a9f8082
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91ee75b5cda097edfc300b7c3362a327e309ae782a2840554eb265732e8061e17427e521f4ecb39c250a5d99acf2c805fb92f4a0b0f45494a04552ec59e62258
|
7
|
+
data.tar.gz: d4402504c6080cfb54ed9660b391a53724e924c005c70bd995e2f31b60118cd7a5cecda0edbdef5968f8b947518eb2d703021af2650d0ad42180c65fdb3ba6e8
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.2.1
|
4
|
+
|
5
|
+
* Fixed support for multilevel settings loaded from ENV variables (inspired by @cbeer in [#144](https://github.com/railsconfig/config/pull/144))gem
|
6
|
+
|
3
7
|
## 1.2.0
|
4
8
|
|
5
|
-
* Add ability to load settings from ENV variables ([#108](https://github.com/railsconfig/config/issues/108) thanks @vinceve and @spalladino)
|
6
|
-
* Removed Rails 5 deprecation warnings for prepend_before_filter ([#141](https://github.com/railsconfig/config/pull/141)
|
9
|
+
* Add ability to load settings from ENV variables ([#108](https://github.com/railsconfig/config/issues/108) thanks to @vinceve and @spalladino)
|
10
|
+
* Removed Rails 5 deprecation warnings for prepend_before_filter ([#141](https://github.com/railsconfig/config/pull/141))
|
7
11
|
|
8
12
|
## 1.1.1
|
9
13
|
|
@@ -18,8 +22,8 @@
|
|
18
22
|
|
19
23
|
* `RailsConfig` is now officially renamed to `Config`
|
20
24
|
* Fixed array descent when converting to hash ([#89](https://github.com/railsconfig/config/pull/89))
|
21
|
-
* Catch OpenStruct reserved keywords ([#95](https://github.com/railsconfig/config/pull/95)
|
22
|
-
* Allows loading before app configuration process ([#107](https://github.com/railsconfig/config/pull/107)
|
25
|
+
* Catch OpenStruct reserved keywords ([#95](https://github.com/railsconfig/config/pull/95) by @dudo)
|
26
|
+
* Allows loading before app configuration process ([#107](https://github.com/railsconfig/config/pull/107) by @Antiarchitect)
|
23
27
|
* `deep_merge` is now properly managed via gemspec ([#110](https://github.com/railsconfig/config/pull/110))
|
24
28
|
* Added `prepend_source!` ([#102](https://github.com/railsconfig/config/pull/102))
|
25
29
|
|
@@ -1,35 +1,33 @@
|
|
1
1
|
module Config
|
2
|
-
module
|
2
|
+
module Integrations
|
3
3
|
module Rails
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
|
+
# Load rake tasks (eg. Heroku)
|
6
|
+
rake_tasks do
|
7
|
+
Dir[File.join(File.dirname(__FILE__), '../tasks/*.rake')].each { |f| load f }
|
8
|
+
end
|
10
9
|
|
11
|
-
|
10
|
+
config.before_configuration { preload }
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
def preload
|
13
|
+
# Manually load the custom initializer before everything else
|
14
|
+
initializer = ::Rails.root.join("config", "initializers", "config.rb")
|
15
|
+
require initializer if File.exist?(initializer)
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
# Parse the settings before any of the initializers
|
18
|
+
Config.load_and_set_settings(
|
19
|
+
Config.setting_files(::Rails.root.join("config"), ::Rails.env)
|
20
|
+
)
|
21
|
+
end
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
23
|
+
# Rails Dev environment should reload the Settings on every request
|
24
|
+
if ::Rails.env.development?
|
25
|
+
initializer :config_reload_on_development do
|
26
|
+
ActionController::Base.class_eval do
|
27
|
+
if ::Rails::VERSION::MAJOR >= 4
|
28
|
+
prepend_before_action { ::Config.reload! }
|
29
|
+
else
|
30
|
+
prepend_before_filter { ::Config.reload! }
|
33
31
|
end
|
34
32
|
end
|
35
33
|
end
|
data/lib/config/options.rb
CHANGED
@@ -29,23 +29,33 @@ module Config
|
|
29
29
|
|
30
30
|
def reload_env!
|
31
31
|
return self if ENV.nil? || ENV.empty?
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
32
|
+
|
33
|
+
hash = Hash.new
|
34
|
+
|
35
|
+
ENV.each do |variable, value|
|
36
|
+
keys = variable.to_s.split(Config.env_separator)
|
37
|
+
|
38
|
+
next if keys.shift != (Config.env_prefix || Config.const_name)
|
39
|
+
|
40
|
+
keys.map! { |key|
|
41
|
+
case Config.env_converter
|
42
|
+
when :downcase then
|
43
|
+
key.downcase.to_sym
|
44
|
+
when nil then
|
45
|
+
key.to_sym
|
46
|
+
else
|
47
|
+
raise "Invalid ENV variables name converter: #{Config.env_converter}"
|
41
48
|
end
|
49
|
+
}
|
42
50
|
|
43
|
-
|
44
|
-
|
45
|
-
|
51
|
+
leaf = keys[0...-1].inject(hash) { |h, key|
|
52
|
+
h[key] ||= {}
|
53
|
+
}
|
54
|
+
|
55
|
+
leaf[keys.last] = Config.env_parse_values ? __value(value) : value
|
46
56
|
end
|
47
57
|
|
48
|
-
merge!(
|
58
|
+
merge!(hash)
|
49
59
|
end
|
50
60
|
|
51
61
|
alias :load_env! :reload_env!
|
@@ -59,11 +69,10 @@ module Config
|
|
59
69
|
if conf.empty?
|
60
70
|
conf = source_conf
|
61
71
|
else
|
62
|
-
# see Options Details in lib/rails_config/vendor/deep_merge.rb
|
63
72
|
DeepMerge.deep_merge!(source_conf,
|
64
73
|
conf,
|
65
74
|
preserve_unmergeables: false,
|
66
|
-
knockout_prefix:
|
75
|
+
knockout_prefix: Config.knockout_prefix)
|
67
76
|
end
|
68
77
|
end
|
69
78
|
|
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.2.
|
4
|
+
version: 1.2.1
|
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-05-
|
13
|
+
date: 2016-05-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|