configurability 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
@@ -1 +1,3 @@
1
- #�Ы�݈�1�O�0���@� #���U(��+�AvߜkU���!��, ���<��~�:[@ ��ߜ����}ߧBAϯ�¹����m-}����9��t]` d�K���t9�BY�_�����?���
1
+ |S��O�@�
2
+ �ជVqGl�G�4�a~�`�q>�z�'t_�m0�� �#jJ����/�j�qj9<�U�I���ۚrK
3
+ ��Q�Bﰰ �t��
data/History.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 1.0.6 [2011-03-03] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Bugfixes:
4
+
5
+ * Fixed predicate methods for missing sections/values, which previously returned
6
+ `true` as well.
7
+
8
+
1
9
  ## 1.0.5 [2011-02-08] Michael Granger <ged@FaerieMUD.org>
2
10
 
3
11
  Bugfixes:
data/Rakefile CHANGED
@@ -21,7 +21,8 @@ hoespec = Hoe.spec 'configurability' do
21
21
  self.developer 'Michael Granger', 'ged@FaerieMUD.org'
22
22
 
23
23
  self.extra_dev_deps.push *{
24
- 'rspec' => '~> 2.4',
24
+ 'rspec' => '~> 2.4',
25
+ 'simplecov' => '~> 0.3',
25
26
  }
26
27
 
27
28
  self.spec_extras[:licenses] = ["BSD"]
@@ -9,10 +9,10 @@ require 'yaml'
9
9
  module Configurability
10
10
 
11
11
  # Library version constant
12
- VERSION = '1.0.5'
12
+ VERSION = '1.0.6'
13
13
 
14
14
  # Version-control revision constant
15
- REVISION = %q$Revision: 12fda25efd84 $
15
+ REVISION = %q$Revision: 631fd470522c $
16
16
 
17
17
  require 'configurability/logformatter'
18
18
  require 'configurability/deferredconfig'
@@ -458,8 +458,10 @@ class Configurability::Config
458
458
  ### Returns +true+ if the given +name+ is the name of a member of
459
459
  ### the receiver.
460
460
  def member?( name )
461
- return @hash.key?( name.to_s.to_sym )
461
+ name = name.to_sym if name.respond_to?( :to_sym )
462
+ return @hash.key?( name )
462
463
  end
464
+ alias_method :has_member?, :member?
463
465
 
464
466
 
465
467
  ### Merge the specified +other+ object with this config struct. The
@@ -544,7 +546,7 @@ class Configurability::Config
544
546
  ### @param [Symbol] key the config key to create the predicate method body for
545
547
  ### @return [Proc] the body of the new method
546
548
  def create_member_predicate( key )
547
- return lambda { self[key] ? true : false }
549
+ return lambda { self.member?( key ) && self[key] ? true : false }
548
550
  end
549
551
 
550
552
 
@@ -93,25 +93,47 @@ describe Configurability::Config do
93
93
  config[:section]['subsection'][:subsubsection].should == 'value'
94
94
  end
95
95
 
96
+ it "autoloads predicates for its members" do
97
+ config = Configurability::Config.new( TEST_CONFIG )
98
+ config.mergekey?.should be_true()
99
+ config.mergemonkey?.should be_false()
100
+ config.section?.should be_true()
101
+ config.section.subsection?.should be_true()
102
+ config.section.subsection.subsubsection?.should be_true()
103
+ config.section.monkeysubsection?.should be_false()
104
+ end
96
105
 
97
- NIL_KEY_CONFIG = %{
98
- ---
99
- trap_on:
100
- "low disk space alert":
101
- ~:
102
- notepad:
103
- patterns:
104
- - pattern1
105
- - pattern2
106
- }.gsub(/^\t/, '')
107
106
 
108
- it "handles nil as a key in the configuration (issue #1)" do
109
- config = Configurability::Config.new( NIL_KEY_CONFIG )
110
- config[:trap_on]['low disk space alert'][nil][:notepad][:patterns].should == [ 'pattern1', 'pattern2' ]
107
+ context "a config with nil keys" do
108
+
109
+ NIL_KEY_CONFIG = %{
110
+ ---
111
+ trap_on:
112
+ "low disk space alert":
113
+ ~:
114
+ notepad:
115
+ patterns:
116
+ - pattern1
117
+ - pattern2
118
+ }.gsub(/^\t{2}/, '')
119
+
120
+ before( :each ) do
121
+ @config = Configurability::Config.new( NIL_KEY_CONFIG )
122
+ end
123
+
124
+ it "doesn't raise a NoMethodError when loading (issue #1)" do
125
+ @config[:trap_on]['low disk space alert'][nil][:notepad][:patterns].
126
+ should == [ 'pattern1', 'pattern2' ]
127
+ end
128
+
129
+ it "knows that it has a nil member" do
130
+ @config[:trap_on]['low disk space alert'].should have_member( nil )
131
+ end
132
+
111
133
  end
112
134
 
113
135
 
114
- describe "created with in-memory YAML source" do
136
+ context "created with in-memory YAML source" do
115
137
 
116
138
  before(:each) do
117
139
  @config = Configurability::Config.new( TEST_CONFIG )
@@ -183,7 +205,7 @@ describe Configurability::Config do
183
205
 
184
206
 
185
207
  # saving if changed since loaded
186
- describe " whose internal values have been changed since loaded" do
208
+ context " whose internal values have been changed since loaded" do
187
209
  before(:each) do
188
210
  @config = Configurability::Config.new( TEST_CONFIG )
189
211
  @config.section.subsection.anothersection = 11451
@@ -203,7 +225,7 @@ describe Configurability::Config do
203
225
 
204
226
 
205
227
  # loading from a file
206
- describe " loaded from a file" do
228
+ context " loaded from a file" do
207
229
  before(:all) do
208
230
  @tmpfile = Tempfile.new( 'test.conf', '.' )
209
231
  @tmpfile.print( TEST_CONFIG )
@@ -265,7 +287,7 @@ describe Configurability::Config do
265
287
 
266
288
 
267
289
  # reload if file changes
268
- describe " whose file changes after loading" do
290
+ context " whose file changes after loading" do
269
291
  before(:all) do
270
292
  @tmpfile = Tempfile.new( 'test.conf', '.' )
271
293
  @tmpfile.print( TEST_CONFIG )
@@ -310,7 +332,7 @@ describe Configurability::Config do
310
332
 
311
333
 
312
334
  # merging
313
- describe " created by merging two other configs" do
335
+ context " created by merging two other configs" do
314
336
  before(:each) do
315
337
  @config1 = Configurability::Config.new
316
338
  @config2 = Configurability::Config.new( TEST_CONFIG )
@@ -10,12 +10,16 @@ BEGIN {
10
10
  $LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
11
11
  }
12
12
 
13
+ require 'simplecov'
13
14
  require 'rspec'
14
15
 
15
16
  require 'logger'
16
17
  require 'erb'
17
18
  require 'yaml'
18
19
 
20
+ SimpleCov.start do
21
+ add_filter '/spec/'
22
+ end
19
23
  require 'configurability'
20
24
 
21
25
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configurability
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 5
10
- version: 1.0.5
9
+ - 6
10
+ version: 1.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Granger
@@ -35,7 +35,7 @@ cert_chain:
35
35
  cmlhXe46pZNJgWKbxZah85jIjx95hR8vOI+NAM5iH9kOqK13DrxacTKPhqj5PjwF
36
36
  -----END CERTIFICATE-----
37
37
 
38
- date: 2011-02-08 00:00:00 -08:00
38
+ date: 2011-03-03 00:00:00 -08:00
39
39
  default_executable:
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
@@ -86,9 +86,24 @@ dependencies:
86
86
  type: :development
87
87
  version_requirements: *id003
88
88
  - !ruby/object:Gem::Dependency
89
- name: hoe
89
+ name: simplecov
90
90
  prerelease: false
91
91
  requirement: &id004 !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ hash: 13
97
+ segments:
98
+ - 0
99
+ - 3
100
+ version: "0.3"
101
+ type: :development
102
+ version_requirements: *id004
103
+ - !ruby/object:Gem::Dependency
104
+ name: hoe
105
+ prerelease: false
106
+ requirement: &id005 !ruby/object:Gem::Requirement
92
107
  none: false
93
108
  requirements:
94
109
  - - ">="
@@ -100,7 +115,7 @@ dependencies:
100
115
  - 0
101
116
  version: 2.9.0
102
117
  type: :development
103
- version_requirements: *id004
118
+ version_requirements: *id005
104
119
  description: |-
105
120
  Configurability is a mixin that allows you to add configurability to one or
106
121
  more objects or classes. You can assign them each a subsection of the
@@ -168,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
183
  requirements: []
169
184
 
170
185
  rubyforge_project: configurability
171
- rubygems_version: 1.5.0
186
+ rubygems_version: 1.6.0
172
187
  signing_key:
173
188
  specification_version: 3
174
189
  summary: Configurability is a mixin that allows you to add configurability to one or more objects or classes
metadata.gz.sig CHANGED
Binary file