yaml_pack 0.0.1.beta → 0.0.2.alpha
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/yaml_pack.rb +12 -1
- data/spec/fixtures/yaml_pack/include_file.yml +1 -0
- data/spec/yaml_pack/yaml_pack_spec.rb +9 -0
- metadata +6 -4
data/lib/yaml_pack.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'core_ext/hash'
|
2
2
|
|
3
3
|
class YamlPack
|
4
|
-
VERSION = "0.0.
|
4
|
+
VERSION = "0.0.2.alpha"
|
5
5
|
|
6
6
|
KEY_CONVERTERS = {
|
7
7
|
:symbolize => Proc.new{|key, previous_keys| key.respond_to?(:to_sym) ? key.to_sym : key }
|
@@ -39,6 +39,17 @@ class YamlPack
|
|
39
39
|
hsh
|
40
40
|
end
|
41
41
|
|
42
|
+
# Include the contents of given file into yaml template.
|
43
|
+
# Use this inside your yaml-file.
|
44
|
+
#
|
45
|
+
# <%= include_file('/path/to/file.yml') %>
|
46
|
+
#
|
47
|
+
# DEBT: extract into own module/class
|
48
|
+
#
|
49
|
+
def include_file(file_path)
|
50
|
+
File.read(file_path)
|
51
|
+
end
|
52
|
+
|
42
53
|
def content(file_path)
|
43
54
|
body = File.read(file_path) || ""
|
44
55
|
[header, body].join("\n")
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= include_file("spec/fixtures/yaml_pack/names.yml") %>
|
@@ -57,6 +57,15 @@ describe YamlPack do
|
|
57
57
|
result['countries']['ch']['name'].should == 'Schweiz'
|
58
58
|
end
|
59
59
|
|
60
|
+
it "#include_file properly includes files" do
|
61
|
+
files = [
|
62
|
+
'spec/fixtures/yaml_pack/include_file.yml'
|
63
|
+
]
|
64
|
+
|
65
|
+
result = YamlPack.new(files).load_deep_merged
|
66
|
+
result['countries']['ch']['name'].should == 'Switzerland'
|
67
|
+
end
|
68
|
+
|
60
69
|
it "replicate nesting of subfolders into resulting hash" do
|
61
70
|
files = [
|
62
71
|
'spec/fixtures/yaml_pack/names.yml',
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yaml_pack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2.alpha
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70343591986120 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70343591986120
|
25
25
|
description: ! "\n YamlPack is a small framework for writing large and complex
|
26
26
|
configuration files in yml.\n It supports nesting and merging merging yaml files.\n
|
27
27
|
\ "
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- spec/fixtures/.DS_Store
|
42
42
|
- spec/fixtures/yaml_pack/countries/sweden.yml
|
43
43
|
- spec/fixtures/yaml_pack/empty.yml
|
44
|
+
- spec/fixtures/yaml_pack/include_file.yml
|
44
45
|
- spec/fixtures/yaml_pack/names.yml
|
45
46
|
- spec/fixtures/yaml_pack/names_german.yml
|
46
47
|
- spec/fixtures/yaml_pack/population.yml
|
@@ -75,6 +76,7 @@ test_files:
|
|
75
76
|
- spec/fixtures/.DS_Store
|
76
77
|
- spec/fixtures/yaml_pack/countries/sweden.yml
|
77
78
|
- spec/fixtures/yaml_pack/empty.yml
|
79
|
+
- spec/fixtures/yaml_pack/include_file.yml
|
78
80
|
- spec/fixtures/yaml_pack/names.yml
|
79
81
|
- spec/fixtures/yaml_pack/names_german.yml
|
80
82
|
- spec/fixtures/yaml_pack/population.yml
|