configster 0.0.2 → 0.0.3
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/CHANGELOG.md +10 -0
- data/README.md +6 -0
- data/autotest/discover.rb +1 -0
- data/configster.gemspec +1 -0
- data/lib/configster/configster.rb +11 -5
- data/lib/configster/version.rb +1 -1
- data/spec/configster_spec.rb +10 -1
- data/spec/configurations/second_configuration.yml +4 -0
- data/spec/konfigured_klass_spec.rb +1 -0
- data/spec/spec_helper.rb +0 -2
- metadata +29 -5
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -27,6 +27,12 @@ For most applications, you'll want to load Configster before you start loading t
|
|
27
27
|
|
28
28
|
You can also pass a raw hash of stuff into `load!` as long as it's in the format of `"ClassName" => { 'variable' => 'whatever' }`
|
29
29
|
|
30
|
+
Configster.load!('MyAwesomeClass' => { :something => 'cool' })
|
31
|
+
|
32
|
+
Or load an entire directory:
|
33
|
+
|
34
|
+
Configster.load!(File.join(Rails.root, 'config', 'configster'))
|
35
|
+
|
30
36
|
Then, just include Configster in any classes you want:
|
31
37
|
|
32
38
|
class KonfiguredKlass
|
@@ -0,0 +1 @@
|
|
1
|
+
Autotest.add_discovery { "rspec2" }
|
data/configster.gemspec
CHANGED
@@ -33,14 +33,20 @@ module Configster
|
|
33
33
|
# ===========================
|
34
34
|
def self.load!(configster_config)
|
35
35
|
@configster_config ||= { }
|
36
|
-
|
36
|
+
case configster_config
|
37
37
|
when Hash
|
38
|
-
configster_config
|
38
|
+
@configster_config.merge!(configster_config)
|
39
39
|
when String
|
40
|
-
|
40
|
+
if File.directory?(configster_config)
|
41
|
+
Dir.glob(File.join(configster_config, "*.yml")).each do |file|
|
42
|
+
@configster_config.merge!(YAML.load_file(file))
|
43
|
+
end
|
44
|
+
elsif File.exists?(configster_config)
|
45
|
+
@configster_config.merge!(YAML.load_file(configster_config))
|
46
|
+
else
|
47
|
+
raise "Unable to locate #{configster_config}"
|
48
|
+
end
|
41
49
|
end
|
42
|
-
|
43
|
-
@configster_config.merge!(new_config)
|
44
50
|
end
|
45
51
|
|
46
52
|
def self.config_for(klass)
|
data/lib/configster/version.rb
CHANGED
data/spec/configster_spec.rb
CHANGED
@@ -2,13 +2,22 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Configster do
|
4
4
|
|
5
|
-
subject
|
5
|
+
subject do
|
6
|
+
Configster.load!(File.join($spec_root, 'configurations', 'test_configuration.yml'))
|
7
|
+
Configster
|
8
|
+
end
|
9
|
+
|
6
10
|
it { should respond_to(:config_for) }
|
7
11
|
|
8
12
|
it "should be able to load the configuration for a specific class" do
|
9
13
|
Configster.config_for(KonfiguredKlass).should_not be_nil
|
10
14
|
end
|
11
15
|
|
16
|
+
it "should be able to load a directory of yml files" do
|
17
|
+
Configster.load!(File.join($spec_root, 'configurations'))
|
18
|
+
Configster.config_for('SecondConfiguration').should_not be_nil
|
19
|
+
end
|
20
|
+
|
12
21
|
it "should not destroy other configurations when loading additional configs" do
|
13
22
|
Configster.load!('test_thing' => { 'test' => true })
|
14
23
|
Configster.config_for('test_thing').test.should be_true
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: configster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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: 2012-
|
12
|
+
date: 2012-11-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,28 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: ZenTest
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
25
46
|
description: Configster is a tidy little configuration management utility for your
|
26
47
|
application. Store your configuration as YAML outside of your application. You
|
27
48
|
probably haven't heard of it.
|
@@ -37,6 +58,7 @@ files:
|
|
37
58
|
- LICENSE.txt
|
38
59
|
- README.md
|
39
60
|
- Rakefile
|
61
|
+
- autotest/discover.rb
|
40
62
|
- configster.gemspec
|
41
63
|
- examples/active_record_example.rb
|
42
64
|
- examples/httparty_example.rb
|
@@ -44,6 +66,7 @@ files:
|
|
44
66
|
- lib/configster/configster.rb
|
45
67
|
- lib/configster/version.rb
|
46
68
|
- spec/configster_spec.rb
|
69
|
+
- spec/configurations/second_configuration.yml
|
47
70
|
- spec/configurations/test_configuration.yml
|
48
71
|
- spec/konfigured_klass_spec.rb
|
49
72
|
- spec/spec_helper.rb
|
@@ -67,12 +90,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
90
|
version: '0'
|
68
91
|
requirements: []
|
69
92
|
rubyforge_project:
|
70
|
-
rubygems_version: 1.8.
|
93
|
+
rubygems_version: 1.8.24
|
71
94
|
signing_key:
|
72
95
|
specification_version: 3
|
73
96
|
summary: Configster keeps your configuration out of your application.
|
74
97
|
test_files:
|
75
98
|
- spec/configster_spec.rb
|
99
|
+
- spec/configurations/second_configuration.yml
|
76
100
|
- spec/configurations/test_configuration.yml
|
77
101
|
- spec/konfigured_klass_spec.rb
|
78
102
|
- spec/spec_helper.rb
|