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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b056650bc04768e6d55177c1125ef048d7f02d4764e8cecdd851f75e07b816c5
4
- data.tar.gz: bc70a195072c63c7af2116b619f8ea5677b7fae0925128f9cfbedb8d216d7d9c
3
+ metadata.gz: 10653bd834aa1d969eae811a6b28678294d9803eb7d5a80c104cedbbb4ce23bc
4
+ data.tar.gz: 37b98892bd8d09f495175b1b7951054d29027490d4a6c3c9f3c8f476125f4b56
5
5
  SHA512:
6
- metadata.gz: 6f3588a3e5a0a07d4102e19ed7d0c87af68f0638037d141df85c4d24c7791743b3fd449fc77a6316d44f602e157297c6560dba9dabc304ee46c36f3ccb8d9155
7
- data.tar.gz: 7ff4beefad210bd1a503a8cfc4563042c53751099441beb04d2ad1680eebad697b87db82e10421c4ca958439bda4c850770729211db8f0f67e3e8a5b6feecc05
6
+ metadata.gz: 666439b434d0c0d29462d4a71489eb59ee899250bb06f58dff732cf422b06b6314f7af6171705e266debfc030d9ccb521c8cbf26b9ea6aeff31d0f0320b075d5
7
+ data.tar.gz: ac940216127d089503b9b515e17d60656a31d33187b0f3ab475162c20b27e7b49a14eb6ecc5305d56939273825af2d9ceefb8389ec4aacdb706362d1aef56681
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017 Matthäus Beyrle
3
+ Copyright (c) 2017-2021 Matthäus J. N. Beyrle
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,8 +1,13 @@
1
1
  # yaml_extend
2
+ ![Gem](https://img.shields.io/gem/v/yaml_extend?color=default&style=plastic&logo=ruby&logoColor=red)
3
+ ![Gem](https://img.shields.io/gem/dt/yaml_extend?color=blue&style=plastic)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-gold.svg?style=plastic&logo=mit)](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 hierachy.
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
- super_config = YAML.load_file(File.open(yaml_path))
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 exteranl caller of YAML.ext_load_file
140
- base_path = File.dirname(caller_locations[2].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}'"
@@ -1,3 +1,3 @@
1
1
  module YamlExtend
2
- VERSION = '1.0.2'.freeze
2
+ VERSION = '1.1.3'.freeze
3
3
  end
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.0.2
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: 2020-12-01 00:00:00.000000000 Z
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.0.8
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