rack-throttle 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 850818d2e52bb001216cc4083e24ca1a595a8735
4
- data.tar.gz: 2689fae4f389e86443c325496d95f41b941c8a76
3
+ metadata.gz: 7823180e20dd3ab553a305842fb9f785894953bd
4
+ data.tar.gz: 9781b73ca8565c8f9123d6100e6fd7729c707d5b
5
5
  SHA512:
6
- metadata.gz: e3b0621c095098a34aa93335dddac8e15d3baf9c1ca45134913535d161a6ab69b35d56c5467d43169d068a593cbf2d3ec57bd456d5f4ca90d4735642fff256c2
7
- data.tar.gz: 851fa5a4128f3d90623d4c867f777b177d4cc1657477a4274b42353a971bae5c4b858bc10de91645f1319349320154b4b0ac0720598f90c44794d067114b4785
6
+ metadata.gz: 0a0828b9d713cb79ba08b694e9163bc22acd86b763b16cd054afb37f3e04ea938fa34c1757d01f4cd2e546b3bda196bc83f0777d232744fb7b098409da9c5461
7
+ data.tar.gz: afc4bb326fb276937dde75cb37db310313e5c87c4d134cef3b25bb4e3dc53ea453e1913514109c35ab58792b40a72897840964a8286aee0fc4a3d956b15e50f4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.5.0
@@ -26,7 +26,7 @@ module Rack; module Throttle
26
26
  end
27
27
 
28
28
  ##
29
- def max_per_day
29
+ def max_per_day(request = nil)
30
30
  @max_per_hour ||= options[:max_per_day] || options[:max] || 86_400
31
31
  end
32
32
 
@@ -26,7 +26,7 @@ module Rack; module Throttle
26
26
  end
27
27
 
28
28
  ##
29
- def max_per_hour
29
+ def max_per_hour(request = nil)
30
30
  @max_per_hour ||= options[:max_per_hour] || options[:max] || 3_600
31
31
  end
32
32
 
@@ -25,7 +25,7 @@ module Rack; module Throttle
25
25
  end
26
26
 
27
27
  ##
28
- def max_per_minute
28
+ def max_per_minute(request = nil)
29
29
  @max_per_minute ||= options[:max_per_minute] || options[:max] || 60
30
30
  end
31
31
 
@@ -24,7 +24,7 @@ module Rack; module Throttle
24
24
  end
25
25
 
26
26
  ##
27
- def max_per_second
27
+ def max_per_second(request = nil)
28
28
  @max_per_second ||= options[:max_per_second] || options[:max] || 1
29
29
  end
30
30
 
@@ -10,7 +10,7 @@ module Rack; module Throttle
10
10
  def allowed?(request)
11
11
  return true if whitelisted?(request)
12
12
  count = cache_get(key = cache_key(request)).to_i + 1 rescue 1
13
- allowed = count <= max_per_window.to_i
13
+ allowed = count <= max_per_window(request).to_i
14
14
  begin
15
15
  cache_set(key, count)
16
16
  allowed
@@ -1,8 +1,8 @@
1
1
  module Rack; module Throttle
2
2
  module VERSION
3
3
  MAJOR = 0
4
- MINOR = 4
5
- TINY = 2
4
+ MINOR = 5
5
+ TINY = 0
6
6
  EXTRA = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-throttle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arto Bendiken
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-04 00:00:00.000000000 Z
11
+ date: 2017-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler