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 CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.0.3 (November 12, 2012)
2
+
3
+ Features:
4
+
5
+ - Load a directory of configs instead of having to load all of them manually.
6
+
7
+ Documentation:
8
+
9
+ - Added example for loading a directory.
10
+
1
11
  ## 0.0.2 (September 12, 2012)
2
12
 
3
13
  Features:
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
@@ -18,5 +18,6 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_development_dependency('rspec')
21
+ gem.add_development_dependency('ZenTest')
21
22
 
22
23
  end
@@ -33,14 +33,20 @@ module Configster
33
33
  # ===========================
34
34
  def self.load!(configster_config)
35
35
  @configster_config ||= { }
36
- new_config = case configster_config
36
+ case configster_config
37
37
  when Hash
38
- configster_config
38
+ @configster_config.merge!(configster_config)
39
39
  when String
40
- YAML.load_file(configster_config)
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)
@@ -1,3 +1,3 @@
1
1
  module Configster
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -2,13 +2,22 @@ require "spec_helper"
2
2
 
3
3
  describe Configster do
4
4
 
5
- subject { Configster }
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
@@ -0,0 +1,4 @@
1
+ SecondConfiguration:
2
+ user_name: configster
3
+ password: bacon
4
+ tag_line: "Okay..."
@@ -3,6 +3,7 @@ require "spec_helper"
3
3
  describe KonfiguredKlass do
4
4
 
5
5
  before(:all) do
6
+ Configster.load!(File.join($spec_root, 'configurations', 'test_configuration.yml'))
6
7
  @test_klass = KonfiguredKlass.new
7
8
  end
8
9
 
data/spec/spec_helper.rb CHANGED
@@ -26,8 +26,6 @@ RSpec.configure do |config|
26
26
  end
27
27
  end
28
28
 
29
- Configster.load!(File.join($spec_root, 'configurations', 'test_configuration.yml'))
30
-
31
29
  class KonfiguredKlass
32
30
  include Configster
33
31
  end
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.2
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-09-12 00:00:00.000000000 Z
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: &70104961260240 !ruby/object:Gem::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: *70104961260240
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.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