yaml_extend 1.0.2 → 1.1.3
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/LICENSE +1 -1
- data/README.md +7 -2
- data/lib/yaml_extend.rb +14 -3
- data/lib/yaml_extend/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10653bd834aa1d969eae811a6b28678294d9803eb7d5a80c104cedbbb4ce23bc
|
4
|
+
data.tar.gz: 37b98892bd8d09f495175b1b7951054d29027490d4a6c3c9f3c8f476125f4b56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 666439b434d0c0d29462d4a71489eb59ee899250bb06f58dff732cf422b06b6314f7af6171705e266debfc030d9ccb521c8cbf26b9ea6aeff31d0f0320b075d5
|
7
|
+
data.tar.gz: ac940216127d089503b9b515e17d60656a31d33187b0f3ab475162c20b27e7b49a14eb6ecc5305d56939273825af2d9ceefb8389ec4aacdb706362d1aef56681
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
# yaml_extend
|
2
|
+

|
3
|
+

|
4
|
+
[](LICENSE)
|
2
5
|
|
3
|
-
Extends YAML to support file based inheritance.
|
6
|
+
> Extends YAML to support file based inheritance.
|
4
7
|
|
5
|
-
That can be very handy to build a configuration
|
8
|
+
That can be very handy to build a configuration hierarchy.
|
9
|
+
|
10
|
+
Basic support for ERB (embedded ruby) is included and automatically applied when config files are named `*.erb` or `*.erb.*`.
|
6
11
|
|
7
12
|
## Installation
|
8
13
|
|
data/lib/yaml_extend.rb
CHANGED
@@ -105,7 +105,14 @@ module YAML
|
|
105
105
|
total_config = config.clone
|
106
106
|
|
107
107
|
yaml_path = YAML.make_absolute_path yaml_path
|
108
|
-
|
108
|
+
|
109
|
+
super_config =
|
110
|
+
if yaml_path.match(/(\.erb\.|\.erb$)/)
|
111
|
+
YAML.load(ERB.new(File.read(yaml_path)).result)
|
112
|
+
else
|
113
|
+
YAML.load_file(File.open(yaml_path))
|
114
|
+
end
|
115
|
+
|
109
116
|
super_inheritance_files = yaml_value_by_key inheritance_key, super_config
|
110
117
|
unless options[:preserve_inheritance_key]
|
111
118
|
delete_yaml_key inheritance_key, super_config # we don't merge the super inheritance keys into the base yaml
|
@@ -136,8 +143,12 @@ module YAML
|
|
136
143
|
# caller_locations returns the current execution stack
|
137
144
|
# [0] is the call from ext_load_file_recursive,
|
138
145
|
# [1] is inside ext_load_file,
|
139
|
-
# [2] is the
|
140
|
-
base_path =
|
146
|
+
# [2] is the external caller of YAML.ext_load_file
|
147
|
+
base_path = if defined?(caller_locations)
|
148
|
+
File.dirname(caller_locations[2].path)
|
149
|
+
else # Fallback for ruby < 2.1.10
|
150
|
+
File.dirname(caller[2])
|
151
|
+
end
|
141
152
|
return base_path + '/' + file_path if File.exist? base_path + '/' + file_path # relative path from yaml file
|
142
153
|
return Dir.pwd + '/' + file_path if File.exist? Dir.pwd + '/' + file_path # relative path from project
|
143
154
|
error_message = "Can not find absolute path of '#{file_path}'"
|
data/lib/yaml_extend/version.rb
CHANGED
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.
|
4
|
+
version: 1.1.3
|
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:
|
11
|
+
date: 2021-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deep_merge
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
109
|
requirements: []
|
110
|
-
rubygems_version: 3.
|
110
|
+
rubygems_version: 3.1.4
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: Extends YAML to support file based inheritance
|