anyway_config 2.0.1 → 2.0.6

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.
@@ -55,9 +55,7 @@ module Anyway
55
55
  registry.each(&block)
56
56
  end
57
57
 
58
- def freeze
59
- registry.freeze
60
- end
58
+ def freeze() = registry.freeze
61
59
 
62
60
  private
63
61
 
@@ -15,9 +15,7 @@ module Anyway
15
15
  @local = local
16
16
  end
17
17
 
18
- def use_local?
19
- @local == true
20
- end
18
+ def use_local?() = @local == true
21
19
  end
22
20
  end
23
21
  end
@@ -26,7 +26,7 @@ module Anyway
26
26
  return {} unless File.file?(path)
27
27
  require "yaml" unless defined?(::YAML)
28
28
  if defined?(ERB)
29
- ::YAML.safe_load(ERB.new(File.read(path)).result, [], [], true)
29
+ ::YAML.load(ERB.new(File.read(path)).result) # rubocop:disable Security/YAMLLoad
30
30
  else
31
31
  ::YAML.load_file(path)
32
32
  end
@@ -10,11 +10,9 @@ end
10
10
  module Anyway
11
11
  class Settings
12
12
  class << self
13
- attr_reader :autoload_static_config_path
13
+ attr_reader :autoload_static_config_path, :autoloader
14
14
 
15
15
  if defined?(::Zeitwerk)
16
- attr_reader :autoloader
17
-
18
16
  def autoload_static_config_path=(val)
19
17
  raise "Cannot setup autoloader after application has been initialized" if ::Rails.application.initialized?
20
18
 
@@ -40,11 +38,15 @@ module Anyway
40
38
  else
41
39
  def autoload_static_config_path=(val)
42
40
  if autoload_static_config_path
43
- ActiveSupport::Dependencies.autoload_paths.delete(::Rails.root.join(autoload_static_config_path).to_s)
41
+ old_path = ::Rails.root.join(autoload_static_config_path).to_s
42
+ ActiveSupport::Dependencies.autoload_paths.delete(old_path)
43
+ ::Rails.application.config.eager_load_paths.delete(old_path)
44
44
  end
45
45
 
46
46
  @autoload_static_config_path = val
47
- ActiveSupport::Dependencies.autoload_paths << ::Rails.root.join(val)
47
+ new_path = ::Rails.root.join(val).to_s
48
+ ActiveSupport::Dependencies.autoload_paths << new_path
49
+ ::Rails.application.config.eager_load_paths << new_path
48
50
  end
49
51
 
50
52
  def cleanup_autoload_paths
@@ -7,11 +7,15 @@ module Anyway # :nodoc:
7
7
  # Add settings to Rails config
8
8
  config.anyway_config = Anyway::Settings
9
9
 
10
- ActiveSupport.on_load(:before_configuration) do
10
+ config.before_configuration do
11
11
  next if ::Rails.application.initialized?
12
12
  config.anyway_config.autoload_static_config_path = DEFAULT_CONFIGS_PATH
13
13
  end
14
14
 
15
+ config.before_eager_load do
16
+ Anyway::Settings.autoloader&.eager_load
17
+ end
18
+
15
19
  # Remove `autoload_static_config_path` from Rails `autoload_paths`
16
20
  # since we use our own autoloading mechanism
17
21
  initializer "anyway_config.cleanup_autoload" do
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "anyway/testing/helpers"
4
4
 
5
- if defined?(RSpec)
5
+ if defined?(RSpec::Core)
6
6
  RSpec.configure do |config|
7
7
  config.include(
8
8
  Anyway::Testing::Helpers,
@@ -13,9 +13,7 @@ module Anyway
13
13
  end
14
14
 
15
15
  refine Thread::Backtrace::Location do
16
- def path_lineno
17
- "#{path}:#{lineno}"
18
- end
16
+ def path_lineno() = "#{path}:#{lineno}"
19
17
  end
20
18
  end)
21
19
 
@@ -34,13 +32,14 @@ module Anyway
34
32
  value.dig(...)
35
33
  end
36
34
 
