prop 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
data/lib/prop.rb CHANGED
@@ -2,7 +2,7 @@ require "prop/limiter"
2
2
  require "forwardable"
3
3
 
4
4
  module Prop
5
- VERSION = "0.7.5"
5
+ VERSION = "0.7.6"
6
6
 
7
7
  # Short hand for accessing Prop::Limiter methods
8
8
  class << self
data/lib/prop/limiter.rb CHANGED
@@ -57,7 +57,8 @@ module Prop
57
57
  if at_threshold?(counter, options[:threshold])
58
58
  raise Prop::RateLimited.new(options.merge(:cache_key => cache_key, :handle => handle))
59
59
  else
60
- counter = writer.call(cache_key, counter + [ 1, options[:increment].to_i ].max)
60
+ increment = options.key?(:increment) ? options[:increment].to_i : 1
61
+ counter = writer.call(cache_key, counter + increment)
61
62
  end
62
63
  end
63
64
 
data/prop.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'prop'
16
- s.version = '0.7.5'
16
+ s.version = '0.7.6'
17
17
  s.date = '2012-04-06'
18
18
  s.rubyforge_project = 'prop'
19
19
 
data/test/test_limiter.rb CHANGED
@@ -51,6 +51,12 @@ class TestLimiter < Test::Unit::TestCase
51
51
  should "raise Prop::RateLimited" do
52
52
  assert_raises(Prop::RateLimited) { Prop.throttle!(:something) { "wibble" }}
53
53
  end
54
+
55
+ should "raise even if given :increment => 0" do
56
+ value = Prop.count(:something)
57
+ assert_raises(Prop::RateLimited) { Prop.throttle!(:something, nil, :increment => 0) { "wibble" }}
58
+ assert_equal value, Prop.count(:something)
59
+ end
54
60
  end
55
61
 
56
62
  context "not given a block" do
@@ -75,6 +81,10 @@ class TestLimiter < Test::Unit::TestCase
75
81
  should "return the updated throttle count" do
76
82
  assert_equal Prop.count(:something) + 1, Prop.throttle!(:something)
77
83
  end
84
+
85
+ should "not update count if passed an increment of 0" do
86
+ assert_equal Prop.count(:something), Prop.throttle!(:something, nil, :increment => 0)
87
+ end
78
88
  end
79
89
  end
80
90
  end
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: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 5
10
- version: 0.7.5
9
+ - 6
10
+ version: 0.7.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Morten Primdahl