anyway_config 2.0.0.rc1 → 2.0.0

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
  SHA256:
3
- metadata.gz: 0c4661661a2d8cbce7e35a4eef45520a290855af228b1d20d69367708b11be3f
4
- data.tar.gz: 97f07abb3e194f490069d6dc1ef7076a88f3775f5b06a3cc99d15314da845c54
3
+ metadata.gz: 47d019e511f1654a2cad179c162f388df74fef736569f6e09189f6ba48295d11
4
+ data.tar.gz: 5a7513880f6f8f436491828d405bd09f63e1226beddfa785ecc59f15b8b15a9d
5
5
  SHA512:
6
- metadata.gz: 9897240812d5ae7522b99c0d4ac2ec1c3e2ec5759ef481ff3db6d9fbeb1c46312a895ed64fd94fc6b3c1a416a3ccee9325458c1aeacd0ff7dbc9a10593fabf89
7
- data.tar.gz: c590c11acb69e99ff0ada09fa7ebb4ae44f777da626f2f9dd053935d9d201fa6b3d6296642271e7d56260b9258d0baca65ade78fd10c9397e5205a03d8551b1a
6
+ metadata.gz: 9fde04c3b432208e9448bf69b198a1bd22f433f0511cb4238f4f725e83cd6fa5af2f19c8fa27638c68aae9b611df883a9be0a32e99686c4e8947a7704c9cc446
7
+ data.tar.gz: b4c3e05462f1c6de323c614e9a89d185ffcc03d84fff5f8f5e083ae1be93ed8b93d896e6502a8604f4bba74ce46c03378e49aaba9d5f18e53d0a1225605fb54c
data/CHANGELOG.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Change log
2
2
 
3
- ## master
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 the upcoming 2.0 version (`2.0.0.rc1` is available on RubyGems).
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.rc1"
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.rc1"
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(yield, *path, **source)
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
@@ -10,17 +10,18 @@ module Anyway
10
10
  module Loaders
11
11
  class YAML < Base
12
12
  def call(config_path:, **_options)
13
- load_yml(config_path).tap do |config|
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
- private
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
- def load_yml(path)
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
@@ -4,7 +4,7 @@ module Anyway
4
4
  module Rails
5
5
  module Loaders
6
6
  class YAML < Anyway::Loaders::YAML
7
- def parse_yml(*)
7
+ def load_base_yml(*)
8
8
  super[::Rails.env] || {}
9
9
  end
10
10
 
@@ -8,6 +8,7 @@ module Anyway # :nodoc:
8
8
  config.anyway_config = Anyway::Settings
9
9
 
10
10
  ActiveSupport.on_load(:before_configuration) do
11
+ next if ::Rails.application.initialized?
11
12
  config.anyway_config.autoload_static_config_path = DEFAULT_CONFIGS_PATH
12
13
  end
13
14
 
@@ -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(yield, *path, **source)
186
+ Tracing.current_trace.record_value(val, *path, **source)
183
187
  end
184
188
  val
185
189
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Anyway # :nodoc:
4
- VERSION = "2.0.0.rc1"
4
+ VERSION = "2.0.0"
5
5
  end
@@ -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
- #{default_configs_path? ? "# " : ""}config.anyway_config.autoload_static_config_path = "#{static_config_root}"
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.rc1
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-03-31 00:00:00.000000000 Z
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: 1.3.1
172
+ version: '0'
173
173
  requirements: []
174
174
  rubygems_version: 3.0.6
175
175
  signing_key: