config_default 0.2.0 → 0.2.3

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: c6d364e12aa53e53403e1d07d97af5e4aa8bf3ebad0e68d89b208aa5e0d3d36e
4
+ data.tar.gz: 8d0a52621b05763871f6f08f45280a6d5098c331e2678def37195d870c7e3c77
5
5
  SHA512:
6
- metadata.gz: 7891a43cdf5152d15524e240a0d89ef33333073d4e8514310d49f58b134b14f34f18306882d653f11a4032b968977f73081657ae806dcead0876e19f6c1d09e7
7
- data.tar.gz: 6ca0ce6cd318011478cffda1ac799d93587b0fc341ed06443fac793f3f756e207f0d72679ec76725c0b845a28a3e6bc021d6696759ee2018cdc32f512627425f
6
+ metadata.gz: 33fff861a6c04f26f96ba558b08bcc1d085391a0a296e519b83cba6386bd32fa6b57cc541eb2ec7acd90623556b0679a39b314cecdaf82870e54580ea76d858e
7
+ data.tar.gz: 76c86562331604f05c83bbc31e273216d46074785bb29f3eae875f9f22be975ef6b72ae466b32a0a9cc70a5eea3570bea5fed392130eff48e0d740ba1b8f0d23
@@ -24,7 +24,7 @@ jobs:
24
24
 
25
25
  strategy:
26
26
  matrix:
27
- ruby: [2.5, 2.6, 2.7, 3.0]
27
+ ruby: [2.7, 3.0, 3.1]
28
28
 
29
29
  steps:
30
30
  - uses: actions/checkout@v2
data/Gemfile.lock CHANGED
@@ -1,83 +1,91 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- config_default (0.2.0)
5
- activesupport (~> 6)
4
+ config_default (0.2.3)
5
+ activesupport (>= 6)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (6.1.4.1)
11
- actionpack (= 6.1.4.1)
12
- activesupport (= 6.1.4.1)
10
+ actioncable (7.0.1)
11
+ actionpack (= 7.0.1)
12
+ activesupport (= 7.0.1)
13
13
  nio4r (~> 2.0)
14
14
  websocket-driver (>= 0.6.1)
15
- actionmailbox (6.1.4.1)
16
- actionpack (= 6.1.4.1)
17
- activejob (= 6.1.4.1)
18
- activerecord (= 6.1.4.1)
19
- activestorage (= 6.1.4.1)
20
- activesupport (= 6.1.4.1)
15
+ actionmailbox (7.0.1)
16
+ actionpack (= 7.0.1)
17
+ activejob (= 7.0.1)
18
+ activerecord (= 7.0.1)
19
+ activestorage (= 7.0.1)
20
+ activesupport (= 7.0.1)
21
21
  mail (>= 2.7.1)
22
- actionmailer (6.1.4.1)
23
- actionpack (= 6.1.4.1)
24
- actionview (= 6.1.4.1)
25
- activejob (= 6.1.4.1)
26
- activesupport (= 6.1.4.1)
22
+ net-imap
23
+ net-pop
24
+ net-smtp
25
+ actionmailer (7.0.1)
26
+ actionpack (= 7.0.1)
27
+ actionview (= 7.0.1)
28
+ activejob (= 7.0.1)
29
+ activesupport (= 7.0.1)
27
30
  mail (~> 2.5, >= 2.5.4)
31
+ net-imap
32
+ net-pop
33
+ net-smtp
28
34
  rails-dom-testing (~> 2.0)
29
- actionpack (6.1.4.1)
30
- actionview (= 6.1.4.1)
31
- activesupport (= 6.1.4.1)
32
- rack (~> 2.0, >= 2.0.9)
35
+ actionpack (7.0.1)
36
+ actionview (= 7.0.1)
37
+ activesupport (= 7.0.1)
38
+ rack (~> 2.0, >= 2.2.0)
33
39
  rack-test (>= 0.6.3)
34
40
  rails-dom-testing (~> 2.0)
