prop 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/prop.rb +8 -6
- data/prop.gemspec +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.5
|
data/lib/prop.rb
CHANGED
@@ -8,13 +8,15 @@ end
|
|
8
8
|
|
9
9
|
class Prop
|
10
10
|
class RateLimitExceededError < RuntimeError
|
11
|
-
|
11
|
+
attr_accessor :root_message, :retry_after
|
12
12
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
13
|
+
def self.create(key, threshold, message)
|
14
|
+
default = "#{key} threshold #{threshold} exceeded"
|
15
|
+
error = new(message || default)
|
16
|
+
error.retry_after = threshold - Time.now.to_i % threshold
|
17
|
+
error.root_message = default
|
16
18
|
|
17
|
-
|
19
|
+
raise error
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
@@ -54,7 +56,7 @@ class Prop
|
|
54
56
|
counter = count(options)
|
55
57
|
|
56
58
|
if counter >= options[:threshold]
|
57
|
-
raise Prop::RateLimitExceededError.
|
59
|
+
raise Prop::RateLimitExceededError.create(options[:key], options[:threshold], options[:message])
|
58
60
|
else
|
59
61
|
writer.call(sanitized_prop_key(options), counter + 1)
|
60
62
|
end
|
data/prop.gemspec
CHANGED
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:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 5
|
10
|
+
version: 0.3.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Morten Primdahl
|