rock-queue 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -7,14 +7,13 @@ $LOAD_PATH.unshift 'lib'
7
7
  require 'rock-queue/tasks'
8
8
 
9
9
  GEM = "rock-queue"
10
- GEM_VERSION = "0.3.1"
10
+ GEM_VERSION = "0.3.2"
11
11
  SUMMARY = "A unified interface for various messaging queues"
12
- AUTHORS = ["Grzegorz Kazulak", "Wojtek Mach", "Piotr Chmolowski", "Daniel Chrusciak"]
12
+ AUTHORS = ["Grzegorz Kazulak"]
13
13
  EMAIL = "gregorz.kazulak@gmail.com"
14
14
  HOMEPAGE = "http://github.com/grzegorzkazulak/rock-queue"
15
15
 
16
16
  begin
17
- gem 'jeweler', '~> 1.4'
18
17
  require 'jeweler'
19
18
  Jeweler::Tasks.new do |gem|
20
19
  gem.name = GEM
@@ -39,7 +38,6 @@ begin
39
38
  gem.extra_rdoc_files = ["LICENSE"]
40
39
  end
41
40
  Jeweler::GemcutterTasks.new
42
- FileList['tasks/**/*.rake'].each { |task| import task }
43
41
  rescue LoadError
44
42
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
45
43
  end
@@ -22,12 +22,11 @@ module RockQueue
22
22
 
23
23
  module InstanceMethods
24
24
  def async(method, *args)
25
- RockQueue.push self.class.queue, self.class, id, method, *args
25
+ RockQueue.push(self.class.queue, self.class, id, method, *args)
26
26
  end
27
27
 
28
28
  def async_at(method, time_to_run_at, *args)
29
- RockQueue.push_at(
30
- self.class.queue, self.class, time_to_run_at, id, method, *args)
29
+ RockQueue.push_at(self.class, time_to_run_at, method, id, *args)
31
30
  end
32
31
  end
33
32
  end
@@ -29,7 +29,9 @@ module RockQueue
29
29
  end
30
30
 
31
31
  def clear
32
- system "killall beanstalkd"
32
+ kill_cmd = `which killall`.empty? ? "pkill" : "killall"
33
+
34
+ system "#{kill_cmd} beanstalkd"
33
35
  system "beanstalkd -d -p #{@options[:port]}"
34
36
  end
35
37
 
@@ -28,12 +28,14 @@ module RockQueue
28
28
  end
29
29
 
30
30
  # Push items to Resque queue to be picked up by the worker on specified time
31
- def push_at(value, time_to_run_at ,*args)
31
+ def push_at(value, time_to_run_at, *args)
32
32
  if !defined?(value.queue)
33
33
  value.class_eval do
34
34
  @queue = :default
35
35
  end
36
36
  end
37
+
38
+ raise "resque_scheduler is required" unless Resque.respond_to?(:enqueue_at)
37
39
  Resque.enqueue_at time_to_run_at, value, args
38
40
  end
39
41
 
@@ -41,7 +43,7 @@ module RockQueue
41
43
  def pop(queue)
42
44
  job = Resque.reserve(queue)
43
45
  [job.payload_class, job.args] if job
44
- end
46
+ end
45
47
 
46
48
  # Register worker for web interface
47
49
  def register_worker(worker)
@@ -1,4 +1,5 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
+ require 'resque_scheduler'
2
3
 
