configru 2.0.0 → 2.0.1

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,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.0.1 (14 September 2012)
4
+
5
+ * Fix: Cascade options in loaded files
6
+
7
+ ## 2.0.0 (19 June 2012)
8
+
9
+ * Entirely new API
10
+
3
11
  ## 0.5.0 (27 February 2012)
4
12
 
5
13
  * Added `Configru.raw` method to access raw hashmap
data/Gemfile CHANGED
@@ -1,9 +1,9 @@
1
1
  source :rubygems
2
2
 
3
3
  group :development do
4
- gem 'rake', '>= 0'
5
- gem 'rspec', '~> 2.8.0'
6
- gem 'simplecov', '~> 0.6.0'
4
+ gem "rake", "~> 0.9.0"
5
+ gem "rspec", "~> 2.10.0"
6
+ gem "simplecov", "~> 0.6.0"
7
7
  end
8
8
 
9
9
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- configru (2.0.0)
4
+ configru (2.0.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -9,14 +9,14 @@ GEM
9
9
  diff-lcs (1.1.3)
10
10
  multi_json (1.3.6)
11
11
  rake (0.9.2.2)
12
- rspec (2.8.0)
13
- rspec-core (~> 2.8.0)
14
- rspec-expectations (~> 2.8.0)
15
- rspec-mocks (~> 2.8.0)
16
- rspec-core (2.8.0)
17
- rspec-expectations (2.8.0)
18
- diff-lcs (~> 1.1.2)
19
- rspec-mocks (2.8.0)
12
+ rspec (2.10.0)
13
+ rspec-core (~> 2.10.0)
14
+ rspec-expectations (~> 2.10.0)
15
+ rspec-mocks (~> 2.10.0)
16
+ rspec-core (2.10.1)
17
+ rspec-expectations (2.10.0)
18
+ diff-lcs (~> 1.1.3)
19
+ rspec-mocks (2.10.1)
20
20
  simplecov (0.6.4)
21
21
  multi_json (~> 1.0)
22
22
  simplecov-html (~> 0.5.3)
@@ -27,6 +27,6 @@ PLATFORMS
27
27
 
28
28
  DEPENDENCIES
29
29
  configru!
30
- rake
31
- rspec (~> 2.8.0)
30
+ rake (~> 0.9.0)
31
+ rspec (~> 2.10.0)
32
32
  simplecov (~> 0.6.0)
data/README.md CHANGED
@@ -1,6 +1,4 @@
1
- # Configru
2
-
3
- [![Build Status](https://secure.travis-ci.org/programble/configru.png?branch=master)](http://travis-ci.org/programble/configru)
1
+ # Configru [![Build Status](https://secure.travis-ci.org/programble/configru.png?branch=master)](http://travis-ci.org/programble/configru) [![Dependency Status](https://gemnasium.com/programble/configru.png?travis)](https://gemnasium.com/programble/configru)
4
2
 
5
3
  YAML configuration file loader
6
4
 
@@ -8,7 +6,40 @@ YAML configuration file loader
8
6
 
9
7
  ```ruby
10
8
  # Gemfile
11
- gem 'configru', '~> 2.0.0'
9
+ gem "configru", "~> 2.0.0"
10
+ ```
11
+ ### Example
12
+
13
+ ```ruby
14
+ require 'configru'
15
+
16
+ Configru.load('config.yml') do
17
+ option :username, String, 'example_user'
18
+ option :token, Fixnum, 1234
19
+ option_group :connection do
20
+ option :server, String, 'example.com'
21
+ option :port, Fixnum, 42
22
+ end
23
+ option :path, String, Dir.home do
24
+ transform {|x| File.expand_path(x) }
25
+ validate {|x| File.directory?(x) }
26
+ end
27
+ end
28
+
29
+ example = Example.new(Configru.connection.server, Configru.connection.port)
30
+ example.login(Configru.username, Configru.token)
31
+ example.sync(Configru.path)
32
+ ```
33
+
34
+ These defaults are equivalent to the following YAML:
35
+
36
+ ```yaml
37
+ username: example_user
38
+ token: 1234
39
+ connection:
40
+ server: example.com
41
+ port: 42
42
+ path: ~
12
43
  ```
13
44
 
14
45
  # License
@@ -1,3 +1,3 @@
1
1
  module Configru
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
data/lib/configru.rb CHANGED
@@ -73,7 +73,10 @@ module Configru
73
73
 
74
74
  if input.include? key
75
75
  value = input[key]
76
- else
76
+ elsif output.include? key # option has already been set
77
+ @option_path.pop
78
+ next
79
+ else # option has not been set
77
80
  value = option.default
78
81
  end
79
82
 
@@ -59,6 +59,16 @@ describe Configru do
59
59
  Configru.example.should == 'example_b'
60
60
  end
61
61
 
62
+ it 'cascades loaded files' do
63
+ Configru.load(example_file(:g), example_file(:h)) do
64
+ option :option1
65
+ option :option2
66
+ end
67
+
68
+ Configru.option1.should == 'example_g'
69
+ Configru.option2.should == 'example_h'
70
+ end
71
+
62
72
  it 'loads a file with a group' do
63
73
  Configru.load(example_file :c) do
64
74
  option_group :example_group do
@@ -0,0 +1,2 @@
1
+ option1: example_g
2
+ option2: example_g
@@ -0,0 +1 @@
1
+ option2: example_h
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configru
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
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-06-20 00:00:00.000000000 Z
12
+ date: 2012-09-14 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: YAML configuration file loader
15
15
  email:
@@ -40,6 +40,8 @@ files:
40
40
  - spec/example_files/example_d.yml
41
41
  - spec/example_files/example_e.yml
42
42
  - spec/example_files/example_f.yml
43
+ - spec/example_files/example_g.yml
44
+ - spec/example_files/example_h.yml
43
45
  - spec/spec_helper.rb
44
46
  - spec/structhash_spec.rb
45
47
  homepage: https://github.com/programble/configru
@@ -56,7 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
58
  version: '0'
57
59
  segments:
58
60
  - 0
59
- hash: -2633773784802344253
61
+ hash: 872203077689334122
60
62
  required_rubygems_version: !ruby/object:Gem::Requirement
61
63
  none: false
62
64
  requirements:
@@ -65,10 +67,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
67
  version: '0'
66
68
  segments:
67
69
  - 0
68
- hash: -2633773784802344253
70
+ hash: 872203077689334122
69
71
  requirements: []
70
72
  rubyforge_project:
71
- rubygems_version: 1.8.11
73
+ rubygems_version: 1.8.24
72
74
  signing_key:
73
75
  specification_version: 3
74
76
  summary: YAML configuration file loader
@@ -81,5 +83,7 @@ test_files:
81
83
  - spec/example_files/example_d.yml
82
84
  - spec/example_files/example_e.yml
83
85
  - spec/example_files/example_f.yml
86
+ - spec/example_files/example_g.yml
87
+ - spec/example_files/example_h.yml
84
88
  - spec/spec_helper.rb
85
89
  - spec/structhash_spec.rb