anyway_config 2.0.0.rc1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -1
- data/README.md +4 -4
- data/lib/.rbnext/2.7/anyway/config.rb +10 -0
- data/lib/.rbnext/2.7/anyway/tracing.rb +5 -1
- data/lib/anyway/config.rb +10 -0
- data/lib/anyway/loaders/yaml.rb +11 -7
- data/lib/anyway/rails/loaders/yaml.rb +1 -1
- data/lib/anyway/railtie.rb +1 -0
- data/lib/anyway/tracing.rb +5 -1
- data/lib/anyway/version.rb +1 -1
- data/lib/generators/anyway/install/install_generator.rb +5 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47d019e511f1654a2cad179c162f388df74fef736569f6e09189f6ba48295d11
|
4
|
+
data.tar.gz: 5a7513880f6f8f436491828d405bd09f63e1226beddfa785ecc59f15b8b15a9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fde04c3b432208e9448bf69b198a1bd22f433f0511cb4238f4f725e83cd6fa5af2f19c8fa27638c68aae9b611df883a9be0a32e99686c4e8947a7704c9cc446
|
7
|
+
data.tar.gz: b4c3e05462f1c6de323c614e9a89d185ffcc03d84fff5f8f5e083ae1be93ed8b93d896e6502a8604f4bba74ce46c03378e49aaba9d5f18e53d0a1225605fb54c
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
-
##
|
3
|
+
## 2.0.0 (2020-04-14)
|
4
|
+
|
5
|
+
- Fix double `yield` in tracing for ENV loader. ([@Envek][])
|
4
6
|
|
5
7
|
## 2.0.0.rc1 (2020-03-31)
|
6
8
|
|
@@ -348,3 +350,4 @@ Now works on JRuby 9.1+.
|
|
348
350
|
[@dsalahutdinov]: https://github.com/dsalahutdinov
|
349
351
|
[@charlie-wasp]: https://github.com/charlie-wasp
|
350
352
|
[@jastkand]: https://github.com/jastkand
|
353
|
+
[@Envek]: https://github.com/Envek
|
data/README.md
CHANGED
@@ -18,8 +18,8 @@ For application developers, Anyway Config could be useful to:
|
|
18
18
|
- **Keep configuration organized** and use _named configs_ instead of bloated `.env`/`settings.yml`/whatever.
|
19
19
|
- **Free code of ENV/credentials/secrets dependency** and use configuration classes instead—your code should not rely on configuration data sources.
|
20
20
|
|
21
|
-
**NOTE:** this readme shows documentation for
|
22
|
-
For version 1.x see [1-4-stable branch](https://github.com/palkan/anyway_config/tree/1-4-stable).
|
21
|
+
**NOTE:** this readme shows documentation for 2.x version.
|
22
|
+
For version 1.x see the [1-4-stable branch](https://github.com/palkan/anyway_config/tree/1-4-stable).
|
23
23
|
|
24
24
|
## Table of contents
|
25
25
|
|
@@ -78,7 +78,7 @@ Adding to a gem:
|
|
78
78
|
# my-cool-gem.gemspec
|
79
79
|
Gem::Specification.new do |spec|
|
80
80
|
# ...
|
81
|
-
spec.add_dependency "anyway_config", "2.0.0
|
81
|
+
spec.add_dependency "anyway_config", ">= 2.0.0"
|
82
82
|
# ...
|
83
83
|
end
|
84
84
|
```
|
@@ -87,7 +87,7 @@ Or adding to your project:
|
|
87
87
|
|
88
88
|
```ruby
|
89
89
|
# Gemfile
|
90
|
-
gem "anyway_config", "2.0.0
|
90
|
+
gem "anyway_config", "~> 2.0.0"
|
91
91
|
```
|
92
92
|
|
93
93
|
### Supported Ruby versions
|
@@ -33,6 +33,7 @@ module Anyway # :nodoc:
|
|
33
33
|
clear
|
34
34
|
deconstruct_keys
|
35
35
|
dig
|
36
|
+
dup
|
36
37
|
initialize
|
37
38
|
load
|
38
39
|
load_from_sources
|
@@ -346,6 +347,15 @@ module Anyway # :nodoc:
|
|
346
347
|
values.deep_dup.deep_freeze
|
347
348
|
end
|
348
349
|
|
350
|
+
def dup
|
351
|
+
self.class.allocate.tap do |new_config|
|
352
|
+
%i[config_name env_prefix __trace__].each do |ivar|
|
353
|
+
new_config.instance_variable_set(:"@#{ivar}", send(ivar).dup)
|
354
|
+
end
|
355
|
+
new_config.instance_variable_set(:@values, values.deep_dup)
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
349
359
|
def resolve_config_path(name, env_prefix)
|
350
360
|
Anyway.env.fetch(env_prefix).delete("conf") || Settings.default_config_path.call(name)
|
351
361
|
end
|
@@ -95,6 +95,10 @@ module Anyway
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
+
def dup
|
99
|
+
self.class.new(type, value.dup, source)
|
100
|
+
end
|
101
|
+
|
98
102
|
def pretty_print(q)
|
99
103
|
if trace?
|
100
104
|
q.nest(2) do
|
@@ -179,7 +183,7 @@ module Anyway
|
|
179
183
|
if val.is_a?(Hash)
|
180
184
|
Tracing.current_trace.merge_values(val, **source)
|
181
185
|
else
|
182
|
-
Tracing.current_trace.record_value(
|
186
|
+
Tracing.current_trace.record_value(val, *path, **source)
|
183
187
|
end
|
184
188
|
val
|
185
189
|
end
|
data/lib/anyway/config.rb
CHANGED
@@ -33,6 +33,7 @@ module Anyway # :nodoc:
|
|
33
33
|
clear
|
34
34
|
deconstruct_keys
|
35
35
|
dig
|
36
|
+
dup
|
36
37
|
initialize
|
37
38
|
load
|
38
39
|
load_from_sources
|
@@ -346,6 +347,15 @@ module Anyway # :nodoc:
|
|
346
347
|
values.deep_dup.deep_freeze
|
347
348
|
end
|
348
349
|
|
350
|
+
def dup
|
351
|
+
self.class.allocate.tap do |new_config|
|
352
|
+
%i[config_name env_prefix __trace__].each do |ivar|
|
353
|
+
new_config.instance_variable_set(:"@#{ivar}", send(ivar).dup)
|
354
|
+
end
|
355
|
+
new_config.instance_variable_set(:@values, values.deep_dup)
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
349
359
|
def resolve_config_path(name, env_prefix)
|
350
360
|
Anyway.env.fetch(env_prefix).delete("conf") || Settings.default_config_path.call(name)
|
351
361
|
end
|
data/lib/anyway/loaders/yaml.rb
CHANGED
@@ -10,17 +10,18 @@ module Anyway
|
|
10
10
|
module Loaders
|
11
11
|
class YAML < Base
|
12
12
|
def call(config_path:, **_options)
|
13
|
-
|
14
|
-
config.deep_merge!(load_yml(local_config_path(config_path))) if use_local?
|
15
|
-
end
|
16
|
-
end
|
13
|
+
base_config = trace!(:yml, path: relative_config_path(config_path).to_s) { load_base_yml(config_path) }
|
17
14
|
|
18
|
-
|
15
|
+
return base_config unless use_local?
|
16
|
+
|
17
|
+
local_path = local_config_path(config_path)
|
18
|
+
local_config = trace!(:yml, path: relative_config_path(local_path).to_s) { load_local_yml(local_path) }
|
19
19
|
|
20
|
-
|
21
|
-
trace!(:yml, path: relative_config_path(path).to_s) { parse_yml(path) }
|
20
|
+
base_config.deep_merge!(local_config)
|
22
21
|
end
|
23
22
|
|
23
|
+
private
|
24
|
+
|
24
25
|
def parse_yml(path)
|
25
26
|
return {} unless File.file?(path)
|
26
27
|
require "yaml" unless defined?(::YAML)
|
@@ -31,6 +32,9 @@ module Anyway
|
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
35
|
+
alias load_base_yml parse_yml
|
36
|
+
alias load_local_yml parse_yml
|
37
|
+
|
34
38
|
def local_config_path(path)
|
35
39
|
path.sub(/\.yml/, ".local.yml")
|
36
40
|
end
|
data/lib/anyway/railtie.rb
CHANGED
data/lib/anyway/tracing.rb
CHANGED
@@ -95,6 +95,10 @@ module Anyway
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
+
def dup
|
99
|
+
self.class.new(type, value.dup, source)
|
100
|
+
end
|
101
|
+
|
98
102
|
def pretty_print(q)
|
99
103
|
if trace?
|
100
104
|
q.nest(2) do
|
@@ -179,7 +183,7 @@ module Anyway
|
|
179
183
|
if val.is_a?(Hash)
|
180
184
|
Tracing.current_trace.merge_values(val, **source)
|
181
185
|
else
|
182
|
-
Tracing.current_trace.record_value(
|
186
|
+
Tracing.current_trace.record_value(val, *path, **source)
|
183
187
|
end
|
184
188
|
val
|
185
189
|
end
|
data/lib/anyway/version.rb
CHANGED
@@ -19,15 +19,19 @@ module Anyway
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
# rubocop:disable Layout/HeredocIndentation
|
22
23
|
def add_setup_autoload_to_config
|
24
|
+
maybe_comment_indented = default_configs_path? ? " # " : " "
|
23
25
|
inject_into_file "config/application.rb", after: %r{< Rails::Application\n} do
|
24
26
|
<<-RUBY
|
25
27
|
# Configure the path for configuration classes that should be used before initialization
|
26
28
|
# NOTE: path should be relative to the project root (Rails.root)
|
27
|
-
|
29
|
+
#{maybe_comment_indented}config.anyway_config.autoload_static_config_path = "#{static_config_root}"
|
30
|
+
#{maybe_comment_indented.sub(/\s+$/, "")}
|
28
31
|
RUBY
|
29
32
|
end
|
30
33
|
end
|
34
|
+
# rubocop:enable Layout/HeredocIndentation
|
31
35
|
|
32
36
|
private
|
33
37
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anyway_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-next-core
|
@@ -167,9 +167,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
167
167
|
version: '2.5'
|
168
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
169
|
requirements:
|
170
|
-
- - "
|
170
|
+
- - ">="
|
171
171
|
- !ruby/object:Gem::Version
|
172
|
-
version:
|
172
|
+
version: '0'
|
173
173
|
requirements: []
|
174
174
|
rubygems_version: 3.0.6
|
175
175
|
signing_key:
|