webmat-local_config 0.1.1 → 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.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :minor: 1
3
- :patch: 1
2
+ :minor: 2
3
+ :patch: 0
4
4
  :major: 0
data/lib/local_config.rb CHANGED
@@ -8,7 +8,12 @@ module LocalConfig
8
8
  shared_config_file = "#{RAILS_ROOT}/config/#{name}.yml"
9
9
  config_file = File.exists?(personal_config_file) ? personal_config_file : shared_config_file
10
10
 
11
- config = HashWithIndifferentAccess.new YAML.load(File.read(config_file))
12
- environment ? config[RAILS_ENV] : config
11
+ yaml = YAML.load(File.read(config_file))
12
+ if yaml.is_a? Hash
13
+ config = HashWithIndifferentAccess.new yaml
14
+ environment ? config[RAILS_ENV] : config
15
+ else
16
+ yaml
17
+ end
13
18
  end
14
19
  end
@@ -41,13 +41,23 @@ class LocalConfigTest < Test::Unit::TestCase
41
41
  end
42
42
  end
43
43
 
44
+ context "reading no_env_ho_hash.yml which contains an array rather than a hash" do
45
+ setup do
46
+ @config = LocalConfig.load_config('no_env_no_hash', :environment => false)
47
+ end
48
+
49
+ should "load the array as is" do
50
+ assert_equal ['string 1 of the array', 'another string'], @config, @config.inspect
51
+ end
52
+ end
53
+
44
54
  context "reading no_env.yml" do
45
55
  setup do
46
56
  @config = LocalConfig.load_config('no_env', :environment => false)
47
57
  end
48
58
 
49
59
  should "return the values of the .yml file" do
50
- assert_equal 'value', @config[:param]
60
+ assert_equal 'value', @config[:param], @config.inspect
51
61
  end
52
62
  end
53
63
  end
@@ -0,0 +1,3 @@
1
+ ---
2
+ - string 1 of the array
3
+ - another string
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmat-local_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathieu Martin
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-04 00:00:00 -07:00
12
+ date: 2009-06-03 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -31,6 +31,7 @@ files:
31
31
  - test/test_rails_root
32
32
  - test/test_rails_root/config
33
33
  - test/test_rails_root/config/no_env.yml
34
+ - test/test_rails_root/config/no_env_no_hash.yml
34
35
  - test/test_rails_root/config/with_local.local.yml
35
36
  - test/test_rails_root/config/with_local.yml
36
37
  - test/test_rails_root/config/without_local.yml