yamload 0.1.0 → 0.2.0
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/CHANGELOG.md +7 -1
- data/lib/yamload/loading/yaml.rb +6 -1
- data/lib/yamload/version.rb +1 -1
- data/spec/fixtures/erb.yml +2 -0
- data/spec/loader_spec.rb +7 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c9c46a3d4a1a0fd85bd0133c105cb9c6775b13b
|
4
|
+
data.tar.gz: 6f779db8faf7e9ac393cfeb86d72cbfbc0c33a2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/yamload/loading/yaml.rb
CHANGED
@@ -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.
|
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)
|
data/lib/yamload/version.rb
CHANGED
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.
|
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-
|
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
|