35
41
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
- actiontext (6.1.4.1)
37
- actionpack (= 6.1.4.1)
38
- activerecord (= 6.1.4.1)
39
- activestorage (= 6.1.4.1)
40
- activesupport (= 6.1.4.1)
42
+ actiontext (7.0.1)
43
+ actionpack (= 7.0.1)
44
+ activerecord (= 7.0.1)
45
+ activestorage (= 7.0.1)
46
+ activesupport (= 7.0.1)
47
+ globalid (>= 0.6.0)
41
48
  nokogiri (>= 1.8.5)
42
- actionview (6.1.4.1)
43
- activesupport (= 6.1.4.1)
49
+ actionview (7.0.1)
50
+ activesupport (= 7.0.1)
44
51
  builder (~> 3.1)
45
52
  erubi (~> 1.4)
46
53
  rails-dom-testing (~> 2.0)
47
54
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
- activejob (6.1.4.1)
49
- activesupport (= 6.1.4.1)
55
+ activejob (7.0.1)
56
+ activesupport (= 7.0.1)
50
57
  globalid (>= 0.3.6)
51
- activemodel (6.1.4.1)
52
- activesupport (= 6.1.4.1)
53
- activerecord (6.1.4.1)
54
- activemodel (= 6.1.4.1)
55
- activesupport (= 6.1.4.1)
56
- activestorage (6.1.4.1)
57
- actionpack (= 6.1.4.1)
58
- activejob (= 6.1.4.1)
59
- activerecord (= 6.1.4.1)
60
- activesupport (= 6.1.4.1)
61
- marcel (~> 1.0.0)
58
+ activemodel (7.0.1)
59
+ activesupport (= 7.0.1)
60
+ activerecord (7.0.1)
61
+ activemodel (= 7.0.1)
62
+ activesupport (= 7.0.1)
63
+ activestorage (7.0.1)
64
+ actionpack (= 7.0.1)
65
+ activejob (= 7.0.1)
66
+ activerecord (= 7.0.1)
67
+ activesupport (= 7.0.1)
68
+ marcel (~> 1.0)
62
69
  mini_mime (>= 1.1.0)
63
- activesupport (6.1.4.1)
70
+ activesupport (7.0.1)
64
71
  concurrent-ruby (~> 1.0, >= 1.0.2)
65
72
  i18n (>= 1.6, < 2)
66
73
  minitest (>= 5.1)
67
74
  tzinfo (~> 2.0)
68
- zeitwerk (~> 2.3)
69
75
  ast (2.4.2)
70
76
  builder (3.2.4)
71
77
  coderay (1.1.3)
72
78
  concurrent-ruby (1.1.9)
73
79
  crass (1.0.6)
74
- diff-lcs (1.4.4)
80
+ diff-lcs (1.5.0)
81
+ digest (3.1.0)
75
82
  erubi (1.10.0)
76
- globalid (0.5.2)
83
+ globalid (1.0.0)
77
84
  activesupport (>= 5.0)
78
85
  i18n (1.8.11)
79
86
  concurrent-ruby (~> 1.0)
80
- loofah (2.12.0)
87
+ io-wait (0.2.1)
88
+ loofah (2.13.0)
81
89
  crass (~> 1.0.2)
82
90
  nokogiri (>= 1.5.9)
83
91
  mail (2.7.1)
@@ -85,14 +93,29 @@ GEM
85
93
  marcel (1.0.2)
86
94
  method_source (1.0.0)
87
95
  mini_mime (1.1.2)
88
- minitest (5.14.4)
96
+ minitest (5.15.0)
97
+ net-imap (0.2.3)
98
+ digest
99
+ net-protocol
100
+ strscan
101
+ net-pop (0.1.1)
102
+ digest
103
+ net-protocol
104
+ timeout
105
+ net-protocol (0.1.2)
106
+ io-wait
107
+ timeout
108
+ net-smtp (0.3.1)
109
+ digest
110
+ net-protocol
111
+ timeout
89
112
  nio4r (2.5.8)
90
- nokogiri (1.12.5-x86_64-darwin)
113
+ nokogiri (1.13.1-x86_64-darwin)
91
114
  racc (~> 1.4)
92
- nokogiri (1.12.5-x86_64-linux)
115
+ nokogiri (1.13.1-x86_64-linux)
93
116
  racc (~> 1.4)
94
117
  parallel (1.21.0)
95
- parser (3.0.2.0)
118
+ parser (3.1.0.0)
96
119
  ast (~> 2.4.1)
