ratelimit 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/CHANGELOG.md +3 -0
- data/lib/ratelimit.rb +3 -0
- data/lib/ratelimit/version.rb +1 -1
- data/spec/ratelimit_spec.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9759fc3e7da10acf75e0b15ba6f90a901257543
|
4
|
+
data.tar.gz: b3bcdc0daa3076dfe081942e90a922125a772019
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4a346d5455ff73cd2218f312ac08f098f2acc80041995a1b9e00ad93dfa37ba27d27be293c2a741f15e2963416083008e7aecdac3f7f96498f32eef37d39a8b
|
7
|
+
data.tar.gz: 7af9dcaddc5bf2f17cb8d335384c3f87eda9336fd0303f3ad8b7ec1c99bdd9c81bcec37cc7e491d77548c974a19b7abcebfc475d694f51398cb941d346fc1334
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/ratelimit.rb
CHANGED
@@ -26,6 +26,9 @@ class Ratelimit
|
|
26
26
|
raise ArgumentError.new("Bucket expiry cannot be larger than the bucket span")
|
27
27
|
end
|
28
28
|
@bucket_count = (@bucket_span / @bucket_interval).round
|
29
|
+
if @bucket_count < 3
|
30
|
+
raise ArgumentError.new("Cannot have less than 3 buckets")
|
31
|
+
end
|
29
32
|
@redis = options[:redis]
|
30
33
|
end
|
31
34
|
|
data/lib/ratelimit/version.rb
CHANGED
data/spec/ratelimit_spec.rb
CHANGED
@@ -11,6 +11,12 @@ describe Ratelimit do
|
|
11
11
|
expect(@r.instance_variable_get(:@bucket_span)).to eq(@r.instance_variable_get(:@bucket_expiry))
|
12
12
|
end
|
13
13
|
|
14
|
+
it "should not allow bucket count less than 3" do
|
15
|
+
expect do
|
16
|
+
Ratelimit.new("key", {:bucket_span => 1, :bucket_interval => 1})
|
17
|
+
end.to raise_error(ArgumentError)
|
18
|
+
end
|
19
|
+
|
14
20
|
it "should not allow bucket expiry to be larger than the bucket span" do
|
15
21
|
expect do
|
16
22
|
Ratelimit.new("key", {:bucket_expiry => 1200})
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ratelimit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- E.J. Finneran
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|