prop 2.2.2 → 2.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/prop.rb +1 -1
- data/lib/prop/interval_strategy.rb +4 -4
- data/lib/prop/leaky_bucket_strategy.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc6f4c4c65b63f97ad2ae286c7bdfcba9340e392
|
4
|
+
data.tar.gz: b5757a4efe766900a87c73f3631ea28d26924ef1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bb9cbe78d81e7bca791d46f67c6ef1776c7c939f56656ed53b05b8568a2e08dc9b2b738e056c38ce3586f68f8e9b7f4a02ff1fd736be29c0d70bf9acf015cee
|
7
|
+
data.tar.gz: 34d62bedf1c439e6fa784a19b9a0f59e6dd8bbe2d152cceda3f63b5fbd58db603e43212d6d786ed2a36294fe6f73db5e0f58cc94c86656a34702d0b958216983
|
data/lib/prop.rb
CHANGED
@@ -15,12 +15,12 @@ module Prop
|
|
15
15
|
|
16
16
|
# options argument is kept for api consistency for all strategies
|
17
17
|
def increment(cache_key, amount, options = {})
|
18
|
-
raise ArgumentError, "Change amount must be a
|
18
|
+
raise ArgumentError, "Change amount must be a Integer, was #{amount.class}" unless amount.is_a?(Integer)
|
19
19
|
cache.increment(cache_key, amount) || (cache.write(cache_key, amount, raw: true) && amount) # WARNING: potential race condition
|
20
20
|
end
|
21
21
|
|
22
22
|
def decrement(cache_key, amount, options = {})
|
23
|
-
raise ArgumentError, "Change amount must be a
|
23
|
+
raise ArgumentError, "Change amount must be a Integer, was #{amount.class}" unless amount.is_a?(Integer)
|
24
24
|
cache.decrement(cache_key, amount) || (cache.write(cache_key, 0, raw: true) && 0) # WARNING: potential race condition
|
25
25
|
end
|
26
26
|
|
@@ -61,14 +61,14 @@ module Prop
|
|
61
61
|
|
62
62
|
amount = options[:increment] || options[:decrement]
|
63
63
|
if amount
|
64
|
-
raise ArgumentError.new(":increment or :decrement must be zero or a positive Integer") if !amount.is_a?(
|
64
|
+
raise ArgumentError.new(":increment or :decrement must be zero or a positive Integer") if !amount.is_a?(Integer) || amount < 0
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
private
|
69
69
|
|
70
70
|
def validate_positive_integer(option, key)
|
71
|
-
raise ArgumentError.new("#{key.inspect} must be a positive Integer") if !option.is_a?(
|
71
|
+
raise ArgumentError.new("#{key.inspect} must be a positive Integer") if !option.is_a?(Integer) || option <= 0
|
72
72
|
end
|
73
73
|
|
74
74
|
def cache
|
@@ -59,7 +59,7 @@ module Prop
|
|
59
59
|
def validate_options!(options)
|
60
60
|
Prop::IntervalStrategy.validate_options!(options)
|
61
61
|
|
62
|
-
if !options[:burst_rate].is_a?(
|
62
|
+
if !options[:burst_rate].is_a?(Integer) || options[:burst_rate] < options[:threshold]
|
63
63
|
raise ArgumentError.new(":burst_rate must be an Integer and not less than :threshold")
|
64
64
|
end
|
65
65
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Morten Primdahl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
118
|
rubyforge_project:
|
119
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.6.11
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: Gem for implementing rate limits.
|