config_default 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: 0f4cf3d6077b01b84dd411087f261e2bbd05d60e94c44dbb56533c67a28cbf44
4
- data.tar.gz: ca3206dbcc7f82a9f1d37049f7106a51cba979ef735ad2b28393c3452152488f
3
+ metadata.gz: b0e496b125200f0a672fbbc01b51ce0f2634f83d742384980a5e77300401de55
4
+ data.tar.gz: 367ebd46e430509331e964e31a463f237f29f9b73a81967a978a9875d41760bf
5
5
  SHA512:
6
- metadata.gz: 7891a43cdf5152d15524e240a0d89ef33333073d4e8514310d49f58b134b14f34f18306882d653f11a4032b968977f73081657ae806dcead0876e19f6c1d09e7
7
- data.tar.gz: 6ca0ce6cd318011478cffda1ac799d93587b0fc341ed06443fac793f3f756e207f0d72679ec76725c0b845a28a3e6bc021d6696759ee2018cdc32f512627425f
6
+ metadata.gz: 4463a3895be54cda1a391edf76b78c55a1389fb981b00e6529ce7643ec307fe98ea7acbc778ddb51b4d330046f07c5e345e1ab14a0e409c5c158c5ed0693f919
7
+ data.tar.gz: ff999b172f7971c4c0f891c8195155b1ac421ae74997e37bb71cb2b06e1e2e5c8d76794d1701b46cc9c8de37999e4a5dab8d85f2c82e13f388ccafde12a0983c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- config_default (0.2.0)
4
+ config_default (0.2.1)
5
5
  activesupport (~> 6)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -33,6 +33,14 @@ ConfigDefault.configure do |config|
33
33
  end
34
34
  ```
35
35
 
36
+ If you want to implement Rails monkey patches for `Rails.application.config_for` and ability to
37
+ separate `database.yml` file you need to apply `#init_rails_monkey_patch!` method in your
38
+ `application.yml` file before application initialization.
39
+
40
+ ```ruby
41
+ ConfigDefault.init_rails_monkey_patch!
42
+ ```
43
+
36
44
  ## Usage
37
45
 
38
46
  ### Default behaviour
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module ConfigDefault::RailsMonkeyPatch
3
+ module ConfigDefault::Init
4
4
  extend self
5
5
 
6
- def call
6
+ def init_rails_monkey_patch!
7
7
  return unless Object.const_defined?("Rails")
8
8
  return unless Object.const_defined?("Rails::Application")
9
9
  return unless Object.const_defined?("Rails::Application::Configuration")
10
10
 
11
- require "config_default/rails/application_extension"
12
- require "config_default/rails/application/configuration_extension"
11
+ Rails::Application.prepend(ConfigDefault::RailsApplicationExtension)
12
+ Rails::Application::Configuration.prepend(ConfigDefault::RailsApplicationConfigurationExtension)
13
13
  end
14
14
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Rails::Application::ConfigurationExtension
3
+ module ConfigDefault::RailsApplicationConfigurationExtension
4
4
  def load_database_yaml
5
5
  ConfigDefault.load(:database, key: nil)
6
6
  end
@@ -9,5 +9,3 @@ module Rails::Application::ConfigurationExtension
9
9
  load_database_yaml
10
10
  end
11
11
  end
12
-
13
- Rails::Application::Configuration.prepend(Rails::Application::ConfigurationExtension)
@@ -1,10 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Rails::ApplicationExtension
3
+ module ConfigDefault::RailsApplicationExtension
4
4
  def config_for(name, env: Rails.env)
5
5
  data = ConfigDefault.load(name, key: env, deep_symbolize_keys: true)
6
6
  ActiveSupport::OrderedOptions.new.merge(data)
7
7
  end
8
8
  end
9
-
10
- Rails::Application.prepend(Rails::ApplicationExtension)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ConfigDefault
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
@@ -4,8 +4,10 @@ require "active_support/core_ext/hash"
4
4
 
5
5
  require "config_default/version"
6
6
  require "config_default/config"
7
+ require "config_default/init"
7
8
  require "config_default/struct"
8
- require "config_default/rails_monkey_patch"
9
+ require "config_default/rails_application_extension"
10
+ require "config_default/rails_application_configuration_extension"
9
11
 
10
12
  module ConfigDefault
11
13
  extend self
@@ -18,6 +20,10 @@ module ConfigDefault
18
20
  yield(config) if block_given?
19
21
  end
20
22
 
23
+ def init_rails_monkey_patch!
24
+ ConfigDefault::Init.init_rails_monkey_patch!
25
+ end
26
+
21
27
  def load(name, key: Rails.env, symbolize_keys: false, deep_symbolize_keys: false)
22
28
  default_config = load_file("#{name}.#{config.postfix}")
23
29
  config = load_file(name)
@@ -49,5 +55,3 @@ module ConfigDefault
49
55
  )
50
56
  end
51
57
  end
52
-
53
- ConfigDefault::RailsMonkeyPatch.call
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config_default
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stepan Kirushkin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-21 00:00:00.000000000 Z
11
+ date: 2021-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -46,9 +46,9 @@ files:
46
46
  - bin/setup
47
47
  - lib/config_default.rb
48
48
  - lib/config_default/config.rb
49
- - lib/config_default/rails/application/configuration_extension.rb
50
- - lib/config_default/rails/application_extension.rb
51
- - lib/config_default/rails_monkey_patch.rb
49
+ - lib/config_default/init.rb
50
+ - lib/config_default/rails_application_configuration_extension.rb
51
+ - lib/config_default/rails_application_extension.rb
52
52
  - lib/config_default/struct.rb
53
53
  - lib/config_default/version.rb
54
54
  homepage: https://github.com/skirushkin/config_default