resque-priority 0.1 → 0.1.1

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/Rakefile CHANGED
@@ -3,7 +3,7 @@ begin
3
3
 
4
4
  Jeweler::Tasks.new do |gem|
5
5
  gem.name = "resque-priority"
6
- gem.version = "0.1"
6
+ gem.version = "0.1.1"
7
7
  gem.summary = "Resque plugin that provides priority levels"
8
8
  gem.description = <<-desc
9
9
  Provides Resque with three levels of (named) priority for a single queue.
@@ -22,3 +22,15 @@ begin
22
22
  rescue LoadError
23
23
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
24
24
  end
25
+
26
+ begin
27
+ require 'rspec/core/rake_task'
28
+
29
+ RSpec::Core::RakeTask.new('spec') do |t|
30
+ t.pattern = FileList['spec/**/*_spec.rb']
31
+ end
32
+
33
+ task :test do
34
+ Rake::Task['spec'].invoke
35
+ end
36
+ end
@@ -21,7 +21,7 @@ module Resque
21
21
  end
22
22
 
23
23
  def priority_key(*args)
24
- ['priority', 'name', priority_identifier(*args)].compact.join(':')
24
+ ['priority', name, priority_identifier(*args)].compact.join(':')
25
25
  end
26
26
 
27
27
  def after_enqueue_set_priority(*args)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{resque-priority}
8
- s.version = "0.1"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brett Buddin"]
12
- s.date = %q{2010-10-01}
12
+ s.date = %q{2010-10-26}
13
13
  s.description = %q{ Provides Resque with three levels of (named) priority for a single queue.
14
14
  }
15
15
  s.email = %q{brett@intraspirit.net}
@@ -29,6 +29,10 @@ Gem::Specification.new do |s|
29
29
  s.require_paths = ["lib"]
30
30
  s.rubygems_version = %q{1.3.7}
31
31
  s.summary = %q{Resque plugin that provides priority levels}
32
+ s.test_files = [
33
+ "spec/priority_spec.rb",
34
+ "spec/spec_helper.rb"
35
+ ]
32
36
 
33
37
  if s.respond_to? :specification_version then
34
38
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe Resque::Plugins::Priority do
4
+ before(:each) do
5
+ Resque.redis.flushdb
6
+ end
7
+
8
+ describe :enqueue_with_priority do
9
+ context "when normal" do
10
+ before(:each) do
11
+ Resque.enqueue_with_priority(:normal, TestJob)
12
+ end
13
+
14
+ it "enqueues to normal queue" do
15
+ Resque.size(:test).should == 1
16
+ end
17
+ end
18
+
19
+ [:high, :low].each do |priority|
20
+ context "when #{priority}" do
21
+ before(:each) do
22
+ Resque.enqueue_with_priority(priority, TestJob)
23
+ end
24
+
25
+ it "enqueues to #{priority} queue" do
26
+ Resque.size("test_#{priority.to_s}").should == 1
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ describe "performing jobs" do
33
+ before(:each) do
34
+ Resque.redis.flushdb
35
+ Resque.enqueue_with_priority(:high, TestJob)
36
+ @job = Resque.reserve(:test_high)
37
+ end
38
+
39
+ it "provides priority to the running job" do
40
+ @job.payload_class.instance_variable_get(:@priority).should == :high
41
+ end
42
+
43
+ it "doesn't modify the queue name" do
44
+ @job.payload_class.instance_variable_get(:@queue).should == :test
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,11 @@
1
+ require 'resque'
2
+ require File.dirname(__FILE__) + '/../lib/resque/plugins/priority'
3
+
4
+ class TestJob
5
+ extend Resque::Plugins::Priority
6
+
7
+ @queue = :test
8
+
9
+ def self.perform
10
+ end
11
+ end
metadata CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- version: "0.1"
8
+ - 1
9
+ version: 0.1.1
9
10
  platform: ruby
10
11
  authors:
11
12
  - Brett Buddin
@@ -13,7 +14,7 @@ autorequire:
13
14
  bindir: bin
14
15
  cert_chain: []
15
16
 
16
- date: 2010-10-01 00:00:00 -04:00
17
+ date: 2010-10-26 00:00:00 -04:00
17
18
  default_executable:
18
19
  dependencies: []
19
20
 
@@ -32,6 +33,8 @@ files:
32
33
  - Rakefile
33
34
  - lib/resque/plugins/priority.rb
34
35
  - resque-priority.gemspec
36
+ - spec/priority_spec.rb
37
+ - spec/spec_helper.rb
35
38
  has_rdoc: true
36
39
  homepage: http://github.com/brettbuddin/resque-priority
37
40
  licenses: []
@@ -64,5 +67,6 @@ rubygems_version: 1.3.7
64
67
  signing_key:
65
68
  specification_version: 3
66
69
  summary: Resque plugin that provides priority levels
67
- test_files: []
68
-
70
+ test_files:
71
+ - spec/priority_spec.rb
72
+ - spec/spec_helper.rb