resque-batched-job 1.2.0 → 1.3.0

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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Daniel Johnston
1
+ Copyright (c) Daniel Johnston
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -21,12 +21,12 @@ require 'resque/batched_job'
21
21
  module Job
22
22
  extend Resque::Plugins::BatchedJob
23
23
 
24
- def self.perform(id, *args)
25
- prime(id, args)
24
+ def self.perform(bid, *args)
25
+ prime(bid, args)
26
26
  end
27
27
 
28
- def self.after_batch_heavy_lifting(id, *args)
29
- heavy_lifting(id)
28
+ def self.after_batch_heavy_lifting(bid, *args)
29
+ heavy_lifting(bid)
30
30
  end
31
31
 
32
32
  end
data/Rakefile CHANGED
@@ -47,6 +47,6 @@ task :changelog do
47
47
 
48
48
  tags.each_slice(2) do |tags|
49
49
  puts "========== #{tags[1]}..#{tags[0]} =========="
50
- sh "git log --pretty=format:'%h : %s' --graph #{tags[1]}..#{tags[0]}"
50
+ `git log --pretty=format:'%h : %s' --graph #{tags[1]}..#{tags[0]}`
51
51
  end
52
52
  end
@@ -0,0 +1,6 @@
1
+ namespace :resque do
2
+
3
+
4
+ end
5
+
6
+
@@ -1,7 +1,7 @@
1
1
  module Resque
2
2
  module Plugins
3
3
  module BatchedJob
4
- VERSION = '1.2.0'
4
+ VERSION = '1.3.0'
5
5
  end
6
6
  end
7
7
  end
@@ -1,5 +1,12 @@
1
1
  module Resque
2
2
 
3
+ # This is a small wrapper around Resque.enqueue.
4
+ # @param [Class] klass Job class.
5
+ # @param [Object, #to_s] bid Batch identifier.
6
+ def self.enqueue_batched_job(klass, bid, *args)
7
+ Resque.enqueue(klass, bid, *args)
8
+ end
9
+
3
10
  module Plugin
4
11
 
5
12
  # This hook is really the meaning of our adventure.
@@ -103,6 +110,10 @@ module Resque
103
110
  # and aquired the lock. This means Job2 has to start from the beginnig.
104
111
  # * If the previous timestamp is still expired the lock has been set and
105
112
  # processing can continue safely
113
+ #
114
+ # @param id (see Resque::Plugins::BatchedJob#batch)
115
+ # @yield [bid] Yields the current batch id.
116
+ # @yieldparam [String] The current batch id.
106
117
  def mutex(id, &block)
107
118
  is_expired = lambda do |locked_at|
108
119
  locked_at.to_f < Time.now.to_f
@@ -130,4 +141,4 @@ module Resque
130
141
 
131
142
  end
132
143
 
133
- end
144
+ end
@@ -75,7 +75,7 @@ class BatchedJobTest < Test::Unit::TestCase
75
75
  # Test that jobs with identical args behave properly.
76
76
  def test_duplicate_args
77
77
  assert_equal(false, Job.batch_exist?(@batch_id))
78
-
78
+
79
79
  assert_nothing_raised do
80
80
  5.times { Resque.enqueue(JobWithoutArgs, @batch_id) }
81
81
  end
@@ -127,7 +127,7 @@ class BatchedJobTest < Test::Unit::TestCase
127
127
 
128
128
  assert_equal(x * y, Integer(redis.get(@batch)))
129
129
  end
130
-
130
+
131
131
  def test_remove_batched_job
132
132
  Resque.enqueue(JobWithoutArgs, @batch_id)
133
133
 
@@ -139,7 +139,7 @@ class BatchedJobTest < Test::Unit::TestCase
139
139
  assert_equal(false, $batch_complete)
140
140
 
141
141
  Resque.enqueue(JobWithoutArgs, @batch_id)
142
-
142
+
143
143
  assert_nothing_raised do
144
144
  JobWithoutArgs.remove_batched_job!(@batch_id)
145
145
  end
@@ -148,6 +148,11 @@ class BatchedJobTest < Test::Unit::TestCase
148
148
  assert_equal(false, Job.batch_exist?(@batch_id))
149
149
  end
150
150
 
151
+ def test_enqueue_batched_job
152
+ Resque.enqueue_batched_job(JobWithoutArgs, @batch_id)
153
+ assert(Job.batch_exist?(@batch_id))
154
+ end
155
+
151
156
  private
152
157
 
153
158
  def redis
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-batched-job
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-03 00:00:00.000000000 Z
12
+ date: 2012-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: resque
16
- requirement: &70323806805200 !ruby/object:Gem::Requirement
16
+ requirement: &70171540725400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 1.10.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70323806805200
24
+ version_requirements: *70171540725400
25
25
  description: ! " Resque plugin for batching jobs. When a batch/group of jobs are
26
26
  complete, \nadditional work can be performed usings batch hooks.\n"
27
27
  email: dan@dj-agiledev.com
@@ -33,6 +33,7 @@ files:
33
33
  - Rakefile
34
34
  - README.md
35
35
  - lib/resque/batched_job.rb
36
+ - lib/resque/plugins/batched_job/tasks.rb
36
37
  - lib/resque/plugins/batched_job/version.rb
37
38
  - lib/resque/plugins/batched_job.rb
38
39
  - lib/resque-batched-job.rb