97
120
  pry (0.14.1)
98
121
  coderay (~> 1.1)
@@ -101,35 +124,35 @@ GEM
101
124
  rack (2.2.3)
102
125
  rack-test (1.1.0)
103
126
  rack (>= 1.0, < 3)
104
- rails (6.1.4.1)
105
- actioncable (= 6.1.4.1)
106
- actionmailbox (= 6.1.4.1)
107
- actionmailer (= 6.1.4.1)
108
- actionpack (= 6.1.4.1)
109
- actiontext (= 6.1.4.1)
110
- actionview (= 6.1.4.1)
111
- activejob (= 6.1.4.1)
112
- activemodel (= 6.1.4.1)
113
- activerecord (= 6.1.4.1)
114
- activestorage (= 6.1.4.1)
115
- activesupport (= 6.1.4.1)
127
+ rails (7.0.1)
128
+ actioncable (= 7.0.1)
129
+ actionmailbox (= 7.0.1)
130
+ actionmailer (= 7.0.1)
131
+ actionpack (= 7.0.1)
132
+ actiontext (= 7.0.1)
133
+ actionview (= 7.0.1)
134
+ activejob (= 7.0.1)
135
+ activemodel (= 7.0.1)
136
+ activerecord (= 7.0.1)
137
+ activestorage (= 7.0.1)
138
+ activesupport (= 7.0.1)
116
139
  bundler (>= 1.15.0)
117
- railties (= 6.1.4.1)
118
- sprockets-rails (>= 2.0.0)
140
+ railties (= 7.0.1)
119
141
  rails-dom-testing (2.0.3)
120
142
  activesupport (>= 4.2.0)
121
143
  nokogiri (>= 1.6)
122
144
  rails-html-sanitizer (1.4.2)
123
145
  loofah (~> 2.3)
124
- railties (6.1.4.1)
125
- actionpack (= 6.1.4.1)
126
- activesupport (= 6.1.4.1)
146
+ railties (7.0.1)
147
+ actionpack (= 7.0.1)
148
+ activesupport (= 7.0.1)
127
149
  method_source
128
- rake (>= 0.13)
150
+ rake (>= 12.2)
129
151
  thor (~> 1.0)
130
- rainbow (3.0.0)
152
+ zeitwerk (~> 2.5)
153
+ rainbow (3.1.1)
131
154
  rake (13.0.6)
132
- regexp_parser (2.1.1)
155
+ regexp_parser (2.2.0)
133
156
  rexml (3.2.5)
134
157
  rspec (3.10.0)
135
158
  rspec-core (~> 3.10.0)
@@ -137,64 +160,59 @@ GEM
137
160
  rspec-mocks (~> 3.10.0)
138
161
  rspec-core (3.10.1)
139
162
  rspec-support (~> 3.10.0)
140
- rspec-expectations (3.10.1)
163
+ rspec-expectations (3.10.2)
141
164
  diff-lcs (>= 1.2.0, < 2.0)
142
165
  rspec-support (~> 3.10.0)
143
166
  rspec-mocks (3.10.2)
144
167
  diff-lcs (>= 1.2.0, < 2.0)
145
168
  rspec-support (~> 3.10.0)
146
169
  rspec-support (3.10.3)
147
- rubocop (1.17.0)
170
+ rubocop (1.25.0)
148
171
  parallel (~> 1.10)
149
- parser (>= 3.0.0.0)
172
+ parser (>= 3.1.0.0)
150
173
  rainbow (>= 2.2.2, < 4.0)
151
174
  regexp_parser (>= 1.8, < 3.0)
152
175
  rexml
153
- rubocop-ast (>= 1.7.0, < 2.0)
176
+ rubocop-ast (>= 1.15.1, < 2.0)
154
177
  ruby-progressbar (~> 1.7)
155
178
  unicode-display_width (>= 1.4.0, < 3.0)
156
- rubocop-ast (1.13.0)
179
+ rubocop-ast (1.15.1)
157
180
  parser (>= 3.0.1.1)
