configoro 1.0.0 → 1.1.0

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/README.textile CHANGED
@@ -1,7 +1,7 @@
1
1
  h1. Configoro -- Environment-specific configuration data for Rails apps
2
2
 
3
3
  | *Author* | Tim Morgan |
4
- | *Version* | 1.0 (May 5, 2011) |
4
+ | *Version* | 1.1 (May 9, 2011) |
5
5
  | *License* | Released under the MIT license. |
6
6
 
7
7
  h2. About
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
data/configoro.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{configoro}
8
- s.version = "1.0.0"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Tim Morgan"]
12
- s.date = %q{2011-05-05}
11
+ s.authors = [%q{Tim Morgan}]
12
+ s.date = %q{2011-05-09}
13
13
  s.description = %q{Creates a YourApp::Configuration object whose methods are generated from environment-specific YAML files.}
14
14
  s.email = %q{git@timothymorgan.info}
15
15
  s.extra_rdoc_files = [
@@ -41,9 +41,9 @@ Gem::Specification.new do |s|
41
41
  "spec/spec_helper.rb"
42
42
  ]
43
43
  s.homepage = %q{http://github.com/RISCfuture/configoro}
44
- s.licenses = ["MIT"]
45
- s.require_paths = ["lib"]
46
- s.rubygems_version = %q{1.7.2}
44
+ s.licenses = [%q{MIT}]
45
+ s.require_paths = [%q{lib}]
46
+ s.rubygems_version = %q{1.8.1}
47
47
  s.summary = %q{Configuration object and YAML-based storage for Rails apps}
48
48
 
49
49
  if s.respond_to? :specification_version then
@@ -79,6 +79,12 @@ class Configoro::Hash < HashWithIndifferentAccess
79
79
  else
80
80
  raise ArgumentError, "wrong number of arguments (#{args.size} for 0)"
81
81
  end
82
+ elsif meth.to_s =~ /^(.+)\?$/ and include?(root_meth = $1) then
83
+ if args.empty? then
84
+ !! create_getter(root_meth) #TODO duplication of logic
85
+ else
86
+ raise ArgumentError, "wrong number of arguments (#{args.size} for 0)"
87
+ end
82
88
  else
83
89
  super
84
90
  end
@@ -117,7 +123,15 @@ class Configoro::Hash < HashWithIndifferentAccess
117
123
  remove_getter meth
118
124
  end
119
125
  end
120
-
126
+
127
+ singleton_class.send(:define_method, :"#{meth}?") do
128
+ if include?(meth.to_s) then
129
+ !! self[meth.to_s]
130
+ else
131
+ remove_getter meth
132
+ end
133
+ end
134
+
121
135
  self[meth.to_s]
122
136
  end
123
137
 
@@ -125,6 +139,10 @@ class Configoro::Hash < HashWithIndifferentAccess
125
139
  if methods.include?(meth.to_sym) then
126
140
  instance_eval "undef #{meth.to_sym.inspect}"
127
141
  end
142
+
143
+ if methods.include?(:"#{meth}?") then
144
+ instance_eval "undef #{:"#{meth}?".inspect}"
145
+ end
128
146
 
129
147
  raise NameError, "undefined local variable or method `#{meth}' for #{self.inspect}"
130
148
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Configoro::Hash do
4
- subject { Configoro::Hash.new(:string => 'value', :fixnum => 123, :hash => { :foo => 'bar' }, :array => [ 1, 2, 3 ]) }
4
+ subject { Configoro::Hash.new(:string => 'value', :fixnum => 123, :hash => { :foo => 'bar' }, :array => [ 1, 2, 3 ], :nilval => nil) }
5
5
 
6
6
  context "[getters]" do
7
7
  it "should allow access by symbol" do
@@ -14,27 +14,43 @@ describe Configoro::Hash do
14
14
 
15
15
  it "should allow access by method" do
16
16
  subject.array.should eql([ 1, 2, 3 ])
17
+ subject.array.should eql([ 1, 2, 3 ])
18
+ end
19
+
20
+ it "should allow access by predicate method" do
21
+ subject.string?.should eql(true)
22
+ subject.string?.should eql(true)
23
+ subject.nilval?.should eql(false)
24
+ subject.nilval?.should eql(false)
17
25
  end
26
+
27
+ # We try the above methods twice: Once for creating the method, the other
28
+ # for accessing it
18
29
  end
19
30
 
20
31
  context "[accessor methods]" do
21
32
  it "should define an accessor method upon first access" do
22
33
  subject.methods.should_not include(:string)
34
+ subject.methods.should_not include(:string?)
23
35
  subject.string
24
36
  subject.methods.should include(:string)
37
+ subject.methods.should include(:string?)
25
38
  end
26
39
 
27
40
  it "should remove the accessor method if the key is removed from the hash" do
28
41
  subject.string
29
42
  subject.methods.should include(:string)
43
+ subject.methods.should include(:string?)
30
44
  subject.delete 'string'
31
45
  proc { subject.string }.should raise_error(NameError)
32
46
  subject.methods.should_not include(:string)
47
+ subject.methods.should_not include(:string?)
33
48
  end
34
49
 
35
50
  it "should not override existing methods" do
36
51
  subject['inspect'] = 'wrong!'
37
52
  subject.inspect.should_not eql('wrong!')
53
+ subject.methods.should_not include(:inspect?)
38
54
  end
39
55
  end
40
56
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: configoro
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 1.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tim Morgan
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-05 00:00:00 Z
13
+ date: 2011-05-09 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -123,7 +123,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
123
  requirements:
124
124
  - - ">="
125
125
  - !ruby/object:Gem::Version
126
- hash: -2726389570801720649
126
+ hash: 3499907636224046396
127
127
  segments:
128
128
  - 0
129
129
  version: "0"
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  requirements: []
137
137
 
138
138
  rubyforge_project:
139
- rubygems_version: 1.7.2
139
+ rubygems_version: 1.8.1
140
140
  signing_key:
141
141
  specification_version: 3
142
142
  summary: Configuration object and YAML-based storage for Rails apps