Permalink
Browse files

v0.1.1

  • Loading branch information...
1 parent 6f966e9 commit 8874f3a8e65114dba1e1afa374e838fc6418432a @benbjohnson committed Jan 28, 2011
Showing with 23 additions and 8 deletions.
  1. +3 −0 CHANGELOG
  2. +1 −1 Gemfile.lock
  3. +9 −6 lib/slow_web/ext/net_http.rb
  4. +1 −1 lib/slow_web/version.rb
  5. +9 −0 spec/net_http_spec.rb
View
@@ -1,2 +1,5 @@
+v0.1.1
+* Fix bug when accessing non-limited hosts.
+
v0.1.0
* Initial release.
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- slowweb (0.1.0)
+ slowweb (0.1.1)
GEM
remote: http://rubygems.org/
@@ -7,13 +7,16 @@ def request_with_slowweb(request, body = nil, &block)
host = self.address
limit = SlowWeb.get_limit(host)
- # Wait until the request limit is no longer exceeded
- while limit.exceeded?
- sleep 1
- end
+ # Manage this request if it has been limited
+ if !limit.nil?
+ # Wait until the request limit is no longer exceeded
+ while limit.exceeded?
+ sleep 1
+ end
- # Add request to limiter
- limit.add_request(request)
+ # Add request to limiter
+ limit.add_request(request)
+ end
# Continue with the original request
request_without_slowweb(request, body, &block)
View
@@ -1,3 +1,3 @@
class SlowWeb
- VERSION = '0.1.0'
+ VERSION = '0.1.1'
end
View
@@ -44,4 +44,13 @@
open('http://github.com')
(Time.now-t).should > 1
end
+
+ it 'should ignore unlimited hosts' do
+ FakeWeb.register_uri(:get, 'http://google.com', :body => 'bar')
+ SlowWeb.limit('github.com', 3, 60)
+ open('http://google.com')
+ open('http://google.com')
+ open('http://google.com')
+ open('http://google.com')
+ end
end

0 comments on commit 8874f3a

Please sign in to comment.