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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +8 -0
- data/lib/config_default/{rails_monkey_patch.rb → init.rb} +4 -4
- data/lib/config_default/{rails/application/configuration_extension.rb → rails_application_configuration_extension.rb} +1 -3
- data/lib/config_default/{rails/application_extension.rb → rails_application_extension.rb} +1 -3
- data/lib/config_default/version.rb +1 -1
- data/lib/config_default.rb +7 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0e496b125200f0a672fbbc01b51ce0f2634f83d742384980a5e77300401de55
|
4
|
+
data.tar.gz: 367ebd46e430509331e964e31a463f237f29f9b73a81967a978a9875d41760bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4463a3895be54cda1a391edf76b78c55a1389fb981b00e6529ce7643ec307fe98ea7acbc778ddb51b4d330046f07c5e345e1ab14a0e409c5c158c5ed0693f919
|
7
|
+
data.tar.gz: ff999b172f7971c4c0f891c8195155b1ac421ae74997e37bb71cb2b06e1e2e5c8d76794d1701b46cc9c8de37999e4a5dab8d85f2c82e13f388ccafde12a0983c
|
data/Gemfile.lock
CHANGED
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::
|
3
|
+
module ConfigDefault::Init
|
4
4
|
extend self
|
5
5
|
|
6
|
-
def
|
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
|
-
|
12
|
-
|
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
|
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
|
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)
|
data/lib/config_default.rb
CHANGED
@@ -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/
|
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.
|
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-
|
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/
|
50
|
-
- lib/config_default/
|
51
|
-
- lib/config_default/
|
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
|