anyway_config 2.6.2 → 2.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +6 -0
- data/lib/.rbnext/2.7/anyway/loaders/yaml.rb +8 -2
- data/lib/.rbnext/3.0/anyway/loaders/yaml.rb +90 -0
- data/lib/anyway/loaders/yaml.rb +8 -2
- data/lib/anyway/version.rb +1 -1
- metadata +8 -7
- /data/sig/{manifest.yml → manifest.yaml} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7cfb06bc950fa9f4c16b771509fc8e88cbe1481ea82a145c2fae80fca80b57b
|
4
|
+
data.tar.gz: fdbd419a8ff57a7fbbb4e887381048e68d830d4927761ec420706e8add146e3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7dd1abbf6411c416571ac67c127b0f0e365c73689d96d094289ab0ede4c494bd56f4246848431a689b2292a2903cea74b918e11569d89423c21e11f2dc3e9ca
|
7
|
+
data.tar.gz: 4d8f2aecbbe6e79314a81d47f4fb92b3dcaba42a656387fbb24dd7c0dc051f3cae0b98de84f797cb48bc3fb9055bf59fd32c128ad4ee979e60eb3a71935a5e5a
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 2.6.4 (2024-04-30)
|
6
|
+
|
7
|
+
- Fix RBS manifest file name (`.yml` -> `.yaml`). ([@carlqt][])
|
8
|
+
|
9
|
+
## 2.6.3 (2024-02-06)
|
10
|
+
|
11
|
+
- Add `permitted_classes` configuration for YAML loaders. ([@palkan][])
|
12
|
+
|
5
13
|
## 2.6.2 (2024-01-08)
|
6
14
|
|
7
15
|
- Fix Ruby 3.3.0 compatibility issues (caused by [Ruby bug](https://bugs.ruby-lang.org/issues/20090)) ([@palkan][])
|
@@ -570,3 +578,4 @@ No we're dependency-free!
|
|
570
578
|
[@inner-whisper]: https://github.com/inner-whisper
|
571
579
|
[@tagirahmad]: https://github.com/tagirahmad
|
572
580
|
[@bessey]: https://github.com/bessey
|
581
|
+
[@carlqt]: https://github.com/carlqt
|
data/README.md
CHANGED
@@ -370,6 +370,12 @@ development:
|
|
370
370
|
|
371
371
|
**NOTE:** You can override the environment name for configuration files via the `ANYWAY_ENV` environment variable or by setting it explicitly in the code: `Anyway::Settings.current_environment = "some_other_env"`.
|
372
372
|
|
373
|
+
You can also configure additional Ruby classes that you want to deserialized from YAML (`permitted_classes` option). For example:
|
374
|
+
|
375
|
+
```ruby
|
376
|
+
Anyway::Loaders::YAML.permitted_classes << Date
|
377
|
+
```
|
378
|
+
|
373
379
|
### Multi-env configuration
|
374
380
|
|
375
381
|
_⚡️ This feature will be turned on by default in the future releases. You can turn it on now via `config.anyway_config.future.use :unwrap_known_environments`._
|
@@ -9,6 +9,12 @@ using Anyway::Ext::Hash
|
|
9
9
|
module Anyway
|
10
10
|
module Loaders
|
11
11
|
class YAML < Base
|
12
|
+
@@permitted_classes = []
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def permitted_classes ; @@permitted_classes; end
|
16
|
+
end
|
17
|
+
|
12
18
|
def call(config_path:, **_options)
|
13
19
|
rel_config_path = relative_config_path(config_path).to_s
|
14
20
|
base_config = trace!(:yml, path: rel_config_path) do
|
@@ -53,9 +59,9 @@ module Anyway
|
|
53
59
|
# the interface when no config file is present.
|
54
60
|
begin
|
55
61
|
if defined?(ERB)
|
56
|
-
::YAML.load(ERB.new(File.read(path)).result, aliases: true) || {}
|
62
|
+
::YAML.load(ERB.new(File.read(path)).result, aliases: true, permitted_classes: self.class.permitted_classes) || {}
|
57
63
|
else
|
58
|
-
::YAML.load_file(path, aliases: true) || {}
|
64
|
+
::YAML.load_file(path, aliases: true, permitted_classes: self.class.permitted_classes) || {}
|
59
65
|
end
|
60
66
|
rescue ArgumentError
|
61
67
|
if defined?(ERB)
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pathname"
|
4
|
+
require "anyway/ext/hash"
|
5
|
+
|
6
|
+
using RubyNext
|
7
|
+
using Anyway::Ext::Hash
|
8
|
+
|
9
|
+
module Anyway
|
10
|
+
module Loaders
|
11
|
+
class YAML < Base
|
12
|
+
@@permitted_classes = []
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def permitted_classes ; @@permitted_classes; end
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(config_path:, **_options)
|
19
|
+
rel_config_path = relative_config_path(config_path).to_s
|
20
|
+
base_config = trace!(:yml, path: rel_config_path) do
|
21
|
+
config = load_base_yml(config_path)
|
22
|
+
environmental?(config) ? config_with_env(config) : config
|
23
|
+
end
|
24
|
+
|
25
|
+
return base_config unless use_local?
|
26
|
+
|
27
|
+
local_path = local_config_path(config_path)
|
28
|
+
local_config = trace!(:yml, path: relative_config_path(local_path).to_s) { load_local_yml(local_path) }
|
29
|
+
Utils.deep_merge!(base_config, local_config)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def environmental?(parsed_yml)
|
35
|
+
# strange, but still possible
|
36
|
+
return true if Settings.default_environmental_key? && parsed_yml.key?(Settings.default_environmental_key)
|
37
|
+
# possible
|
38
|
+
return true if !Settings.future.unwrap_known_environments && Settings.current_environment
|
39
|
+
# for other environments
|
40
|
+
return true if Settings.known_environments&.any? { parsed_yml.key?(_1) }
|
41
|
+
# preferred
|
42
|
+
parsed_yml.key?(Settings.current_environment)
|
43
|
+
end
|
44
|
+
|
45
|
+
def config_with_env(config)
|
46
|
+
env_config = config[Settings.current_environment] || {}
|
47
|
+
return env_config unless Settings.default_environmental_key?
|
48
|
+
|
49
|
+
default_config = config[Settings.default_environmental_key] || {}
|
50
|
+
Utils.deep_merge!(default_config, env_config)
|
51
|
+
end
|
52
|
+
|
53
|
+
def parse_yml(path)
|
54
|
+
return {} unless File.file?(path)
|
55
|
+
require "yaml" unless defined?(::YAML)
|
56
|
+
|
57
|
+
# By default, YAML load will return `false` when the yaml document is
|
58
|
+
# empty. When this occurs, we return an empty hash instead, to match
|
59
|
+
# the interface when no config file is present.
|
60
|
+
begin
|
61
|
+
if defined?(ERB)
|
62
|
+
::YAML.load(ERB.new(File.read(path)).result, aliases: true, permitted_classes: self.class.permitted_classes) || {}
|
63
|
+
else
|
64
|
+
::YAML.load_file(path, aliases: true, permitted_classes: self.class.permitted_classes) || {}
|
65
|
+
end
|
66
|
+
rescue ArgumentError
|
67
|
+
if defined?(ERB)
|
68
|
+
::YAML.load(ERB.new(File.read(path)).result) || {}
|
69
|
+
else
|
70
|
+
::YAML.load_file(path) || {}
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
alias_method :load_base_yml, :parse_yml
|
76
|
+
alias_method :load_local_yml, :parse_yml
|
77
|
+
|
78
|
+
def local_config_path(path)
|
79
|
+
path.sub(".yml", ".local.yml")
|
80
|
+
end
|
81
|
+
|
82
|
+
def relative_config_path(path)
|
83
|
+
Pathname.new(path).then do |path|
|
84
|
+
return path if path.relative?
|
85
|
+
path.relative_path_from(Settings.app_root)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
data/lib/anyway/loaders/yaml.rb
CHANGED
@@ -9,6 +9,12 @@ using Anyway::Ext::Hash
|
|
9
9
|
module Anyway
|
10
10
|
module Loaders
|
11
11
|
class YAML < Base
|
12
|
+
@@permitted_classes = []
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def permitted_classes = @@permitted_classes
|
16
|
+
end
|
17
|
+
|
12
18
|
def call(config_path:, **_options)
|
13
19
|
rel_config_path = relative_config_path(config_path).to_s
|
14
20
|
base_config = trace!(:yml, path: rel_config_path) do
|
@@ -53,9 +59,9 @@ module Anyway
|
|
53
59
|
# the interface when no config file is present.
|
54
60
|
begin
|
55
61
|
if defined?(ERB)
|
56
|
-
::YAML.load(ERB.new(File.read(path)).result, aliases: true) || {}
|
62
|
+
::YAML.load(ERB.new(File.read(path)).result, aliases: true, permitted_classes: self.class.permitted_classes) || {}
|
57
63
|
else
|
58
|
-
::YAML.load_file(path, aliases: true) || {}
|
64
|
+
::YAML.load_file(path, aliases: true, permitted_classes: self.class.permitted_classes) || {}
|
59
65
|
end
|
60
66
|
rescue ArgumentError
|
61
67
|
if defined?(ERB)
|
data/lib/anyway/version.rb
CHANGED
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.6.
|
4
|
+
version: 2.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-next-core
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- lib/.rbnext/3.0/anyway/config.rb
|
133
133
|
- lib/.rbnext/3.0/anyway/loaders.rb
|
134
134
|
- lib/.rbnext/3.0/anyway/loaders/base.rb
|
135
|
+
- lib/.rbnext/3.0/anyway/loaders/yaml.rb
|
135
136
|
- lib/.rbnext/3.0/anyway/tracing.rb
|
136
137
|
- lib/.rbnext/3.1/anyway/config.rb
|
137
138
|
- lib/.rbnext/3.1/anyway/dynamic_config.rb
|
@@ -194,7 +195,7 @@ files:
|
|
194
195
|
- lib/generators/anyway/install/templates/application_config.rb.tt
|
195
196
|
- lib/rails/commands/local_credentials/local_credentials_command.rb
|
196
197
|
- sig/anyway_config.rbs
|
197
|
-
- sig/manifest.
|
198
|
+
- sig/manifest.yaml
|
198
199
|
homepage: http://github.com/palkan/anyway_config
|
199
200
|
licenses:
|
200
201
|
- MIT
|
@@ -205,7 +206,7 @@ metadata:
|
|
205
206
|
homepage_uri: http://github.com/palkan/anyway_config
|
206
207
|
source_code_uri: http://github.com/palkan/anyway_config
|
207
208
|
funding_uri: https://github.com/sponsors/palkan
|
208
|
-
post_install_message:
|
209
|
+
post_install_message:
|
209
210
|
rdoc_options: []
|
210
211
|
require_paths:
|
211
212
|
- lib
|
@@ -220,8 +221,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
221
|
- !ruby/object:Gem::Version
|
221
222
|
version: '0'
|
222
223
|
requirements: []
|
223
|
-
rubygems_version: 3.4.
|
224
|
-
signing_key:
|
224
|
+
rubygems_version: 3.4.19
|
225
|
+
signing_key:
|
225
226
|
specification_version: 4
|
226
227
|
summary: Configuration DSL for Ruby libraries and applications
|
227
228
|
test_files: []
|
File without changes
|