yaml_configuration 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ tmp/
@@ -4,8 +4,9 @@ module YamlConfiguration
4
4
  combined_configuration = {}
5
5
  config_files.flatten.each do |config_file|
6
6
  loaded_config = load_yaml_config(config_file)
7
- combined_configuration.deep_merge(loaded_config)
7
+ combined_configuration.deep_merge!(loaded_config)
8
8
  end
9
+ puts combined_configuration.inspect
9
10
  Configuration.new(combined_configuration)
10
11
  end
11
12
 
@@ -1,3 +1,3 @@
1
1
  module YamlConfiguration
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -0,0 +1,43 @@
1
+ require_relative '../tests_setup.rb'
2
+ require 'fileutils'
3
+ require 'hash_deep_merge'
4
+
5
+ module YamlConfiguration
6
+ class LoaderTests < MiniTest::Unit::TestCase
7
+ def test_that_the_yaml_configs_get_deep_merged
8
+ config_a = {'user' => {'name' => 'David', 'surname' => 'Santoro', 'middle' => 'Maximillian'}, 'role' => 'developer'}
9
+ config_b = {'user' => {'name' => 'John'}, 'role' => 'artist'}
10
+ config_c = {'user' => {'surname' => 'Locke'}, 'role' => 'messiah'}
11
+
12
+ recreate_directory('tmp')
13
+ create_yaml_config_file(config_a, 'tmp/config_a.yml')
14
+ create_yaml_config_file(config_b, 'tmp/config_b.yml')
15
+ create_yaml_config_file(config_c, 'tmp/config_c.yml')
16
+
17
+ combined_config = Loader.new.load('tmp/config_a', 'tmp/config_b', 'tmp/config_c')
18
+
19
+ assert_equal 'John', combined_config.user.name
20
+ assert_equal 'Locke', combined_config.user.surname
21
+ assert_equal 'messiah', combined_config.role
22
+ assert_equal 'Maximillian', combined_config.user.middle
23
+
24
+ combined_config = Loader.new.load(['tmp/config_a', 'tmp/config_b', 'tmp/config_c'])
25
+
26
+ assert_equal 'John', combined_config.user.name
27
+ end
28
+
29
+ private
30
+ def recreate_directory(directory_path)
31
+ full_path = File.join(File.dirname(__FILE__), '../..',directory_path)
32
+ FileUtils.rm_rf full_path
33
+ FileUtils.mkdir_p full_path
34
+ end
35
+
36
+ def create_yaml_config_file(hash, file_path)
37
+ full_path = File.join(File.dirname(__FILE__),'../..', file_path)
38
+ File.open(full_path, 'w') do |file|
39
+ file.write(hash.to_yaml)
40
+ end
41
+ end
42
+ end
43
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaml_configuration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
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: 2011-12-05 00:00:00.000000000Z
12
+ date: 2011-12-06 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &78671870 !ruby/object:Gem::Requirement
16
+ requirement: &70833570 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *78671870
24
+ version_requirements: *70833570
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: turn
27
- requirement: &78671660 !ruby/object:Gem::Requirement
27
+ requirement: &70833290 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *78671660
35
+ version_requirements: *70833290
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ansi
38
- requirement: &78671450 !ruby/object:Gem::Requirement
38
+ requirement: &70832770 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *78671450
46
+ version_requirements: *70832770
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: hash-deep-merge
49
- requirement: &78671210 !ruby/object:Gem::Requirement
49
+ requirement: &70832280 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *78671210
57
+ version_requirements: *70832280
58
58
  description: Load, merge and provide sensible error messages when using yaml based
59
59
  configuration
60
60
  email:
@@ -72,6 +72,7 @@ files:
72
72
  - lib/yaml_configuration/version.rb
73
73
  - tests/tests_setup.rb
74
74
  - tests/yaml_configuration/configuration_tests.rb
75
+ - tests/yaml_configuration/loader_tests.rb
75
76
  - yaml_configuration.gemspec
76
77
  homepage: http://github.com/soulnafein/yaml_configuration
77
78
  licenses: []