extlib 0.9.11 → 0.9.12
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of extlib might be problematic. Click here for more details.
- data/History.txt +10 -1
- data/Rakefile +2 -2
- data/lib/extlib/byte_array.rb +3 -1
- data/lib/extlib/datetime.rb +2 -2
- data/lib/extlib/hook.rb +5 -5
- data/lib/extlib/mash.rb +7 -0
- data/lib/extlib/module.rb +1 -1
- data/lib/extlib/pathname.rb +1 -1
- data/lib/extlib/time.rb +2 -2
- data/lib/extlib/version.rb +1 -1
- data/spec/byte_array_spec.rb +2 -2
- data/spec/class_spec.rb +2 -2
- data/spec/hash_spec.rb +4 -4
- data/spec/hook_spec.rb +6 -6
- data/spec/lazy_array_spec.rb +1 -1
- data/spec/mash_spec.rb +52 -27
- data/spec/module_spec.rb +13 -1
- data/spec/object_spec.rb +15 -15
- data/spec/pooling_spec.rb +5 -5
- data/spec/simple_set_spec.rb +2 -2
- metadata +8 -9
data/History.txt
CHANGED
@@ -1,4 +1,13 @@
|
|
1
|
-
=== 0.9.
|
1
|
+
=== 0.9.12 / 2009-05-05
|
2
|
+
|
3
|
+
* 4 bug fixes
|
4
|
+
|
5
|
+
* Fixed constant lookup for nested constructs
|
6
|
+
* Moved ByteArray to the Extlib module
|
7
|
+
* Fix specs for recent RSpec versions
|
8
|
+
* Fix compatibility with ActiveSupport
|
9
|
+
|
10
|
+
=== 0.9.11 / 2009-03-29
|
2
11
|
|
3
12
|
* 1 major enhancement:
|
4
13
|
|
data/Rakefile
CHANGED
@@ -22,8 +22,8 @@ PROJECT_URL = "http://extlib.rubyforge.org"
|
|
22
22
|
PROJECT_SUMMARY = "Support library for DataMapper and Merb."
|
23
23
|
PROJECT_DESCRIPTION = PROJECT_SUMMARY
|
24
24
|
|
25
|
-
AUTHOR = "
|
26
|
-
EMAIL = "
|
25
|
+
AUTHOR = "Dan Kubb"
|
26
|
+
EMAIL = "dan.kubb@gmail.com"
|
27
27
|
|
28
28
|
GEM_NAME = "extlib"
|
29
29
|
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
data/lib/extlib/byte_array.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# This class has exists to represent binary data. This is mainly
|
2
2
|
# used by DataObjects. Binary data sometimes needs to be quoted differently
|
3
3
|
# than regular string data (even if the string is just plain ASCII).
|
4
|
-
|
4
|
+
module Extlib
|
5
|
+
class ByteArray < ::String; end
|
6
|
+
end
|
data/lib/extlib/datetime.rb
CHANGED
@@ -9,7 +9,7 @@ class DateTime
|
|
9
9
|
# @return [Time] Time object representing the same moment as receiver
|
10
10
|
#
|
11
11
|
# @api public
|
12
|
-
remove_method :to_time if
|
12
|
+
remove_method :to_time if instance_methods(false).any? { |m| m.to_sym == :to_time }
|
13
13
|
def to_time
|
14
14
|
Time.parse self.to_s
|
15
15
|
end
|
@@ -22,7 +22,7 @@ class DateTime
|
|
22
22
|
# @return [DateTime] Receiver
|
23
23
|
#
|
24
24
|
# @api public
|
25
|
-
remove_method :to_datetime if
|
25
|
+
remove_method :to_datetime if instance_methods(false).any? { |m| m.to_sym == :to_datetime }
|
26
26
|
def to_datetime
|
27
27
|
self
|
28
28
|
end
|
data/lib/extlib/hook.rb
CHANGED
@@ -243,12 +243,12 @@ module Extlib
|
|
243
243
|
|
244
244
|
private
|
245
245
|
|
246
|
-
remove_method :#{before_hook_name} if
|
246
|
+
remove_method :#{before_hook_name} if instance_methods(false).any? { |m| m.to_sym == :#{before_hook_name} }
|
247
247
|
def #{before_hook_name}(*args)
|
248
248
|
#{before_hooks}
|
249
249
|
end
|
250
250
|
|
251
|
-
remove_method :#{after_hook_name} if
|
251
|
+
remove_method :#{after_hook_name} if instance_methods(false).any? { |m| m.to_sym == :#{after_hook_name} }
|
252
252
|
def #{after_hook_name}(*args)
|
253
253
|
#{after_hooks}
|
254
254
|
end
|
@@ -288,7 +288,7 @@ module Extlib
|
|
288
288
|
end
|
289
289
|
EOD
|
290
290
|
|
291
|
-
if scope == :instance && !instance_methods(false).
|
291
|
+
if scope == :instance && !instance_methods(false).any? { |m| m.to_sym == target_method }
|
292
292
|
send(:alias_method, renamed_target, target_method)
|
293
293
|
|
294
294
|
proxy_module = Module.new
|
@@ -330,12 +330,12 @@ module Extlib
|
|
330
330
|
after_hook_name = hook_method_name(target_method, 'execute_after', 'hook_stack')
|
331
331
|
|
332
332
|
hooks[target_method][:in].class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
333
|
-
remove_method :#{before_hook_name} if
|
333
|
+
remove_method :#{before_hook_name} if instance_methods(false).any? { |m| m.to_sym == :#{before_hook_name} }
|
334
334
|
def #{before_hook_name}(*args)
|
335
335
|
super
|
336
336
|
end
|
337
337
|
|
338
|
-
remove_method :#{after_hook_name} if
|
338
|
+
remove_method :#{after_hook_name} if instance_methods(false).any? { |m| m.to_sym == :#{before_hook_name} }
|
339
339
|
def #{after_hook_name}(*args)
|
340
340
|
super
|
341
341
|
end
|
data/lib/extlib/mash.rb
CHANGED
@@ -112,6 +112,13 @@ class Mash < Hash
|
|
112
112
|
# @return <Mash> This mash unchanged.
|
113
113
|
def stringify_keys!; self end
|
114
114
|
|
115
|
+
# @return <Hash> The mash as a Hash with symbolized keys.
|
116
|
+
def symbolize_keys
|
117
|
+
h = Hash.new(default)
|
118
|
+
each { |key, val| h[key.to_sym] = val }
|
119
|
+
h
|
120
|
+
end
|
121
|
+
|
115
122
|
# @return <Hash> The mash as a Hash with string keys.
|
116
123
|
def to_hash
|
117
124
|
Hash.new(default).merge(self)
|
data/lib/extlib/module.rb
CHANGED
data/lib/extlib/pathname.rb
CHANGED
@@ -14,7 +14,7 @@ class Pathname
|
|
14
14
|
end
|
15
15
|
|
16
16
|
# alias to_s to to_str when to_str not defined
|
17
|
-
unless public_instance_methods(false).any? { |m| m.
|
17
|
+
unless public_instance_methods(false).any? { |m| m.to_sym == :to_str }
|
18
18
|
alias to_str to_s
|
19
19
|
end
|
20
20
|
end # class Pathname
|
data/lib/extlib/time.rb
CHANGED
@@ -23,7 +23,7 @@ class Time
|
|
23
23
|
# @return [Time] Receiver
|
24
24
|
#
|
25
25
|
# @api public
|
26
|
-
remove_method :to_time if
|
26
|
+
remove_method :to_time if instance_methods(false).any? { |m| m.to_sym == :to_time }
|
27
27
|
def to_time
|
28
28
|
self
|
29
29
|
end
|
@@ -36,7 +36,7 @@ class Time
|
|
36
36
|
# @return [DateTime] DateTime object representing the same moment as receiver
|
37
37
|
#
|
38
38
|
# @api public
|
39
|
-
remove_method :to_datetime if
|
39
|
+
remove_method :to_datetime if instance_methods(false).any? { |m| m.to_sym == :to_datetime }
|
40
40
|
def to_datetime
|
41
41
|
DateTime.parse self.to_s
|
42
42
|
end
|
data/lib/extlib/version.rb
CHANGED
data/spec/byte_array_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
2
2
|
|
3
|
-
describe ByteArray do
|
3
|
+
describe Extlib::ByteArray do
|
4
4
|
it 'should be a String' do
|
5
|
-
ByteArray.new.should be_kind_of(String)
|
5
|
+
Extlib::ByteArray.new.should be_kind_of(String)
|
6
6
|
end
|
7
7
|
end
|
data/spec/class_spec.rb
CHANGED
@@ -148,10 +148,10 @@ end
|
|
148
148
|
|
149
149
|
describe Class, "#inheritable_accessor" do
|
150
150
|
it "uses object_id for comparison" do
|
151
|
-
Model.methods.map { |m| m.
|
151
|
+
Model.methods.map { |m| m.to_sym }.should be_include(:plugin_options)
|
152
152
|
Model.plugin_options.should == :foo
|
153
153
|
|
154
|
-
Model::Version.methods.map { |m| m.
|
154
|
+
Model::Version.methods.map { |m| m.to_sym }.should be_include(:plugin_options)
|
155
155
|
Model::Version.plugin_options.should == :foo
|
156
156
|
end
|
157
157
|
end
|
data/spec/hash_spec.rb
CHANGED
@@ -177,18 +177,18 @@ describe Hash, "from_xml" do
|
|
177
177
|
|
178
178
|
it "should undasherize keys as tags" do
|
179
179
|
xml = "<tag-1>Stuff</tag-1>"
|
180
|
-
Hash.from_xml(xml).
|
180
|
+
Hash.from_xml(xml).should have_key('tag_1')
|
181
181
|
end
|
182
182
|
|
183
183
|
it "should undasherize keys as attributes" do
|
184
184
|
xml = "<tag1 attr-1='1'></tag1>"
|
185
|
-
Hash.from_xml(xml)['tag1'].
|
185
|
+
Hash.from_xml(xml)['tag1'].should have_key('attr_1')
|
186
186
|
end
|
187
187
|
|
188
188
|
it "should undasherize keys as tags and attributes" do
|
189
189
|
xml = "<tag-1 attr-1='1'></tag-1>"
|
190
|
-
Hash.from_xml(xml).
|
191
|
-
Hash.from_xml(xml)['tag_1'].
|
190
|
+
Hash.from_xml(xml).should have_key('tag_1' )
|
191
|
+
Hash.from_xml(xml)['tag_1'].should have_key('attr_1')
|
192
192
|
end
|
193
193
|
|
194
194
|
it "should render nested content correctly" do
|
data/spec/hook_spec.rb
CHANGED
@@ -52,9 +52,9 @@ describe Extlib::Hook do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
@another_class.register_class_hooks :method_one, :method_two, :method_three
|
55
|
-
@another_class.class_hooks.
|
56
|
-
@another_class.class_hooks.
|
57
|
-
@another_class.class_hooks.
|
55
|
+
@another_class.class_hooks.should have_key(:method_one)
|
56
|
+
@another_class.class_hooks.should have_key(:method_two)
|
57
|
+
@another_class.class_hooks.should have_key(:method_three)
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should not allow a method that does not exist to be registered as hookable" do
|
@@ -158,9 +158,9 @@ describe Extlib::Hook do
|
|
158
158
|
end
|
159
159
|
|
160
160
|
@another_class.register_instance_hooks :method_one, :method_two, :method_three
|
161
|
-
@another_class.instance_hooks.
|
162
|
-
@another_class.instance_hooks.
|
163
|
-
@another_class.instance_hooks.
|
161
|
+
@another_class.instance_hooks.should have_key(:method_one)
|
162
|
+
@another_class.instance_hooks.should have_key(:method_two)
|
163
|
+
@another_class.instance_hooks.should have_key(:method_three)
|
164
164
|
end
|
165
165
|
|
166
166
|
it "should not allow a method that does not exist to be registered as hookable" do
|
data/spec/lazy_array_spec.rb
CHANGED
@@ -1913,7 +1913,7 @@ end
|
|
1913
1913
|
describe 'a method mixed into Array' do
|
1914
1914
|
before :all do
|
1915
1915
|
Enumerable.class_eval do
|
1916
|
-
remove_method :lazy_spec if
|
1916
|
+
remove_method :lazy_spec if instance_methods(false).any? { |m| m.to_sym == :lazy_spec }
|
1917
1917
|
def lazy_spec
|
1918
1918
|
true
|
1919
1919
|
end
|
data/spec/mash_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe Mash do
|
|
13
13
|
it 'converts all keys into strings when param is a Hash' do
|
14
14
|
mash = Mash.new(@hash)
|
15
15
|
|
16
|
-
mash.keys.any? { |key| key.is_a?(Symbol) }.should
|
16
|
+
mash.keys.any? { |key| key.is_a?(Symbol) }.should be_false
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'converts all pure Hash values into Mashes if param is a Hash' do
|
@@ -52,7 +52,7 @@ describe Mash do
|
|
52
52
|
mash = Mash.new(@hash)
|
53
53
|
mash.update("starry" => "night")
|
54
54
|
|
55
|
-
mash.keys.any? { |key| key.is_a?(Symbol) }.should
|
55
|
+
mash.keys.any? { |key| key.is_a?(Symbol) }.should be_false
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'converts all Hash values into Mashes if param is a Hash' do
|
@@ -70,7 +70,7 @@ describe Mash do
|
|
70
70
|
mash = Mash.new(@hash)
|
71
71
|
mash[:hash] = { "starry" => "night" }
|
72
72
|
|
73
|
-
mash.keys.any? { |key| key.is_a?(Symbol) }.should
|
73
|
+
mash.keys.any? { |key| key.is_a?(Symbol) }.should be_false
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'converts all Hash value into Mash' do
|
@@ -89,36 +89,36 @@ describe Mash do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'converts key before lookup' do
|
92
|
-
@mash.key?("mash").should
|
93
|
-
@mash.key?(:mash).should
|
92
|
+
@mash.key?("mash").should be_true
|
93
|
+
@mash.key?(:mash).should be_true
|
94
94
|
|
95
|
-
@mash.key?("hash").should
|
96
|
-
@mash.key?(:hash).should
|
95
|
+
@mash.key?("hash").should be_true
|
96
|
+
@mash.key?(:hash).should be_true
|
97
97
|
|
98
|
-
@mash.key?(:rainclouds).should
|
99
|
-
@mash.key?("rainclouds").should
|
98
|
+
@mash.key?(:rainclouds).should be_false
|
99
|
+
@mash.key?("rainclouds").should be_false
|
100
100
|
end
|
101
101
|
|
102
102
|
it 'is aliased as include?' do
|
103
|
-
@mash.include?("mash").should
|
104
|
-
@mash.include?(:mash).should
|
103
|
+
@mash.include?("mash").should be_true
|
104
|
+
@mash.include?(:mash).should be_true
|
105
105
|
|
106
|
-
@mash.include?("hash").should
|
107
|
-
@mash.include?(:hash).should
|
106
|
+
@mash.include?("hash").should be_true
|
107
|
+
@mash.include?(:hash).should be_true
|
108
108
|
|
109
|
-
@mash.include?(:rainclouds).should
|
110
|
-
@mash.include?("rainclouds").should
|
109
|
+
@mash.include?(:rainclouds).should be_false
|
110
|
+
@mash.include?("rainclouds").should be_false
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'is aliased as member?' do
|
114
|
-
@mash.member?("mash").should
|
115
|
-
@mash.member?(:mash).should
|
114
|
+
@mash.member?("mash").should be_true
|
115
|
+
@mash.member?(:mash).should be_true
|
116
116
|
|
117
|
-
@mash.member?("hash").should
|
118
|
-
@mash.member?(:hash).should
|
117
|
+
@mash.member?("hash").should be_true
|
118
|
+
@mash.member?(:hash).should be_true
|
119
119
|
|
120
|
-
@mash.member?(:rainclouds).should
|
121
|
-
@mash.member?("rainclouds").should
|
120
|
+
@mash.member?(:rainclouds).should be_false
|
121
|
+
@mash.member?("rainclouds").should be_false
|
122
122
|
end
|
123
123
|
end # describe "#key?"
|
124
124
|
|
@@ -167,19 +167,44 @@ describe Mash do
|
|
167
167
|
|
168
168
|
|
169
169
|
|
170
|
+
describe "#symbolize_keys" do
|
171
|
+
it 'returns instance of Mash' do
|
172
|
+
Mash.new(@hash).symbolize_keys.should be_an_instance_of(Hash)
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'converts keys to symbols' do
|
176
|
+
mash = Mash.new(@hash)
|
177
|
+
converted = mash.symbolize_keys
|
178
|
+
|
179
|
+
converted_keys = converted.keys.sort{|k1, k2| k1.to_s <=> k2.to_s}
|
180
|
+
orig_keys = mash.keys.map{|k| k.to_sym}.sort{|i1, i2| i1.to_s <=> i2.to_s}
|
181
|
+
|
182
|
+
converted_keys.should == orig_keys
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'preserves value' do
|
186
|
+
mash = Mash.new(@hash)
|
187
|
+
converted = mash.symbolize_keys
|
188
|
+
|
189
|
+
mash.values.sort.should == converted.values.sort
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
|
194
|
+
|
170
195
|
describe "#delete" do
|
171
196
|
it 'converts Symbol key into String before deleting' do
|
172
197
|
mash = Mash.new(@hash)
|
173
198
|
|
174
199
|
mash.delete(:hash)
|
175
|
-
mash.key?("hash").should
|
200
|
+
mash.key?("hash").should be_false
|
176
201
|
end
|
177
202
|
|
178
203
|
it 'works with String keys as well' do
|
179
204
|
mash = Mash.new(@hash)
|
180
205
|
|
181
206
|
mash.delete("mash")
|
182
|
-
mash.key?("mash").should
|
207
|
+
mash.key?("mash").should be_false
|
183
208
|
end
|
184
209
|
end
|
185
210
|
|
@@ -190,22 +215,22 @@ describe Mash do
|
|
190
215
|
mash = Mash.new(@hash)
|
191
216
|
|
192
217
|
hashless_mash = mash.except(:hash)
|
193
|
-
hashless_mash.key?("hash").should
|
218
|
+
hashless_mash.key?("hash").should be_false
|
194
219
|
end
|
195
220
|
|
196
221
|
it "works with String keys as well" do
|
197
222
|
mash = Mash.new(@hash)
|
198
223
|
|
199
224
|
mashless_mash = mash.except("mash")
|
200
|
-
mashless_mash.key?("mash").should
|
225
|
+
mashless_mash.key?("mash").should be_false
|
201
226
|
end
|
202
227
|
|
203
228
|
it "works with multiple keys" do
|
204
229
|
mash = Mash.new(@hash)
|
205
230
|
|
206
231
|
mashless = mash.except("hash", :mash)
|
207
|
-
mashless.key?(:hash).should
|
208
|
-
mashless.key?("mash").should
|
232
|
+
mashless.key?(:hash).should be_false
|
233
|
+
mashless.key?("mash").should be_false
|
209
234
|
end
|
210
235
|
|
211
236
|
it "should return a mash" do
|
data/spec/module_spec.rb
CHANGED
@@ -7,6 +7,8 @@ describe Module do
|
|
7
7
|
module ModBar
|
8
8
|
module Noo
|
9
9
|
module Too
|
10
|
+
module Boo
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
@@ -45,9 +47,19 @@ describe Module do
|
|
45
47
|
end
|
46
48
|
|
47
49
|
it "should find nested constants on nested constants" do
|
48
|
-
Foo::ModBar.find_const('Noo::Too')
|
50
|
+
Foo::ModBar.find_const('Noo::Too').should == Foo::ModBar::Noo::Too
|
49
51
|
end
|
50
52
|
|
53
|
+
it "should find constants outside of nested constants" do
|
54
|
+
Foo::ModBar::Noo::Too.find_const("Zed").should == Foo::Zed
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should be able to find past the second nested level' do
|
58
|
+
Foo::ModBar::Noo.find_const('Too').should == Foo::ModBar::Noo::Too
|
59
|
+
Foo::ModBar::Noo::Too.find_const('Boo').should == Foo::ModBar::Noo::Too::Boo
|
60
|
+
end
|
61
|
+
|
62
|
+
|
51
63
|
it "should be able to deal with constants being added and removed" do
|
52
64
|
Object.find_const('Bar') # First we load Bar with find_const
|
53
65
|
Object.module_eval { remove_const('Bar') } # Now we delete it
|
data/spec/object_spec.rb
CHANGED
@@ -62,35 +62,35 @@ describe Object do
|
|
62
62
|
|
63
63
|
describe "#quacks_like?" do
|
64
64
|
it 'returns true if duck is a Symbol and receiver responds to it' do
|
65
|
-
SymbolicDuck.new.quacks_like?(:quack).should
|
65
|
+
SymbolicDuck.new.quacks_like?(:quack).should be_true
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'returns false if duck is a Symbol and receiver DOES NOT respond to it' do
|
69
|
-
SymbolicDuck.new.quacks_like?(:wtf).should
|
69
|
+
SymbolicDuck.new.quacks_like?(:wtf).should be_false
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'returns true if duck is a class and receiver is its instance' do
|
73
73
|
receiver = ClassyDuck.new
|
74
|
-
receiver.quacks_like?(ClassyDuck).should
|
74
|
+
receiver.quacks_like?(ClassyDuck).should be_true
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'returns false if duck is a class and receiver IS NOT its instance' do
|
78
78
|
receiver = ClassyDuck.new
|
79
|
-
receiver.quacks_like?(SymbolicDuck).should
|
79
|
+
receiver.quacks_like?(SymbolicDuck).should be_false
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'returns true if duck is an array and at least one of its members quacks like this duck' do
|
83
83
|
receiver = ClassyDuck.new
|
84
84
|
ary = [ClassyDuck, SymbolicDuck]
|
85
85
|
|
86
|
-
receiver.quacks_like?(ary).should
|
86
|
+
receiver.quacks_like?(ary).should be_true
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'returns false if duck is an array and none of its members quacks like this duck' do
|
90
90
|
receiver = ClassyDuck.new
|
91
91
|
ary = [SymbolicDuck.new, SymbolicDuck]
|
92
92
|
|
93
|
-
receiver.quacks_like?(ary).should
|
93
|
+
receiver.quacks_like?(ary).should be_false
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -99,16 +99,16 @@ describe Object do
|
|
99
99
|
@ary = [1, 2, 3]
|
100
100
|
@set = Set.new([2, 3, 5])
|
101
101
|
|
102
|
-
1.in?(@ary).should
|
103
|
-
2.in?(@ary).should
|
104
|
-
3.in?(@ary).should
|
105
|
-
4.in?(@ary).should
|
102
|
+
1.in?(@ary).should be_true
|
103
|
+
2.in?(@ary).should be_true
|
104
|
+
3.in?(@ary).should be_true
|
105
|
+
4.in?(@ary).should be_false
|
106
106
|
|
107
|
-
1.in?(@set).should
|
108
|
-
2.in?(@set).should
|
109
|
-
3.in?(@set).should
|
110
|
-
4.in?(@set).should
|
111
|
-
5.in?(@set).should
|
107
|
+
1.in?(@set).should be_false
|
108
|
+
2.in?(@set).should be_true
|
109
|
+
3.in?(@set).should be_true
|
110
|
+
4.in?(@set).should be_false
|
111
|
+
5.in?(@set).should be_true
|
112
112
|
end
|
113
113
|
end
|
114
114
|
end
|
data/spec/pooling_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'timeout'
|
|
3
3
|
|
4
4
|
module Extlib::Pooling
|
5
5
|
class << self
|
6
|
-
remove_method :scavenger_interval if
|
6
|
+
remove_method :scavenger_interval if instance_methods(false).any? { |m| m.to_sym == :scavenger_interval }
|
7
7
|
def scavenger_interval
|
8
8
|
1
|
9
9
|
end
|
@@ -56,7 +56,7 @@ describe "Extlib::Pooling" do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
class << self
|
59
|
-
remove_method :pool_size if
|
59
|
+
remove_method :pool_size if instance_methods(false).any? { |m| m.to_sym == :pool_size }
|
60
60
|
def pool_size
|
61
61
|
pool_size = if RUBY_PLATFORM =~ /java/
|
62
62
|
20
|
@@ -431,7 +431,7 @@ end
|
|
431
431
|
# it "acquires new instances from pool" do
|
432
432
|
# @instance_one = DisposableResource.new
|
433
433
|
#
|
434
|
-
# DisposableResource.pool.acquired?(@instance_one).should
|
434
|
+
# DisposableResource.pool.acquired?(@instance_one).should be_true
|
435
435
|
# end
|
436
436
|
#
|
437
437
|
# it "flushed existing pool on re-initialization" do
|
@@ -483,10 +483,10 @@ end
|
|
483
483
|
#
|
484
484
|
# it "returns true when object's last aquisition time is greater than limit" do
|
485
485
|
# @t1 = DisposableResource.new
|
486
|
-
# DisposableResource.pool.time_to_release?(@t1).should
|
486
|
+
# DisposableResource.pool.time_to_release?(@t1).should be_false
|
487
487
|
#
|
488
488
|
# sleep 3
|
489
|
-
# DisposableResource.pool.time_to_release?(@t1).should
|
489
|
+
# DisposableResource.pool.time_to_release?(@t1).should be_true
|
490
490
|
# end
|
491
491
|
# end
|
492
492
|
#
|
data/spec/simple_set_spec.rb
CHANGED
@@ -19,12 +19,12 @@ describe Extlib::SimpleSet do
|
|
19
19
|
describe "#<<" do
|
20
20
|
it "adds value to the set" do
|
21
21
|
@s << "Hello"
|
22
|
-
@s.to_a.should
|
22
|
+
@s.to_a.should be_include("Hello")
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'sets true mark on the key' do
|
26
26
|
@s << "Fun"
|
27
|
-
@s["Fun"].should
|
27
|
+
@s["Fun"].should be_true
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
metadata
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extlib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Dan Kubb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-05-05 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: Support library for DataMapper and Merb.
|
17
|
-
email:
|
17
|
+
email: dan.kubb@gmail.com
|
18
18
|
executables: []
|
19
19
|
|
20
20
|
extensions: []
|
@@ -28,7 +28,6 @@ files:
|
|
28
28
|
- README
|
29
29
|
- Rakefile
|
30
30
|
- History.txt
|
31
|
-
- lib/extlib
|
32
31
|
- lib/extlib/array.rb
|
33
32
|
- lib/extlib/assertions.rb
|
34
33
|
- lib/extlib/blank.rb
|
@@ -56,7 +55,6 @@ files:
|
|
56
55
|
- lib/extlib/string.rb
|
57
56
|
- lib/extlib/struct.rb
|
58
57
|
- lib/extlib/symbol.rb
|
59
|
-
- lib/extlib/tasks
|
60
58
|
- lib/extlib/tasks/release.rb
|
61
59
|
- lib/extlib/time.rb
|
62
60
|
- lib/extlib/version.rb
|
@@ -69,7 +67,6 @@ files:
|
|
69
67
|
- spec/datetime_spec.rb
|
70
68
|
- spec/hash_spec.rb
|
71
69
|
- spec/hook_spec.rb
|
72
|
-
- spec/inflection
|
73
70
|
- spec/inflection/plural_spec.rb
|
74
71
|
- spec/inflection/singular_spec.rb
|
75
72
|
- spec/inflection_extras_spec.rb
|
@@ -92,6 +89,8 @@ files:
|
|
92
89
|
- spec/virtual_file_spec.rb
|
93
90
|
has_rdoc: false
|
94
91
|
homepage: http://extlib.rubyforge.org
|
92
|
+
licenses: []
|
93
|
+
|
95
94
|
post_install_message:
|
96
95
|
rdoc_options: []
|
97
96
|
|
@@ -112,9 +111,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
111
|
requirements: []
|
113
112
|
|
114
113
|
rubyforge_project:
|
115
|
-
rubygems_version: 1.3.
|
114
|
+
rubygems_version: 1.3.2
|
116
115
|
signing_key:
|
117
|
-
specification_version:
|
116
|
+
specification_version: 3
|
118
117
|
summary: Support library for DataMapper and Merb.
|
119
118
|
test_files: []
|
120
119
|
|