3
4
  RockQueue.setup(
4
5
  :adapter => :resque,
@@ -15,9 +16,27 @@ describe "Object with ActiveRecordHelper" do
15
16
  it "class responds to .perform" do
16
17
  @post.class.perform([@post.id, :title]).should == "Test"
17
18
  end
19
+
20
+ it "should respond to queue" do
21
+ @post.class.queue.should == :default
22
+ end
18
23
 
19
24
  it "calls a method asynchronously" do
20
25
  @post.async(:archive)
21
26
  RockQueue.pop(:default).should == [Post, [[@post.id, "archive"]]]
22
27
  end
28
+
29
+ it "calls a method asynchronously at a given time" do
30
+ time = Time.now.to_i + 3600
31
+
32
+ Resque.delayed_queue_schedule_size.should == 0
33
+ @post.async_at(:archive, time)
34
+
35
+ Resque.delayed_queue_schedule_size.should == 1
36
+ Resque.next_item_for_timestamp(time).should == {
37
+ "args" => [["archive", @post.id]],
38
+ "class" => "Post",
39
+ "queue" => "default"
40
+ }
41
+ end
23
42
  end
@@ -0,0 +1,15 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ require "mail"
4
+
5
+ describe "Notifiers" do
6
+ it "registers an observer" do
7
+ notifiers = RockQueue::Notifiers.instance
8
+ notifier = RockQueue::EmailNotifier.new({:from => "joe@localhost", :to => "mike@localhost"})
9
+
10
+ notifiers.count_observers.should == 0
11
+ notifiers.register(notifier)
12
+ notifiers.count_observers.should == 1
13
+ notifiers.delete_observers
14
+ end
15
+ end
@@ -1,5 +1,11 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
+ RockQueue.setup(
4
+ :adapter => :resque,
5
+ :server => 'localhost',
6
+ :port => 6379
7
+ )
8
+
3
9
  describe "ResqueQueue" do
4
10
  before(:each) do
5
11
  @adapter = RockQueue::ResqueQueue.new(:server => 'localhost', :port => 6379)
@@ -7,4 +13,10 @@ describe "ResqueQueue" do
7
13
  end
8
14
 
9
15
  it_should_behave_like "RockQueue adapter"
16
+
17
+ it "should register worker" do
18
+ worker = RockQueue::Worker.new(:default)
19
+ @adapter.register_worker(worker)
20
+ Resque.redis.sismember(:workers, worker).should == true
21
+ end
10
22
  end
metadata CHANGED
@@ -1,35 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rock-queue
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 3
9
- - 1
10
- version: 0.3.1
8
+ - 2
9
+ version: 0.3.2
11
10
  platform: ruby
12
11
  authors:
13
12
  - Grzegorz Kazulak
14
- - Wojtek Mach
15
- - Piotr Chmolowski
16
- - Daniel Chrusciak
17
13
  autorequire: rock-queue
18
14
  bindir: bin
19
15
  cert_chain: []
20
16
 
21
- date: 2010-07-30 00:00:00 +02:00
17
+ date: 2010-07-31 00:00:00 +02:00
22
18
  default_executable:
23
19
  dependencies:
24
20
  - !ruby/object:Gem::Dependency
25
21
  name: rspec
26
22
  prerelease: false
27
23
  requirement: &id001 !ruby/object:Gem::Requirement
28
- none: false
29
24
  requirements:
30
25
  - - ">="
31
26
  - !ruby/object:Gem::Version
32
- hash: 13
33
27
  segments:
34
28
  - 1
35
29
  - 2
@@ -41,11 +35,9 @@ dependencies:
41
35
  name: resque
42
36
  prerelease: false
43
37
  requirement: &id002 !ruby/object:Gem::Requirement
44
- none: false
45
38
  requirements:
46
39
  - - ">="
47
40
  - !ruby/object:Gem::Version
48
- hash: 33
49
41
  segments:
50
42
  - 1
51
43
  - 9
@@ -57,11 +49,9 @@ dependencies:
57
49
  name: mail
58
50
  prerelease: false
59
51
  requirement: &id003 !ruby/object:Gem::Requirement
60
- none: false
61
52
  requirements:
62
53
  - - ">="
63
54
  - !ruby/object:Gem::Version
64
- hash: 13
65
55
  segments:
66
56
  - 2
67
57
  - 2
@@ -95,16 +85,6 @@ files:
95
85
  - lib/rock-queue/web.rb
96
86
  - lib/rock-queue/web/views/dashboard.erb
97
87
  - lib/rock-queue/worker.rb
98
- - spec/active_record_helper_spec.rb
99
- - spec/beanstalkd_spec.rb
100
- - spec/email_notifier_spec.rb
101
- - spec/fixtures.rb
102
- - spec/queue_object_spec.rb
103
- - spec/resque_queue_spec.rb
104
- - spec/rock_queue_spec.rb
105
- - spec/shared.rb
106
- - spec/spec_helper.rb
107
- - spec/worker_spec.rb
108
88
  has_rdoc: true
109
89
  homepage: http://github.com/grzegorzkazulak/rock-queue
110
90
  licenses: []
@@ -115,27 +95,23 @@ rdoc_options:
115
95
  require_paths:
116
96
  - lib
117
97
  required_ruby_version: !ruby/object:Gem::Requirement
118
- none: false
119
98
  requirements:
120
99
  - - ">="
121
100
  - !ruby/object:Gem::Version
122
- hash: 3
123
101
  segments:
124
102
  - 0
125
103
  version: "0"
126
104
  required_rubygems_version: !ruby/object:Gem::Requirement
127
- none: false
128
105
  requirements:
129
106
  - - ">="
130
107
  - !ruby/object:Gem::Version
131
- hash: 3
132
108
  segments:
133
109
  - 0
134
110
  version: "0"
135
111
  requirements: []
136
112
 
137
113
  rubyforge_project:
138
- rubygems_version: 1.3.7
114
+ rubygems_version: 1.3.6
139
115
  signing_key:
140
116
  specification_version: 3
141
117
  summary: A unified interface for various messaging queues
@@ -144,6 +120,7 @@ test_files:
144
120
  - spec/beanstalkd_spec.rb
145
121
  - spec/email_notifier_spec.rb
146
122
  - spec/fixtures.rb
123
+ - spec/notifiers_spec.rb
147
124
  - spec/queue_object_spec.rb
148
125
  - spec/resque_queue_spec.rb
149
126
  - spec/rock_queue_spec.rb