yml_reader 0.5 → 0.6

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
  SHA1:
3
- metadata.gz: 78c0e2cd18e1986c515717a6f69a8602a56f9fb2
4
- data.tar.gz: 8e0c0d0c62b59a50ea2a53d9fa7be09f9d6a0db0
3
+ metadata.gz: abcb76b45e302e5d4d1f023f67736d74c61f6b3a
4
+ data.tar.gz: 18bd608be37156033de23f7615de98ab03ba44e3
5
5
  SHA512:
6
- metadata.gz: fb3f04abdb2a255f6cc83c246af06674a541920db578540e525e0dfea8bb568f92c2a1d86707ad2de1ec6e7cc6e1776a5a5641ff3b1ee58ece02324cd00cd25b
7
- data.tar.gz: 8a3bcb918a78219efdb5518130a6f432dce32a535e7e600f1944aad7edb15943d4d5620096d43610ed5411b5cf9f5080160db264ef85d040322c7cec4f25fd15
6
+ metadata.gz: 2973bc536c44157cf875ec8b349f42eaf7d4c16df7ebd71e73e14b04ed5ab08df554bee41c94f8ba0526f7c5da1fd0e28366f644346eb248b389502a0b611d88
7
+ data.tar.gz: 7e7c0621650e06e3e080ff1d386c34217adf1f80f4d867a3c7c8a15b6f51f723298f893d513244f512927e82dff0b006d051ddc7f859bec5809227b9597244ca
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ === Version 0.6 / 2015-12-1
2
+ * Enhancements
3
+ * Added include_yml keyword to allow inclusion of one file within another (thanks Donavan Stanley)
4
+
1
5
  === Version 0.5 / 2014-12-18
2
6
  * Fixes
3
7
  * Added require for ERB to resolve issues when not in bundle (thanks Doug Morgan)
@@ -1,3 +1,3 @@
1
1
  module YmlReader
2
- VERSION = "0.5"
2
+ VERSION = "0.6"
3
3
  end
data/lib/yml_reader.rb CHANGED
@@ -25,7 +25,11 @@ module YmlReader
25
25
  # directory specified by a call to the yml_directory= method.
26
26
  #
27
27
  def load(filename)
28
- @yml = ::YAML.load(ERB.new(File.read("#{yml_directory}/#{filename}")).result)
28
+ @yml = ::YAML.load(ERB.new(File.read("#{yml_directory}/#{filename}")).result(binding))
29
29
  end
30
-
30
+
31
+ def include_yml(filename)
32
+ ERB.new(IO.read("#{yml_directory}/#{filename}")).result
33
+ end
34
+
31
35
  end
@@ -0,0 +1,2 @@
1
+ 'include_1':
2
+ 'key_1': 'Value 1'
@@ -0,0 +1,4 @@
1
+ ---
2
+ <%= include_yml("include1.yml") %>
3
+ 'section_1':
4
+ 'foo': 'bar'
@@ -4,6 +4,9 @@ require 'yaml'
4
4
  module MyModule
5
5
  extend YmlReader
6
6
 
7
+ def self.data
8
+ @yml
9
+ end
7
10
  def self.default_directory
8
11
  'default_directory'
9
12
  end
@@ -25,4 +28,15 @@ describe YmlReader do
25
28
  end
26
29
  end
27
30
 
31
+ context 'when including files' do
32
+ before(:each) do
33
+ MyModule.yml_directory = File.expand_path('data', File.dirname(__FILE__))
34
+ end
35
+
36
+ it 'should load data from included yaml' do
37
+ MyModule.load 'with_includes.yml'
38
+ MyModule.data['include_1']['key_1'].should == 'Value 1'
39
+ end
40
+ end
41
+
28
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yml_reader
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.5'
4
+ version: '0.6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey S. Morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-18 00:00:00.000000000 Z
11
+ date: 2015-12-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Sets a directory and reads yml files
14
14
  email:
@@ -30,6 +30,8 @@ files:
30
30
  - lib/yml_reader.rb
31
31
  - lib/yml_reader/version.rb
32
32
  - spec/spec_helper.rb
33
+ - spec/yml_reader/data/include1.yml
34
+ - spec/yml_reader/data/with_includes.yml
33
35
  - spec/yml_reader/yml_reader_spec.rb
34
36
  - yml_reader.gemspec
35
37
  homepage: http://github.com/cheezy/yml_reader
@@ -57,4 +59,6 @@ specification_version: 4
57
59
  summary: Sets a directory and reads yml files
58
60
  test_files:
59
61
  - spec/spec_helper.rb
62
+ - spec/yml_reader/data/include1.yml
63
+ - spec/yml_reader/data/with_includes.yml
60
64
  - spec/yml_reader/yml_reader_spec.rb