resque-throttle 0.2.4 → 0.2.6

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.2.6
@@ -1,13 +1,8 @@
1
1
  module Resque
2
- class SettingNotFound < RuntimeError; end
3
-
4
2
  class ThrottledJob
5
3
 
6
4
  THROTTLE_DEFAULTS = {
7
5
  :can_run_every => 1800,
8
- :enqueued => 'Your job has been submitted. You will receive an email with a download link shortly.',
9
- :throttled => 'Frequency has been exceeded. Job not submitted. Try again a little later.',
10
- :latest => 'Download the most recent result',
11
6
  :disabled => false,
12
7
  :identifier => nil
13
8
  }
@@ -24,9 +19,16 @@ module Resque
24
19
  [self.to_s, identifier].compact.join(":")
25
20
  end
26
21
 
27
- def self.method_missing(method, *args)
28
- raise SettingNotFound("Could not find the #{method} setting") if !settings.key?(method)
29
- settings[method]
22
+ def self.can_run_every
23
+ settings[:can_run_every]
24
+ end
25
+
26
+ def self.disabled
27
+ settings[:disabled]
28
+ end
29
+
30
+ def self.identifier
31
+ settings[:identifier]
30
32
  end
31
33
  end
32
34
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{resque-throttle}
8
- s.version = "0.2.4"
8
+ s.version = "0.2.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Scott J. Tamosunas"]
12
- s.date = %q{2010-02-18}
12
+ s.date = %q{2010-02-19}
13
13
  s.description = %q{resque-throttle is an extension to the resque queue system that restricts the frequency in which certain jobs are run. Add more description here.}
14
14
  s.email = %q{tamosunas@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -7,7 +7,8 @@ class ThrottledJobTest < Test::Unit::TestCase
7
7
  assert Resque::ThrottledJob.new
8
8
  end
9
9
 
10
- context "settings" do
10
+ context "settings (private methods)" do
11
+
11
12
  context "#can_run_every" do
12
13
  should "return the number of seconds in which to throttle these jobs" do
13
14
  assert_equal 3600, OneHourThrottledJob.can_run_every
@@ -28,36 +29,6 @@ class ThrottledJobTest < Test::Unit::TestCase
28
29
  end
29
30
  end
30
31
 
31
- context "#enqueued" do
32
- should "have a default message if not overrriden" do
33
- assert_equal "Your job has been submitted. You will receive an email with a download link shortly.", DefaultThrottledJob.enqueued
34
- end
35
-
36
- should "be able to be overriden" do
37
- assert_equal "Yada Yada", OneHourThrottledJob.enqueued
38
- end
39
- end
40
-
41
- context "#throttled" do
42
- should "have a default message if not overrriden" do
43
- assert_equal "Frequency has been exceeded. Job not submitted. Try again a little later.", DefaultThrottledJob.throttled
44
- end
45
-
46
- should "be able to be overriden" do
47
- assert_equal "Yada Yada", OneHourThrottledJob.throttled
48
- end
49
- end
50
-
51
- context "#latest" do
52
- should "have a default message if not overrriden" do
53
- assert_equal "Download the most recent result", DefaultThrottledJob.latest
54
- end
55
-
56
- should "be able to be overriden" do
57
- assert_equal "Yada Yada", OneHourThrottledJob.latest
58
- end
59
- end
60
-
61
32
  context "#disabled" do
62
33
  should "not be disabled by default" do
63
34
  assert !DefaultThrottledJob.disabled
data/test/test_helper.rb CHANGED
@@ -22,12 +22,7 @@ end
22
22
 
23
23
  class OneHourThrottledJob < Resque::ThrottledJob
24
24
  @queue = :some_queue
25
-
26
- throttle :can_run_every => 3600,
27
- :enqueued => "Yada Yada",
28
- :throttled => "Yada Yada",
29
- :latest => "Yada Yada"
30
-
25
+ throttle :can_run_every => 3600
31
26
 
32
27
  def self.perform(some_id, some_other_thing)
33
28
  end
@@ -35,7 +30,6 @@ end
35
30
 
36
31
  class IdetifierThrottledJob < Resque::ThrottledJob
37
32
  @queue = :some_queue
38
-
39
33
  throttle :identifier => "my_identifier"
40
34
 
41
35
  def self.perform(some_id, some_other_thing)
@@ -44,7 +38,6 @@ end
44
38
 
45
39
  class DisabledThrottledJob < Resque::ThrottledJob
46
40
  @queue = :some_queue
47
-
48
41
  throttle :disabled => true
49
42
 
50
43
  def self.perform(some_id, some_other_thing)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-throttle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott J. Tamosunas
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-18 00:00:00 -08:00
12
+ date: 2010-02-19 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency