prop 0.3.4 → 0.3.5

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/prop.rb +8 -6
  3. data/prop.gemspec +1 -1
  4. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
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
- attr_reader :root_message, :retry_after
11
+ attr_accessor :root_message, :retry_after
12
12
 
13
- def initialize(key, threshold, message)
14
- @root_message = "#{key} threshold #{threshold} exceeded"
15
- @retry_after = Time.now.to_i % threshold.to_i
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
- super(message || @root_message)
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.new(options[:key], options[:threshold], options[:message])
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{prop}
8
- s.version = "0.3.4"
8
+ s.version = "0.3.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Morten Primdahl"]
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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 4
10
- version: 0.3.4
9
+ - 5
10
+ version: 0.3.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Morten Primdahl