dot_hash 0.4.0 → 0.5.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.
@@ -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.load_file(file)
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)
@@ -1,3 +1,3 @@
1
1
  module DotHash
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/lib/dot_hash.rb CHANGED
@@ -2,6 +2,7 @@ $:.push File.expand_path('../', __FILE__)
2
2
 
3
3
  require 'yaml'
4
4
  require 'json'
5
+ require 'erb'
5
6
  require 'dot_hash/properties'
6
7
  require 'dot_hash/hash_to_properties'
7
8
  require 'dot_hash/hash_loader'
@@ -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
@@ -0,0 +1,4 @@
1
+ hero:
2
+ name: Eden
3
+ <%= "power" %>: 100
4
+ location: <%= TESTS_PATH %>
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.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-03 00:00:00.000000000 Z
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: -1993425773159925620
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: -1993425773159925620
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