conf 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/VERSION +1 -1
- data/conf.gemspec +3 -3
- data/lib/conf.rb +13 -1
- data/spec/conf_spec.rb +8 -0
- metadata +3 -7
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/conf.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{conf}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jari Bakken"]
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.homepage = %q{http://github.com/jarib/conf}
|
33
33
|
s.rdoc_options = ["--charset=UTF-8"]
|
34
34
|
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.3.
|
35
|
+
s.rubygems_version = %q{1.3.6}
|
36
36
|
s.summary = %q{Simple configuraton library that supports inheritance.}
|
37
37
|
s.test_files = [
|
38
38
|
"spec/conf_spec.rb",
|
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
|
|
43
43
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
44
44
|
s.specification_version = 3
|
45
45
|
|
46
|
-
if Gem::Version.new(Gem::
|
46
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
47
47
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
48
48
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
49
49
|
else
|
data/lib/conf.rb
CHANGED
@@ -48,6 +48,16 @@ class Conf
|
|
48
48
|
super
|
49
49
|
end
|
50
50
|
|
51
|
+
def section(start_key)
|
52
|
+
result = @parent ? @parent.section(start_keykey) : {}
|
53
|
+
|
54
|
+
@data.each do |key, value|
|
55
|
+
result[key] = value if key =~ /^#{Regexp.escape start_key}/
|
56
|
+
end
|
57
|
+
|
58
|
+
result
|
59
|
+
end
|
60
|
+
|
51
61
|
protected
|
52
62
|
|
53
63
|
def data() @data end
|
@@ -94,7 +104,9 @@ class Conf
|
|
94
104
|
|
95
105
|
def validate_nesting
|
96
106
|
current = expand_key(nil)
|
97
|
-
|
107
|
+
match_proc = Proc.new { |key,_| key =~ /^#{Regexp.escape current}/ }
|
108
|
+
|
109
|
+
unless @data.any?(&match_proc) || (@parent && @parent.data.any?(&match_proc))
|
98
110
|
@current_nesting.clear
|
99
111
|
raise InvalidKeyError, "no such key: #{current.inspect}"
|
100
112
|
end
|
data/spec/conf_spec.rb
CHANGED
@@ -97,4 +97,12 @@ describe "Conf" do
|
|
97
97
|
conf.key?("foo.bar.baz").should be_true
|
98
98
|
conf.key?("bar").should be_false
|
99
99
|
end
|
100
|
+
|
101
|
+
it "retrieves a section of the config as a hash" do
|
102
|
+
Conf.define(:tmp) {
|
103
|
+
foo.bar.baz 1
|
104
|
+
foo.bar.boo 2
|
105
|
+
foo.bla.baz 3
|
106
|
+
}.section("foo.bar").should == {"foo.bar.baz" => 1, "foo.bar.boo" => 2}
|
107
|
+
end
|
100
108
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jari Bakken
|
@@ -21,7 +21,6 @@ dependencies:
|
|
21
21
|
name: rspec
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
24
|
requirements:
|
26
25
|
- - ">="
|
27
26
|
- !ruby/object:Gem::Version
|
@@ -36,7 +35,6 @@ dependencies:
|
|
36
35
|
name: yard
|
37
36
|
prerelease: false
|
38
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
38
|
requirements:
|
41
39
|
- - ">="
|
42
40
|
- !ruby/object:Gem::Version
|
@@ -76,7 +74,6 @@ rdoc_options:
|
|
76
74
|
require_paths:
|
77
75
|
- lib
|
78
76
|
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
77
|
requirements:
|
81
78
|
- - ">="
|
82
79
|
- !ruby/object:Gem::Version
|
@@ -84,7 +81,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
81
|
- 0
|
85
82
|
version: "0"
|
86
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
84
|
requirements:
|
89
85
|
- - ">="
|
90
86
|
- !ruby/object:Gem::Version
|
@@ -94,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
90
|
requirements: []
|
95
91
|
|
96
92
|
rubyforge_project:
|
97
|
-
rubygems_version: 1.3.
|
93
|
+
rubygems_version: 1.3.6
|
98
94
|
signing_key:
|
99
95
|
specification_version: 3
|
100
96
|
summary: Simple configuraton library that supports inheritance.
|