simple-conf 0.1.1 → 0.1.2
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/Guardfile +0 -1
- data/lib/simple-conf/loader.rb +9 -11
- data/lib/simple-conf/version.rb +1 -1
- data/spec/simple_conf_spec.rb +15 -0
- metadata +4 -4
data/Guardfile
CHANGED
@@ -2,6 +2,5 @@ guard 'rspec', :cli => '--format documentation', :version => 2, :all_after_pass
|
|
2
2
|
watch(%r{^spec/.+_spec\.rb$})
|
3
3
|
watch(%r{^spec/.+\.rb$})
|
4
4
|
watch(%r{^lib/(.+)\.rb$}) { "spec" }
|
5
|
-
watch(%r{^lib/messaging_app/(.+)\.rb$}) { "spec" }
|
6
5
|
watch('spec/spec_helper.rb') { "spec" }
|
7
6
|
end
|
data/lib/simple-conf/loader.rb
CHANGED
@@ -3,13 +3,7 @@ require 'yaml'
|
|
3
3
|
require 'erb'
|
4
4
|
|
5
5
|
module SimpleConf
|
6
|
-
|
7
|
-
attr_reader :klass
|
8
|
-
|
9
|
-
def initialize(klass)
|
10
|
-
@klass = klass
|
11
|
-
end
|
12
|
-
|
6
|
+
Loader = Struct.new(:klass) do
|
13
7
|
def run
|
14
8
|
yaml_file.each_pair do |key, value|
|
15
9
|
set(key, value)
|
@@ -19,15 +13,19 @@ module SimpleConf
|
|
19
13
|
set(key, value)
|
20
14
|
end if rails_environment_defined?
|
21
15
|
|
22
|
-
yaml_file.fetch(
|
16
|
+
yaml_file.fetch(klass.env, {}).each_pair do |key, value|
|
23
17
|
set(key, value)
|
24
|
-
end if
|
18
|
+
end if klass.respond_to?(:env)
|
25
19
|
end
|
26
20
|
|
27
21
|
def path
|
28
|
-
|
22
|
+
"./config/#{config_file_name}"
|
23
|
+
end
|
29
24
|
|
30
|
-
|
25
|
+
def config_file_name
|
26
|
+
klass.respond_to?(:config_file_name) ?
|
27
|
+
klass.config_file_name :
|
28
|
+
"#{klass.name.downcase.split("::").last}.yml"
|
31
29
|
end
|
32
30
|
|
33
31
|
def yaml_file
|
data/lib/simple-conf/version.rb
CHANGED
data/spec/simple_conf_spec.rb
CHANGED
@@ -28,6 +28,14 @@ class Settings
|
|
28
28
|
include SimpleConf
|
29
29
|
end
|
30
30
|
|
31
|
+
class SettingsWithFilename
|
32
|
+
def self.config_file_name
|
33
|
+
'settings.yml'
|
34
|
+
end
|
35
|
+
|
36
|
+
include SimpleConf
|
37
|
+
end
|
38
|
+
|
31
39
|
describe SimpleConf do
|
32
40
|
context "on include to config class generate properties" do
|
33
41
|
it { Configuration.staging.domain.should == "staging.example.com" }
|
@@ -96,3 +104,10 @@ describe SimpleConf do
|
|
96
104
|
}
|
97
105
|
end
|
98
106
|
end
|
107
|
+
|
108
|
+
describe SimpleConf do
|
109
|
+
it 'should be possible to use defined name in the settings class for loading the configuration file' do
|
110
|
+
SettingsWithFilename.test.domain.should == 'test.example.com'
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-conf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
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-
|
12
|
+
date: 2013-10-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -67,7 +67,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
67
|
version: '0'
|
68
68
|
segments:
|
69
69
|
- 0
|
70
|
-
hash:
|
70
|
+
hash: -847311465064856186
|
71
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: '0'
|
77
77
|
segments:
|
78
78
|
- 0
|
79
|
-
hash:
|
79
|
+
hash: -847311465064856186
|
80
80
|
requirements: []
|
81
81
|
rubyforge_project:
|
82
82
|
rubygems_version: 1.8.25
|