yamload 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 831e871ab4c0d0dbe55c9465bad82ba229730d87
4
- data.tar.gz: 52dbd15b58e1adc00928261b9490da7761bbc607
3
+ metadata.gz: 7c9c46a3d4a1a0fd85bd0133c105cb9c6775b13b
4
+ data.tar.gz: 6f779db8faf7e9ac393cfeb86d72cbfbc0c33a2b
5
5
  SHA512:
6
- metadata.gz: 36e4c622fabf2326406df940a8caa541268372cbedc3f1b829b3fa3fdbf9b5766d1d8322817cab0fce255c936b3e75df49ed09fd8312d720d1a35229849c47a9
7
- data.tar.gz: ca1f592c5e75d2f1a34aa12385a9b8b16dd333bbc6d1f99d550ddf9a8569ae2475a3000eac9301ccc1354ad2c10ed6b37492b2031a32dea9c4963fc02e722ac4
6
+ metadata.gz: 5c64e82e496305a8df2eec39a47a51dc83d870958070e425f78497374445c1625315410159de46ece460eb3163778e0f71d4bd117628c720a614f32af6fd8ce3
7
+ data.tar.gz: 9b75f9a3f2d2331cde36ba3ff25f90b3968d4f22033148278c0383feb77e3f8573e2c1fb9f6a61d73ecc86e74b91e316dfefcd0906e0bee40f5007ba4011bdb1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.2.0 (2015-02-20)
2
+
3
+ Features:
4
+
5
+ - Add ERB parsing as a prestep for loaded YAML files
6
+
1
7
  ## 0.1.0 (2015-02-17)
2
8
 
3
9
  - use proper semantic versioning (semver.org)
@@ -45,4 +51,4 @@ Features:
45
51
  - load valid yml files defining a hash
46
52
  - conversion of loaded hash to immutable object
47
53
  - default values
48
- - schema validation
54
+ - schema validation
@@ -26,11 +26,16 @@ module Yamload
26
26
 
27
27
  def load
28
28
  fail IOError, "#{@file}.yml could not be found" unless exist?
29
- YAML.load_file(filepath).tap do |content|
29
+ YAML.load(erb_parsed_content).tap do |content|
30
30
  fail IOError, "#{@file}.yml is blank" if content.blank?
31
31
  end
32
32
  end
33
33
 
34
+ def erb_parsed_content
35
+ raw_content = File.read(filepath, encoding: 'bom|utf-8', mode: 'r')
36
+ ERB.new(raw_content).result
37
+ end
38
+
34
39
  def filepath
35
40
  fail IOError, 'No yml files directory specified' if @dir.nil?
36
41
  fail IOError, "#{@dir} is not a valid directory" unless File.directory?(@dir)
@@ -1,3 +1,3 @@
1
1
  module Yamload
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -0,0 +1,2 @@
1
+ ---
2
+ erb_var: <%= 'ERB RAN!' %>
data/spec/loader_spec.rb CHANGED
@@ -31,6 +31,13 @@ describe Yamload::Loader do
31
31
  specify { expect { content }.to raise_error IOError, 'empty.yml is blank' }
32
32
  end
33
33
 
34
+ context 'with a file containing ERB' do
35
+ let(:file) { :erb }
36
+ let(:expected_content) { { "erb_var" => "ERB RAN!" } }
37
+ specify { expect(loader).to exist }
38
+ specify { expect(content).to eq expected_content }
39
+ end
40
+
34
41
  context 'with a file defining an array' do
35
42
  let(:file) { :array }
36
43
  let(:expected_content) { %w(first second third) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yamload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Berardi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-17 00:00:00.000000000 Z
11
+ date: 2015-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anima
@@ -184,6 +184,7 @@ files:
184
184
  - spec/conversion_spec.rb
185
185
  - spec/fixtures/array.yml
186
186
  - spec/fixtures/empty.yml
187
+ - spec/fixtures/erb.yml
187
188
  - spec/fixtures/string.yml
188
189
  - spec/fixtures/test.yml
189
190
  - spec/loader_spec.rb
@@ -217,6 +218,7 @@ test_files:
217
218
  - spec/conversion_spec.rb
218
219
  - spec/fixtures/array.yml
219
220
  - spec/fixtures/empty.yml
221
+ - spec/fixtures/erb.yml
220
222
  - spec/fixtures/string.yml
221
223
  - spec/fixtures/test.yml
222
224
  - spec/loader_spec.rb