dot_hash 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dot_hash/hash_loader.rb +6 -2
- data/lib/dot_hash/version.rb +1 -1
- data/lib/dot_hash.rb +1 -0
- data/test/dot_hash/hash_loader_test.rb +10 -1
- data/test/fixtures/config3.yaml.erb +4 -0
- metadata +6 -4
data/lib/dot_hash/hash_loader.rb
CHANGED
@@ -37,8 +37,12 @@ module DotHash
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def get_hash_from_file(file)
|
40
|
-
return {} unless file =~ /\.(yaml|yml)
|
41
|
-
YAML.
|
40
|
+
return {} unless file =~ /\.(yaml|yml)(\.erb)?$/
|
41
|
+
YAML.load load_erb(file)
|
42
|
+
end
|
43
|
+
|
44
|
+
def load_erb(file)
|
45
|
+
ERB.new(File.read(file)).result
|
42
46
|
end
|
43
47
|
|
44
48
|
def get_hash_from_directory(directory)
|
data/lib/dot_hash/version.rb
CHANGED
data/lib/dot_hash.rb
CHANGED
@@ -44,7 +44,16 @@ module DotHash
|
|
44
44
|
|
45
45
|
loader.load.must_equal({
|
46
46
|
"default"=>{"attr"=>{"speed"=>10, "power"=>11}},
|
47
|
-
"rogue"=>{"attr"=>{"speed"=>25, "power"=>11}}
|
47
|
+
"rogue"=>{"attr"=>{"speed"=>25, "power"=>11}},
|
48
|
+
"hero"=>{"name"=>"Eden", "power"=>100, "location"=>TESTS_PATH}
|
49
|
+
})
|
50
|
+
end
|
51
|
+
|
52
|
+
it "loads ERB files" do
|
53
|
+
loader = HashLoader.new fixtures_path("config3.yaml.erb")
|
54
|
+
|
55
|
+
loader.load.must_equal({
|
56
|
+
"hero"=>{"name"=>"Eden", "power"=>100, "location"=>TESTS_PATH}
|
48
57
|
})
|
49
58
|
end
|
50
59
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dot_hash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- test/dot_hash/properties_test.rb
|
53
53
|
- test/dot_hash/settings_test.rb
|
54
54
|
- test/fixtures/config.yaml.example
|
55
|
+
- test/fixtures/config3.yaml.erb
|
55
56
|
- test/fixtures/configs1.yaml
|
56
57
|
- test/fixtures/configs2.yaml
|
57
58
|
- test/test_helper.rb
|
@@ -69,7 +70,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
70
|
version: '0'
|
70
71
|
segments:
|
71
72
|
- 0
|
72
|
-
hash:
|
73
|
+
hash: 4189611218546110139
|
73
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
75
|
none: false
|
75
76
|
requirements:
|
@@ -78,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
79
|
version: '0'
|
79
80
|
segments:
|
80
81
|
- 0
|
81
|
-
hash:
|
82
|
+
hash: 4189611218546110139
|
82
83
|
requirements: []
|
83
84
|
rubyforge_project:
|
84
85
|
rubygems_version: 1.8.24
|
@@ -91,6 +92,7 @@ test_files:
|
|
91
92
|
- test/dot_hash/properties_test.rb
|
92
93
|
- test/dot_hash/settings_test.rb
|
93
94
|
- test/fixtures/config.yaml.example
|
95
|
+
- test/fixtures/config3.yaml.erb
|
94
96
|
- test/fixtures/configs1.yaml
|
95
97
|
- test/fixtures/configs2.yaml
|
96
98
|
- test/test_helper.rb
|