configa 0.0.8 → 0.0.9
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/lib/configa.rb +9 -1
- data/lib/configa/version.rb +1 -1
- data/spec/configa/configa_spec.rb +9 -0
- metadata +3 -3
data/lib/configa.rb
CHANGED
@@ -19,7 +19,14 @@ module Configa
|
|
19
19
|
@yamls = {}
|
20
20
|
@yaml = {}
|
21
21
|
|
22
|
-
|
22
|
+
if opts[:env]
|
23
|
+
fn = File.join(@base_dir, opts[:env].to_s + @base_extname)
|
24
|
+
if File.exist?(fn)
|
25
|
+
@default_env = opts[:env]
|
26
|
+
else
|
27
|
+
puts "Configa WARNING: can't find #{fn}, using base configuration"
|
28
|
+
end
|
29
|
+
end
|
23
30
|
|
24
31
|
parser(@base_env)
|
25
32
|
end
|
@@ -41,6 +48,7 @@ module Configa
|
|
41
48
|
def load_yaml(env)
|
42
49
|
@yamls[env] ||= begin
|
43
50
|
path = File.join(@base_dir, env.to_s + @base_extname)
|
51
|
+
|
44
52
|
file = File.read(path)
|
45
53
|
yaml = YAML.load(file)
|
46
54
|
yaml
|
data/lib/configa/version.rb
CHANGED
@@ -89,6 +89,15 @@ describe Configa do
|
|
89
89
|
proc{ @config.production.mysql.username }.must_raise Configa::UnknownEnvironment
|
90
90
|
end
|
91
91
|
|
92
|
+
it "should work with default env that don't exist" do
|
93
|
+
path = File.expand_path("../../base.yml", __FILE__)
|
94
|
+
@config = Configa.new(path, env: :some_non_exist_env)
|
95
|
+
@config.mysql.username.must_equal "root"
|
96
|
+
@config.storage.must_equal "tmp"
|
97
|
+
@config.mysql.host.must_equal "localhost"
|
98
|
+
@config.production.mysql.username.must_equal "admin"
|
99
|
+
end
|
100
|
+
|
92
101
|
it "should return result as a hash" do
|
93
102
|
path = File.expand_path("../../config.yml", __FILE__)
|
94
103
|
@config = Configa.new(path)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: configa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
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: 2012-
|
12
|
+
date: 2012-11-28 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: YAML configuration file parser
|
15
15
|
email:
|
@@ -54,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
54
|
version: '0'
|
55
55
|
requirements: []
|
56
56
|
rubyforge_project:
|
57
|
-
rubygems_version: 1.8.
|
57
|
+
rubygems_version: 1.8.24
|
58
58
|
signing_key:
|
59
59
|
specification_version: 3
|
60
60
|
summary: Configa makes it easier to use multi environment YAML configs
|