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 +2 -2
- data/lib/local_config.rb +7 -2
- data/test/local_config_test.rb +11 -1
- data/test/test_rails_root/config/no_env_no_hash.yml +3 -0
- metadata +3 -2
data/VERSION.yml
CHANGED
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
|
-
|
12
|
-
|
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
|
data/test/local_config_test.rb
CHANGED
@@ -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
|
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.
|
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-
|
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
|