prop 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -74,9 +74,9 @@ Prop ships with a built in Rack middleware that you can use to do all the except
74
74
 
75
75
  Where `Retry-After` is the number of seconds the client has to wait before retrying this end point. The body of this response is whatever description Prop has configured for the throttle that got violated, or a default string if there's none configured.
76
76
 
77
- If you wish to do manual error messaging in these cases, you can define an error handler in your Prop configuration. Here's how the default error handler looks, feel free to replace it with your own - you can set the error handler to anything that responds to `.call` and takes a `RateLimited` instance as argument:
77
+ If you wish to do manual error messaging in these cases, you can define an error handler in your Prop configuration. Here's how the default error handler looks, feel free to replace it with your own - you can set the error handler to anything that responds to `.call` and takes the environment and a `RateLimited` instance as argument:
78
78
 
79
- error_handler = Proc.new do |error|
79
+ error_handler = Proc.new do |env, error|
80
80
  body = error.description || "This action has been rate limited"
81
81
  headers = { "Content-Type" => "text/plain", "Content-Length" => body.size, "Retry-After" => error.retry_after }
82
82
 
@@ -2,7 +2,7 @@ require "prop/limiter"
2
2
  require "forwardable"
3
3
 
4
4
  module Prop
5
- VERSION = "0.7.1"
5
+ VERSION = "0.7.2"
6
6
 
7
7
  # Short hand for accessing Prop::Limiter methods
8
8
  class << self
@@ -6,7 +6,7 @@ module Prop
6
6
 
7
7
  # Default error handler
8
8
  class DefaultErrorHandler
9
- def self.call(error)
9
+ def self.call(env, error)
10
10
  body = error.description || "This action has been rate limited"
11
11
  headers = { "Content-Type" => "text/plain", "Content-Length" => body.size, "Retry-After" => error.retry_after }
12
12
 
@@ -24,7 +24,7 @@ module Prop
24
24
  begin
25
25
  @app.call(env)
26
26
  rescue Prop::RateLimited => e
27
- @handler.call(e)
27
+ @handler.call(env, e)
28
28
  end
29
29
  end
30
30
  end
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'prop'
16
- s.version = '0.7.1'
16
+ s.version = '0.7.2'
17
17
  s.date = '2012-04-06'
18
18
  s.rubyforge_project = 'prop'
19
19
 
@@ -35,7 +35,7 @@ class TestMiddleware < Test::Unit::TestCase
35
35
 
36
36
  context "with a custom error handler" do
37
37
  setup do
38
- @middleware = Prop::Middleware.new(@app, :error_handler => Proc.new { |error| "Oops" })
38
+ @middleware = Prop::Middleware.new(@app, :error_handler => Proc.new { |env, error| "Oops" })
39
39
  end
40
40
 
41
41
  should "allow setting a custom error handler" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prop
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 1
10
- version: 0.7.1
9
+ - 2
10
+ version: 0.7.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Morten Primdahl