37
- def record_value(val, *path, key, **opts)
38
- trace =
39
- if val.is_a?(Hash)
40
- Trace.new.tap { _1.merge_values(val, **opts) }
41
- else
42
- Trace.new(:value, val, **opts)
43
- end
35
+ def record_value(val, *path, **opts)
36
+ key = path.pop
37
+ if val.is_a?(Hash)
38
+ Trace.new.tap { _1.merge_values(val, **opts) }
39
+ else
40
+ Trace.new(:value, val, **opts)
41
+ end => trace
42
+
44
43
  target_trace = path.empty? ? self : value.dig(*path)
45
44
  target_trace.value[key.to_s] = trace
46
45
 
@@ -79,13 +78,9 @@ module Anyway
79
78
  value.keep_if(...)
80
79
  end
81
80
 
82
- def clear
83
- value.clear
84
- end
81
+ def clear() = value.clear
85
82
 
86
- def trace?
87
- type == :trace
88
- end
83
+ def trace?() = type == :trace
89
84
 
90
85
  def to_h
91
86
  if trace?
@@ -95,9 +90,7 @@ module Anyway
95
90
  end
96
91
  end
97
92
 
98
- def dup
99
- self.class.new(type, value.dup, source)
100
- end
93
+ def dup() = self.class.new(type, value.dup, **source)
101
94
 
102
95
  def pretty_print(q)
103
96
  if trace?
@@ -146,9 +139,7 @@ module Anyway
146
139
  (Thread.current[:__anyway__trace_stack__] ||= [])
147
140
  end
148
141
 
149
- def current_trace
150
- trace_stack.last
151
- end
142
+ def current_trace() = trace_stack.last
152
143
 
153
144
  alias tracing? current_trace
154
145
 
@@ -178,12 +169,11 @@ module Anyway
178
169
 
179
170
  def trace!(type, *path, **opts)
180
171
  return yield unless Tracing.tracing?
181
- source = {type: type}.merge(opts)
182
172
  val = yield
183
173
  if val.is_a?(Hash)
184
- Tracing.current_trace.merge_values(val, **source)
174
+ Tracing.current_trace.merge_values(val, type: type, **opts)
185
175
  else
186
- Tracing.current_trace.record_value(val, *path, **source)
176
+ Tracing.current_trace.record_value(val, *path, type: type, **opts)
187
177
  end
188
178
  val
189
179
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Anyway # :nodoc:
4
- VERSION = "2.0.1"
4
+ VERSION = "2.0.6"
5
5
  end
@@ -3,7 +3,7 @@
3
3
  require "ruby-next"
4
4
 
5
5
  require "ruby-next/language/setup"
6
- RubyNext::Language.setup_gem_load_path
6
+ RubyNext::Language.setup_gem_load_path(transpile: true)
7
7
 
8
8
  require "anyway/version"
9
9
 
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.1
4
+ version: 2.0.6
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-04-15 00:00:00.000000000 Z
11
+ date: 2020-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-next-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.1
19
+ version: 0.8.0
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
- version: 0.5.1
26
+ version: 0.8.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ammeter
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '0.5'
89
+ version: '0.8'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '0.5'
96
+ version: '0.8'
97
97
  description: "\n Configuration DSL for Ruby libraries and applications.\n Allows
98
98
  you to easily follow the twelve-factor application principles (https://12factor.net/config).\n
99
99
  \ "
@@ -110,6 +110,10 @@ files:
110
110
  - lib/.rbnext/2.7/anyway/config.rb
111
111
  - lib/.rbnext/2.7/anyway/option_parser_builder.rb
112
112
  - lib/.rbnext/2.7/anyway/tracing.rb
113
+ - lib/.rbnext/2.8/anyway/config.rb
114
+ - lib/.rbnext/2.8/anyway/loaders.rb
115
+ - lib/.rbnext/2.8/anyway/loaders/base.rb
116
+ - lib/.rbnext/2.8/anyway/tracing.rb
113
117
  - lib/anyway.rb
114
118
  - lib/anyway/auto_cast.rb
115
119
  - lib/anyway/config.rb