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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33b69a268cf5f3283b1d14ea01b4345fbd6433ef
4
- data.tar.gz: 4ad2fb585182fd398877f53974bba1244eae8bea
3
+ metadata.gz: 34f4e737856626cc5203879e2d02a960d462c98a
4
+ data.tar.gz: 19ad725186dca0e04f6df5e3cc19233f4a9f8082
5
5
  SHA512:
6
- metadata.gz: a92ef95bc9265fcd182d29cffd3f37e2bd71f3b0e3d8ca4d0f540f62389c4aaab2fbddd4ba15b45fd11c782c9ed3836eabe35927c3ceb3bd54abdf4d616cb1cc
7
- data.tar.gz: 58568bb221dd00b41b8b5305510c763bf1610b63e7904a41e38ef1b5305c79e9ca0cbb49f3177bbb33c8107075314e5349d1ebd9d26e3fe1b15810c71b46057e
6
+ metadata.gz: 91ee75b5cda097edfc300b7c3362a327e309ae782a2840554eb265732e8061e17427e521f4ecb39c250a5d99acf2c805fb92f4a0b0f45494a04552ec59e62258
7
+ data.tar.gz: d4402504c6080cfb54ed9660b391a53724e924c005c70bd995e2f31b60118cd7a5cecda0edbdef5968f8b947518eb2d703021af2650d0ad42180c65fdb3ba6e8
@@ -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) thanks @dudo)
22
- * Allows loading before app configuration process ([#107](https://github.com/railsconfig/config/pull/107) thanks @Antiarchitect)
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,5 +1,9 @@
1
1
  module Config
2
- class Engine < ::Rails::Engine
3
- isolate_namespace Config
2
+ module Integrations
3
+ module Rails
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace Config
6
+ end
7
+ end
4
8
  end
5
9
  end
@@ -1,35 +1,33 @@
1
1
  module Config
2
- module Integration
2
+ module Integrations
3
3
  module Rails
4
- if defined?(::Rails::Railtie)
5
- class Railtie < ::Rails::Railtie
6
- # Load rake tasks (eg. Heroku)
7
- rake_tasks do
8
- Dir[File.join(File.dirname(__FILE__),'../tasks/*.rake')].each { |f| load f }
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
- config.before_configuration { preload }
10
+ config.before_configuration { preload }
12
11
 
13
- def preload
14
- # Manually load the custom initializer before everything else
15
- initializer = ::Rails.root.join("config", "initializers", "config.rb")
16
- require initializer if File.exist?(initializer)
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
- # Parse the settings before any of the initializers
19
- Config.load_and_set_settings(
20
- Config.setting_files(::Rails.root.join("config"), ::Rails.env)
21
- )
22
- end
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
- # Rails Dev environment should reload the Settings on every request
25
- if ::Rails.env.development?
26
- initializer :config_reload_on_development do
27
- ActionController::Base.class_eval do
28
- if ::Rails::VERSION::MAJOR >= 4
29
- prepend_before_action { ::Config.reload! }
30
- else
31
- prepend_before_filter { ::Config.reload! }
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
@@ -29,23 +29,33 @@ module Config
29
29
 
30
30
  def reload_env!
31
31
  return self if ENV.nil? || ENV.empty?
32
- conf = Hash.new
33
- ENV.each do |key, value|
34
- next unless key.to_s.index(Config.env_prefix || Config.const_name) == 0
35
- hash = Config.env_parse_values ? __value(value) : value
36
- key.to_s.split(Config.env_separator).reverse[0...-1].each do |element|
37
- element = case Config.env_converter
38
- when :downcase then element.downcase
39
- when nil then element
40
- else raise "Invalid env converter: #{Config.env_converter}"
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
- hash = {element => hash}
44
- end
45
- DeepMerge.deep_merge!(hash, conf, :preserve_unmergeables => false)
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!(conf)
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: Config.knockout_prefix)
75
+ knockout_prefix: Config.knockout_prefix)
67
76
  end
68
77
  end
69
78
 
@@ -1,3 +1,3 @@
1
1
  module Config
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
  end
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.0
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-12 00:00:00.000000000 Z
13
+ date: 2016-05-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport