resource_pool 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/lib/resource_pool.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  class ResourcePool
2
2
  class ResourcePoolError < RuntimeError; end
3
- class PoolTimeout < ResourcePoolError; end
3
+ class ResourceNotAvailable < ResourcePoolError; end
4
4
  class BadResource < ResourcePoolError; end
5
5
  class InvalidCreateProc < ResourcePoolError; end
6
6
 
@@ -37,12 +37,13 @@ class ResourcePool
37
37
  end
38
38
  begin
39
39
  unless res = acquire(t)
40
+ raise ResourceNotAvailable if @timeout == 0
40
41
  time = Time.now
41
42
  timeout = time + @timeout
42
43
  sleep_time = @sleep_time
43
44
  sleep sleep_time
44
45
  until res = acquire(t)
45
- raise PoolTimeout if Time.now > timeout
46
+ raise ResourceNotAvailable if Time.now > timeout
46
47
  sleep sleep_time
47
48
  end
48
49
  end
@@ -0,0 +1,59 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{resource_pool}
8
+ s.version = "0.1.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = [%q{Aaron Qian}]
12
+ s.date = %q{2011-10-13}
13
+ s.description = %q{A gem for generic connection pooling / resource pooling. The code is mostly taken from Sequel gem's ThreadedConnectionPool class, and adapted for more general use.}
14
+ s.email = %q{aq1018@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/resource_pool.rb",
28
+ "resource_pool.gemspec",
29
+ "spec/resource_pool_spec.rb",
30
+ "spec/spec_helper.rb"
31
+ ]
32
+ s.homepage = %q{http://github.com/aq1018/resource_pool}
33
+ s.licenses = [%q{MIT}]
34
+ s.require_paths = [%q{lib}]
35
+ s.rubygems_version = %q{1.8.6}
36
+ s.summary = %q{A gem for generic connection pooling / resource pooling.}
37
+
38
+ if s.respond_to? :specification_version then
39
+ s.specification_version = 3
40
+
41
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
43
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
44
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
45
+ s.add_development_dependency(%q<rcov>, [">= 0"])
46
+ else
47
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
48
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
49
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
50
+ s.add_dependency(%q<rcov>, [">= 0"])
51
+ end
52
+ else
53
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
54
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
55
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
56
+ s.add_dependency(%q<rcov>, [">= 0"])
57
+ end
58
+ end
59
+
@@ -279,7 +279,7 @@ describe "ResourcePool" do
279
279
  start = Time.now
280
280
  lambda {
281
281
  @pool.hold{ |res| res.should == @res }
282
- }.should raise_error(ResourcePool::PoolTimeout)
282
+ }.should raise_error(ResourcePool::ResourceNotAvailable)
283
283
 
284
284
  delta = Time.now - start
285
285
  delta.should be_between(1.99, 2.01)
metadata CHANGED
@@ -1,94 +1,70 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: resource_pool
3
- version: !ruby/object:Gem::Version
4
- hash: 25
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Aaron Qian
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-10-12 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2011-10-13 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &14549840 !ruby/object:Gem::Requirement
22
17
  none: false
23
- requirements:
18
+ requirements:
24
19
  - - ~>
25
- - !ruby/object:Gem::Version
26
- hash: 3
27
- segments:
28
- - 2
29
- - 3
30
- - 0
20
+ - !ruby/object:Gem::Version
31
21
  version: 2.3.0
32
- version_requirements: *id001
33
- name: rspec
34
- prerelease: false
35
22
  type: :development
36
- - !ruby/object:Gem::Dependency
37
- requirement: &id002 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ version_requirements: *14549840
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &15026640 !ruby/object:Gem::Requirement
38
28
  none: false
39
- requirements:
29
+ requirements:
40
30
  - - ~>
41
- - !ruby/object:Gem::Version
42
- hash: 23
43
- segments:
44
- - 1
45
- - 0
46
- - 0
31
+ - !ruby/object:Gem::Version
47
32
  version: 1.0.0
48
- version_requirements: *id002
49
- name: bundler
50
- prerelease: false
51
33
  type: :development
52
- - !ruby/object:Gem::Dependency
53
- requirement: &id003 !ruby/object:Gem::Requirement
34
+ prerelease: false
35
+ version_requirements: *15026640
36
+ - !ruby/object:Gem::Dependency
37
+ name: jeweler
38
+ requirement: &15057820 !ruby/object:Gem::Requirement
54
39
  none: false
55
- requirements:
40
+ requirements:
56
41
  - - ~>
57
- - !ruby/object:Gem::Version
58
- hash: 7
59
- segments:
60
- - 1
61
- - 6
62
- - 4
42
+ - !ruby/object:Gem::Version
63
43
  version: 1.6.4
64
- version_requirements: *id003
65
- name: jeweler
66
- prerelease: false
67
44
  type: :development
68
- - !ruby/object:Gem::Dependency
69
- requirement: &id004 !ruby/object:Gem::Requirement
70
- none: false
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- hash: 3
75
- segments:
76
- - 0
77
- version: "0"
78
- version_requirements: *id004
79
- name: rcov
80
45
  prerelease: false
46
+ version_requirements: *15057820
47
+ - !ruby/object:Gem::Dependency
48
+ name: rcov
49
+ requirement: &15060420 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
81
55
  type: :development
82
- description: A gem for generic connection pooling / resource pooling. The code is mostly taken from Sequel gem's ThreadedConnectionPool class, and adapted for more general use.
56
+ prerelease: false
57
+ version_requirements: *15060420
58
+ description: A gem for generic connection pooling / resource pooling. The code is
59
+ mostly taken from Sequel gem's ThreadedConnectionPool class, and adapted for more
60
+ general use.
83
61
  email: aq1018@gmail.com
84
62
  executables: []
85
-
86
63
  extensions: []
87
-
88
- extra_rdoc_files:
64
+ extra_rdoc_files:
89
65
  - LICENSE.txt
90
66
  - README.rdoc
91
- files:
67
+ files:
92
68
  - .document
93
69
  - .rspec
94
70
  - Gemfile
@@ -97,40 +73,35 @@ files:
97
73
  - Rakefile
98
74
  - VERSION
99
75
  - lib/resource_pool.rb
76
+ - resource_pool.gemspec
100
77
  - spec/resource_pool_spec.rb
101
78
  - spec/spec_helper.rb
102
79
  homepage: http://github.com/aq1018/resource_pool
103
- licenses:
80
+ licenses:
104
81
  - MIT
105
82
  post_install_message:
106
83
  rdoc_options: []
107
-
108
- require_paths:
84
+ require_paths:
109
85
  - lib
110
- required_ruby_version: !ruby/object:Gem::Requirement
86
+ required_ruby_version: !ruby/object:Gem::Requirement
111
87
  none: false
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- hash: 3
116
- segments:
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ segments:
117
93
  - 0
118
- version: "0"
119
- required_rubygems_version: !ruby/object:Gem::Requirement
94
+ hash: -2898749747760156030
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
96
  none: false
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- hash: 3
125
- segments:
126
- - 0
127
- version: "0"
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
128
101
  requirements: []
129
-
130
102
  rubyforge_project:
131
103
  rubygems_version: 1.8.6
132
104
  signing_key:
133
105
  specification_version: 3
134
106
  summary: A gem for generic connection pooling / resource pooling.
135
107
  test_files: []
136
-