yaml_extend 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yaml_extend/version.rb +1 -1
- data/lib/yaml_extend.rb +34 -25
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec1808b7abe4ba5c1873c8936f54f3e046b8b8e0d95fccc224012bec384d6e29
|
4
|
+
data.tar.gz: 4c5193ab9b82cf6c4c75e8bbbf6f22ed86548aa219e4fc7c6d2693c531906e9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fd78eca7e2fccc281470237a99660cd7a20115789d2d2ee735167b9f62920c57b3240950d0ecceb472e39a4af9248298e5f13d0ea2b8db380fa5e50780a9a71
|
7
|
+
data.tar.gz: 7002a22e0128f7a8f255a3d0d56e66bf09d084f5b0abdf0d49844e49c93ada8fd747f03b1df7950dd731b40aca6b6ff6e496034239b3f74324ba2b495e998500
|
data/lib/yaml_extend/version.rb
CHANGED
data/lib/yaml_extend.rb
CHANGED
@@ -15,15 +15,15 @@ module YAML
|
|
15
15
|
@@ext_load_key = nil
|
16
16
|
|
17
17
|
DEEP_MERGE_OPTIONS = [
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
18
|
+
:preserve_unmergeables,
|
19
|
+
:knockout_prefix,
|
20
|
+
:overwrite_arrays,
|
21
|
+
:sort_merged_arrays,
|
22
|
+
:unpack_arrays,
|
23
|
+
:merge_hash_arrays,
|
24
|
+
:extend_existing_arrays,
|
25
|
+
:merge_nil_values,
|
26
|
+
:merge_debug,
|
27
27
|
]
|
28
28
|
|
29
29
|
#
|
@@ -86,19 +86,19 @@ module YAML
|
|
86
86
|
yaml_path = yaml_path.to_s
|
87
87
|
# backward compatibility to 1.0.1
|
88
88
|
if options == true || options == false
|
89
|
-
options = {extend_existing_arrays: options}
|
89
|
+
options = { extend_existing_arrays: options }
|
90
90
|
end
|
91
91
|
default_options = {
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
92
|
+
preserve_inheritance_key: false,
|
93
|
+
preserve_unmergeables: false,
|
94
|
+
knockout_prefix: nil,
|
95
|
+
overwrite_arrays: false,
|
96
|
+
sort_merged_arrays: false,
|
97
|
+
unpack_arrays: nil,
|
98
|
+
merge_hash_arrays: false,
|
99
|
+
extend_existing_arrays: true,
|
100
|
+
merge_nil_values: false,
|
101
|
+
merge_debug: false,
|
102
102
|
}
|
103
103
|
options = default_options.merge options
|
104
104
|
private_class_method
|
@@ -111,9 +111,17 @@ module YAML
|
|
111
111
|
|
112
112
|
super_config =
|
113
113
|
if yaml_path.match(/(\.erb\.|\.erb$)/)
|
114
|
-
YAML.unsafe_load
|
114
|
+
if YAML.respond_to? :unsafe_load # backward compatibility for Ruby 3.1 / Psych 4
|
115
|
+
YAML.unsafe_load(ERB.new(File.read(yaml_path)).result)
|
116
|
+
else
|
117
|
+
YAML.load(ERB.new(File.read(yaml_path)).result)
|
118
|
+
end
|
115
119
|
else
|
116
|
-
YAML.unsafe_load_file
|
120
|
+
if YAML.respond_to? :unsafe_load_file # backward compatibility for Ruby 3.1 / Psych 4
|
121
|
+
YAML.unsafe_load_file(File.open(yaml_path))
|
122
|
+
else
|
123
|
+
YAML.load_file(File.open(yaml_path))
|
124
|
+
end
|
117
125
|
end
|
118
126
|
|
119
127
|
super_inheritance_files = yaml_value_by_key inheritance_key, super_config
|
@@ -149,7 +157,8 @@ module YAML
|
|
149
157
|
# [2] is the external caller of YAML.ext_load_file
|
150
158
|
base_path = if defined?(caller_locations)
|
151
159
|
File.dirname(caller_locations[2].path)
|
152
|
-
else
|
160
|
+
else
|
161
|
+
# Fallback for ruby < 2.1.10
|
153
162
|
File.dirname(caller[2])
|
154
163
|
end
|
155
164
|
return base_path + '/' + file_path if File.exist? base_path + '/' + file_path # relative path from yaml file
|
@@ -165,7 +174,7 @@ module YAML
|
|
165
174
|
def self.absolute_path?(path)
|
166
175
|
private_class_method
|
167
176
|
path.start_with?('/') || # unix like
|
168
|
-
|
177
|
+
(path.length >= 3 && path[1] == ':') # ms windows
|
169
178
|
end
|
170
179
|
|
171
180
|
# Return the value of the corresponding key
|
@@ -187,7 +196,7 @@ module YAML
|
|
187
196
|
|
188
197
|
def self.valid_key_type?(key)
|
189
198
|
key.is_a?(Array) || key.is_a?(String) ||
|
190
|
-
|
199
|
+
raise(InvalidKeyTypeError, "Invalid key of type '#{key.class.name}'. Valid types are String and Array.")
|
191
200
|
end
|
192
201
|
|
193
202
|
def self.delete_yaml_key(key, config)
|
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.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthäus Beyrle
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deep_merge
|