yaml_extend 1.3.3 → 1.3.5
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 +4 -4
- data/.gitattributes +1 -0
- data/README.md +3 -2
- data/lib/yaml_extend/version.rb +1 -1
- data/lib/yaml_extend.rb +4 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03e4778ee1f4118a06fce7dcbc7bbd0a6defae359b04341f5632e1a414c2eb6e
|
4
|
+
data.tar.gz: 49ad4cfd28f6ce2d13aa66ad4c4cafe740a5f110ae1ac79f8c492fd7726c23b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b13ee198ddd926ec4569a826f12ca13229a5b574ccfede3fe4c0bf66eb8f586e6574f2d7ea91e45fc2b0e769c5002215c6b4c7333887a74efe0a37b980762e7
|
7
|
+
data.tar.gz: 20cb5a6bf6831df937dc2d68106250e7a10ead10ddfc1afb5673481afc13974234b2f7cd8144280c00f1e9b81d31992eb3716db7e65ce4cf79dfc03f44ee609b
|
data/.gitattributes
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* text=auto eol=lf
|
data/README.md
CHANGED
@@ -86,7 +86,7 @@ This method works like the original YAML.load_file, by extending it with file in
|
|
86
86
|
Given the following both files are defined:
|
87
87
|
|
88
88
|
```yaml
|
89
|
-
# start.yml
|
89
|
+
# start.erb.yml
|
90
90
|
extends: 'super.yml'
|
91
91
|
data:
|
92
92
|
name: 'Mr. Superman'
|
@@ -110,7 +110,7 @@ data:
|
|
110
110
|
When you then call `ext_load_file`
|
111
111
|
|
112
112
|
```ruby
|
113
|
-
config = YAML.ext_load_file 'start.yml'
|
113
|
+
config = YAML.ext_load_file 'start.erb.yml'
|
114
114
|
```
|
115
115
|
|
116
116
|
the returned YAML value results in
|
@@ -224,6 +224,7 @@ YAML.ext_load_file(yaml_path, inheritance_key='extends', options = {})
|
|
224
224
|
- `:extend_existing_arrays` (Boolean) Set to true to extend existing arrays, instead of overwriting them - DEFAULT: true
|
225
225
|
- `:merge_nil_values` (Boolean) Set to true to merge nil hash values, overwriting a possibly non-nil value - DEFAULT: false
|
226
226
|
- `:merge_debug` (Boolean) Set to true to get console output of merge process for debugging - DEFAULT: false
|
227
|
+
- `:force_erb` (Boolean) Set to true to force ERB processing on all inherited files, even if they do not end with `.erb` - DEFAULT: false
|
227
228
|
|
228
229
|
See also rubydoc at [https://www.rubydoc.info/gems/yaml_extend](https://www.rubydoc.info/gems/yaml_extend)
|
229
230
|
|
data/lib/yaml_extend/version.rb
CHANGED
data/lib/yaml_extend.rb
CHANGED
@@ -67,6 +67,7 @@ module YAML
|
|
67
67
|
# @option options [Boolean] :extend_existing_arrays Set to true to extend existing arrays, instead of overwriting them - DEFAULT: true
|
68
68
|
# @option options [Boolean] :merge_nil_values Set to true to merge nil hash values, overwriting a possibly non-nil value - DEFAULT: false
|
69
69
|
# @option options [Boolean] :merge_debug Set to true to get console output of merge process for debugging - DEFAULT: false
|
70
|
+
# @option options [Boolean] :force_erb Set to true to force ERB processing of the yaml file, even if it does not end with '.erb' or include '.erb.' in the file name - DEFAULT: false
|
70
71
|
#
|
71
72
|
# @param [Boolean] options Fallback for backward compatiblity: extend existing arrays instead of replacing them (deep_merge)
|
72
73
|
# @return [Hash] the resulting yaml config
|
@@ -99,6 +100,7 @@ module YAML
|
|
99
100
|
extend_existing_arrays: true,
|
100
101
|
merge_nil_values: false,
|
101
102
|
merge_debug: false,
|
103
|
+
force_erb: false,
|
102
104
|
}
|
103
105
|
options = default_options.merge options
|
104
106
|
private_class_method
|
@@ -110,7 +112,7 @@ module YAML
|
|
110
112
|
yaml_path = YAML.make_absolute_path yaml_path
|
111
113
|
|
112
114
|
super_config =
|
113
|
-
if yaml_path.match(/(\.erb\.|\.erb$)/)
|
115
|
+
if options[:force_erb] || yaml_path.match(/(\.erb\.|\.erb$)/)
|
114
116
|
if YAML.respond_to? :unsafe_load # backward compatibility for Ruby 3.1 / Psych 4
|
115
117
|
YAML.unsafe_load(ERB.new(File.read(yaml_path)).result)
|
116
118
|
else
|
@@ -180,6 +182,7 @@ module YAML
|
|
180
182
|
# Return the value of the corresponding key
|
181
183
|
# @param key [String|Array]
|
182
184
|
def self.yaml_value_by_key(key, config)
|
185
|
+
return nil if config.nil? # config is nil, if the yaml file is empty
|
183
186
|
return config[key] if key.is_a? String
|
184
187
|
if valid_key_type? key
|
185
188
|
cfg_copy = config.clone
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yaml_extend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthäus Beyrle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deep_merge
|
@@ -74,6 +74,7 @@ executables:
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
+
- ".gitattributes"
|
77
78
|
- ".gitignore"
|
78
79
|
- ".rspec"
|
79
80
|
- ".travis.yml"
|