158
- rubocop-config-umbrellio (1.17.0.53)
159
- rubocop (= 1.17.0)
160
- rubocop-performance (= 1.10.0)
161
- rubocop-rails (= 2.9.1)
162
- rubocop-rake (= 0.5.1)
163
- rubocop-rspec (= 2.2.0)
164
- rubocop-sequel (= 0.2.0)
165
- rubocop-performance (1.10.0)
166
- rubocop (>= 0.90.0, < 2.0)
181
+ rubocop-config-umbrellio (1.25.0.61)
182
+ rubocop (~> 1.25.0)
183
+ rubocop-performance (~> 1.13.0)
184
+ rubocop-rails (~> 2.13.0)
185
+ rubocop-rake (~> 0.6.0)
186
+ rubocop-rspec (~> 2.7.0)
187
+ rubocop-sequel (~> 0.3.3)
188
+ rubocop-performance (1.13.2)
189
+ rubocop (>= 1.7.0, < 2.0)
167
190
  rubocop-ast (>= 0.4.0)
168
- rubocop-rails (2.9.1)
191
+ rubocop-rails (2.13.2)
169
192
  activesupport (>= 4.2.0)
170
193
  rack (>= 1.1)
171
- rubocop (>= 0.90.0, < 2.0)
172
- rubocop-rake (0.5.1)
173
- rubocop
174
- rubocop-rspec (2.2.0)
194
+ rubocop (>= 1.7.0, < 2.0)
195
+ rubocop-rake (0.6.0)
175
196
  rubocop (~> 1.0)
176
- rubocop-ast (>= 1.1.0)
177
- rubocop-sequel (0.2.0)
197
+ rubocop-rspec (2.7.0)
198
+ rubocop (~> 1.19)
199
+ rubocop-sequel (0.3.3)
178
200
  rubocop (~> 1.0)
179
201
  ruby-progressbar (1.11.0)
180
- sprockets (4.0.2)
181
- concurrent-ruby (~> 1.0)
182
- rack (> 1, < 3)
183
- sprockets-rails (3.4.0)
184
- actionpack (>= 5.2)
185
- activesupport (>= 5.2)
186
- sprockets (>= 3.0.0)
187
- thor (1.1.0)
202
+ strscan (3.0.1)
203
+ thor (1.2.1)
204
+ timeout (0.2.0)
188
205
  tzinfo (2.0.4)
189
206
  concurrent-ruby (~> 1.0)
190
207
  unicode-display_width (2.1.0)
191
208
  websocket-driver (0.7.5)
192
209
  websocket-extensions (>= 0.1.0)
193
210
  websocket-extensions (0.1.5)
194
- zeitwerk (2.5.1)
211
+ zeitwerk (2.5.3)
195
212
 
196
213
  PLATFORMS
197
214
  x86_64-darwin-20
215
+ x86_64-darwin-21
198
216
  x86_64-linux
199
217
 
200
218
  DEPENDENCIES
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
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ConfigDefault::Init
4
+ extend self
5
+
6
+ def init_rails_monkey_patch!
7
+ return unless Object.const_defined?(:Rails)
8
+
9
+ Rails::Application.prepend(ConfigDefault::RailsApplicationExtension)
10
+ Rails::Application::Configuration.prepend(ConfigDefault::RailsApplicationConfigurationExtension)
11
+ end
12
+ 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)
@@ -20,7 +20,7 @@ class ConfigDefault::Struct
20
20
 
21
21
  def method_missing(method, *_args)
22
22
  return if @allow_nil
23
- raise StandardError.new("There is no option :#{method} in configuration.")
23
+ raise ArgumentError.new("There is no option :#{method} in configuration.")
24
24
  end
25
25
 
26
26
  def respond_to_missing?(*_args)
@@ -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.3"
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,27 +1,27 @@
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.3
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: 2022-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '6'
27
27
  description: |2
@@ -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
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
- rubygems_version: 3.2.15
76
+ rubygems_version: 3.3.3
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: A simple way to manage default and env configuration in Rails.
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ConfigDefault::RailsMonkeyPatch
4
- extend self
5
-
6
- def call
7
- return unless Object.const_defined?("Rails")
8
- return unless Object.const_defined?("Rails::Application")
9
- return unless Object.const_defined?("Rails::Application::Configuration")
10
-
11
- require "config_default/rails/application_extension"
12
- require "config_default/rails/application/configuration_extension"
13
- end
14
- end