confstruct 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +5 -0
- data/README.md +3 -4
- data/confstruct.gemspec +2 -1
- data/lib/confstruct/hash_with_struct_access.rb +5 -4
- data/lib/confstruct.rb +1 -1
- data/lib/tasks/rspec.rake +0 -2
- data/spec/confstruct/hash_with_struct_access_spec.rb +23 -0
- data/spec/spec_helper.rb +4 -0
- metadata +31 -16
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
# confstruct
|
1
|
+
# confstruct [![Build Status](https://secure.travis-ci.org/mbklein/confstruct.png)](http://travis-ci.org/mbklein/confstruct) [![Dependency Status](https://gemnasium.com/mbklein/confstruct.png)](https://gemnasium.com/mbklein/confstruct)
|
2
|
+
|
2
3
|
|
3
4
|
<b>Confstruct</b> is yet another configuration gem. Definable and configurable by
|
4
5
|
hash, struct, or block, confstruct aims to provide the flexibility to do things your
|
5
6
|
way, while keeping things simple and intuitive.
|
6
7
|
|
7
|
-
[![Build Status](https://secure.travis-ci.org/mbklein/confstruct.png)](http://travis-ci.org/mbklein/confstruct)
|
8
|
-
[![Dependency Status](https://gemnasium.com/mbklein/confstruct.png)](https://gemnasium.com/mbklein/confstruct)
|
9
|
-
|
10
8
|
## Usage
|
11
9
|
|
12
10
|
First, either create an empty `ConfStruct::Configuration` object:
|
@@ -192,6 +190,7 @@ The pattern `add_$key!` can be used to add to or create an array.
|
|
192
190
|
- <b>v0.1.0</b> - Initial release
|
193
191
|
- <b>v0.2.0</b> - Add fallback value to HashWithStructAccess#lookup!, native support for Rails I18n.
|
194
192
|
- <b>v0.2.1</b> - Initialize properly from a nested hash with string (non-symbol) keys
|
193
|
+
- <b>v0.2.2</b> - Fix ArgumentError on #respond_to?(sym, true)
|
195
194
|
|
196
195
|
## Contributing to confstruct
|
197
196
|
|
data/confstruct.gemspec
CHANGED
@@ -16,8 +16,9 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
|
+
s.add_development_dependency 'active_support'
|
19
20
|
s.add_development_dependency "rake", ">=0.8.7"
|
20
|
-
s.add_development_dependency "
|
21
|
+
s.add_development_dependency "simplecov"
|
21
22
|
s.add_development_dependency "rdiscount"
|
22
23
|
s.add_development_dependency "rdoc"
|
23
24
|
s.add_development_dependency "rspec"
|
@@ -132,9 +132,10 @@ module Confstruct
|
|
132
132
|
"{#{r.compact.join(', ')}}"
|
133
133
|
end
|
134
134
|
|
135
|
-
def
|
136
|
-
|
135
|
+
def kind_of? klazz
|
136
|
+
@@hash_class.ancestors.include?(klazz) or super
|
137
137
|
end
|
138
|
+
alias_method :is_a?, :kind_of?
|
138
139
|
|
139
140
|
def lookup! key_path, fallback = nil
|
140
141
|
val = self
|
@@ -194,8 +195,8 @@ module Confstruct
|
|
194
195
|
self.class.ordered?
|
195
196
|
end
|
196
197
|
|
197
|
-
def respond_to?
|
198
|
-
super(
|
198
|
+
def respond_to? *args
|
199
|
+
super(*args) || keys.include?(symbolize!(args[0].to_s.sub(/=$/,'')))
|
199
200
|
end
|
200
201
|
|
201
202
|
def structurize! hash
|
data/lib/confstruct.rb
CHANGED
data/lib/tasks/rspec.rake
CHANGED
@@ -239,6 +239,29 @@ describe Confstruct::HashWithStructAccess do
|
|
239
239
|
@hwsa.github.local_hello.should == 'Bonjour, Monde!'
|
240
240
|
@hwsa.github.local_time.should == 'French Time!'
|
241
241
|
end
|
242
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
context "delegation" do
|
246
|
+
before :each do
|
247
|
+
@hwsa = Confstruct::HashWithStructAccess.from_hash('a' => { 'b' => { 'c' => 'd' } })
|
248
|
+
end
|
242
249
|
|
250
|
+
it "should always return HashWithStructAccess hashes" do
|
251
|
+
@hwsa.a.b.should be_a Confstruct::HashWithStructAccess
|
252
|
+
end
|
253
|
+
|
254
|
+
it "should gracefully handle being extended" do
|
255
|
+
pending %{probably won't fix due to the unpredictable way ActiveSupport injects #presence()}
|
256
|
+
@hwsa.a.b.presence.should be_a Confstruct::HashWithStructAccess
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
context "bug fixes" do
|
261
|
+
hwsa = Confstruct::HashWithStructAccess.from_hash('a' => { 'b' => { 'c' => 'd' } })
|
262
|
+
it "should handle the two-argument form of #respond_to?" do
|
263
|
+
lambda { hwsa.respond_to? :something, true }.should_not raise_error
|
264
|
+
end
|
243
265
|
end
|
266
|
+
|
244
267
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confstruct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Klein
|
@@ -15,40 +15,40 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01
|
18
|
+
date: 2012-03-01 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
21
|
+
name: active_support
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
hash:
|
28
|
+
hash: 3
|
29
29
|
segments:
|
30
30
|
- 0
|
31
|
-
|
32
|
-
- 7
|
33
|
-
version: 0.8.7
|
31
|
+
version: "0"
|
34
32
|
type: :development
|
35
33
|
version_requirements: *id001
|
36
34
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
35
|
+
name: rake
|
38
36
|
prerelease: false
|
39
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
38
|
none: false
|
41
39
|
requirements:
|
42
40
|
- - ">="
|
43
41
|
- !ruby/object:Gem::Version
|
44
|
-
hash:
|
42
|
+
hash: 49
|
45
43
|
segments:
|
46
44
|
- 0
|
47
|
-
|
45
|
+
- 8
|
46
|
+
- 7
|
47
|
+
version: 0.8.7
|
48
48
|
type: :development
|
49
49
|
version_requirements: *id002
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
|
-
name:
|
51
|
+
name: simplecov
|
52
52
|
prerelease: false
|
53
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
54
54
|
none: false
|
@@ -62,7 +62,7 @@ dependencies:
|
|
62
62
|
type: :development
|
63
63
|
version_requirements: *id003
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
|
-
name:
|
65
|
+
name: rdiscount
|
66
66
|
prerelease: false
|
67
67
|
requirement: &id004 !ruby/object:Gem::Requirement
|
68
68
|
none: false
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
type: :development
|
77
77
|
version_requirements: *id004
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
79
|
+
name: rdoc
|
80
80
|
prerelease: false
|
81
81
|
requirement: &id005 !ruby/object:Gem::Requirement
|
82
82
|
none: false
|
@@ -90,7 +90,7 @@ dependencies:
|
|
90
90
|
type: :development
|
91
91
|
version_requirements: *id005
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
|
-
name:
|
93
|
+
name: rspec
|
94
94
|
prerelease: false
|
95
95
|
requirement: &id006 !ruby/object:Gem::Requirement
|
96
96
|
none: false
|
@@ -103,6 +103,20 @@ dependencies:
|
|
103
103
|
version: "0"
|
104
104
|
type: :development
|
105
105
|
version_requirements: *id006
|
106
|
+
- !ruby/object:Gem::Dependency
|
107
|
+
name: yard
|
108
|
+
prerelease: false
|
109
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
hash: 3
|
115
|
+
segments:
|
116
|
+
- 0
|
117
|
+
version: "0"
|
118
|
+
type: :development
|
119
|
+
version_requirements: *id007
|
106
120
|
description: A simple, hash/struct-based configuration object
|
107
121
|
email:
|
108
122
|
- mbklein@gmail.com
|
@@ -114,6 +128,7 @@ extra_rdoc_files: []
|
|
114
128
|
|
115
129
|
files:
|
116
130
|
- .gitignore
|
131
|
+
- .travis.yml
|
117
132
|
- Gemfile
|
118
133
|
- README.md
|
119
134
|
- Rakefile
|