resque-access_worker_from_job 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,12 +43,6 @@ as well.
43
43
 
44
44
 
45
45
  == Warnings
46
- === Argument errors in mixed environments
47
- Internally, this overrides Resque::Job to append the worker to the argument list passed to any <code>JobClass#perform</code>
48
- method. For a class that extends Resque::Plugins::AccessWorkerFromJob, this is handled transparently (worker is
49
- removed from the argument list and is available via the <code>@worker</code> instance variable, instead). For mixed environments
50
- where not all jobs to be run extend AccessWorkerFromJob, and where some of these expect a set number of arguments,
51
- this may cause problems ("wrong number of arguments" exceptions).
52
46
 
53
47
  === Ephemeral nature of worker changes
54
48
  Be careful to note that each job forks before running, so instance variables will be a _copy_ and, if changed,
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.3.0
@@ -1,11 +1,15 @@
1
1
  require 'resque' unless defined?(Resque)
2
2
 
3
3
  module Resque # :nodoc:
4
- # Resque-AccessWorkerFromJob plugin overrides the Resque::Job#args method to pass the worker along as the last argument.
4
+ # Resque-AccessWorkerFromJob plugin overrides the Resque::Job#args method to
5
+ # pass the worker along as the last argument, if the class on which to call perform wants it.
5
6
  class Job
7
+
6
8
  # Overridden args appends the worker when returning the list of args represented in this job's payload.
7
9
  def args
8
- @payload['args'] + [worker]
10
+ base_args = @payload['args'] || []
11
+ base_args << worker if payload_class.respond_to?(:wants_worker_access) && payload_class.wants_worker_access
12
+ return base_args
9
13
  end
10
14
  end
11
15
  end
@@ -43,12 +47,14 @@ module Resque # :nodoc:
43
47
  attr_accessor :required_worker_class, :worker
44
48
 
45
49
  def self.extended(base)
46
-
47
50
  unless base.methods.include?('perform')
48
51
  raise %Q{You must call "extend Resque::Plugins::AccessWorkerFromJob" AFTER (below) defining the perform method}
49
52
  end
50
53
 
51
54
  class << base
55
+ def wants_worker_access
56
+ true
57
+ end
52
58
 
53
59
  # Remove worker from last argument, so can write their perform method assuming just the arguments
54
60
  # they sent it, without worrying about the appended worker.
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{resque-access_worker_from_job}
8
- s.version = "0.2.3"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kali Donovan"]
12
- s.date = %q{2010-04-25}
12
+ s.date = %q{2010-06-02}
13
13
  s.description = %q{By allowing multiple jobs to share a single socket, which is persisted over the life of the worker, this plugin is an important building block for implementing a Resque-based service send background iPhone messages via the Apple Push Notification servers.}
14
14
  s.email = %q{kali.donovan@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
32
32
  s.homepage = %q{http://github.com/kdonovan/resque-access_worker_from_job}
33
33
  s.rdoc_options = ["--charset=UTF-8"]
34
34
  s.require_paths = ["lib"]
35
- s.rubygems_version = %q{1.3.5}
35
+ s.rubygems_version = %q{1.3.6}
36
36
  s.summary = %q{Resque plugin to allow jobs access to their calling worker at runtime.}
37
37
 
38
38
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-access_worker_from_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Kali Donovan
@@ -9,19 +14,21 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-04-25 00:00:00 -07:00
17
+ date: 2010-06-02 00:00:00 -07:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: resque
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
23
29
  version: "0"
24
- version:
30
+ type: :runtime
31
+ version_requirements: *id001
25
32
  description: By allowing multiple jobs to share a single socket, which is persisted over the life of the worker, this plugin is an important building block for implementing a Resque-based service send background iPhone messages via the Apple Push Notification servers.
26
33
  email: kali.donovan@gmail.com
27
34
  executables: []
@@ -56,18 +63,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
63
  requirements:
57
64
  - - ">="
58
65
  - !ruby/object:Gem::Version
66
+ segments:
67
+ - 0
59
68
  version: "0"
60
- version:
61
69
  required_rubygems_version: !ruby/object:Gem::Requirement
62
70
  requirements:
63
71
  - - ">="
64
72
  - !ruby/object:Gem::Version
73
+ segments:
74
+ - 0
65
75
  version: "0"
66
- version:
67
76
  requirements: []
68
77
 
69
78
  rubyforge_project:
70
- rubygems_version: 1.3.5
79
+ rubygems_version: 1.3.6
71
80
  signing_key:
72
81
  specification_version: 3
73
82
  summary: Resque plugin to allow jobs access to their calling worker at runtime.