resque-multi-step 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Peter Williams
1
+ Copyright (c) OpenLogic, Peter Williams
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -111,6 +111,13 @@ Note on Patches/Pull Requests
111
111
  (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
112
112
  * Send me a pull request. Bonus points for topic branches.
113
113
 
114
+ Mailing List
115
+ ----
116
+
117
+ To join the list simply send an email to <mailto:resquemultistep@librelist.com>. This will subscribe you and send you information about your subscription, including unsubscribe information.
118
+
119
+ The archive can be found at <http://librelist.com/browser/resquemultistep/>.
120
+
114
121
  Copyright
115
122
  -----
116
123
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -82,6 +82,11 @@ module Resque
82
82
 
83
83
  # Handle job invocation
84
84
  def perform(task_id, job_module_name, *args)
85
+ task = perform_without_maybe_finalize(task_id, job_module_name, *args)
86
+ task.maybe_finalize
87
+ end
88
+
89
+ def perform_without_maybe_finalize(task_id, job_module_name, *args)
85
90
  task = MultiStepTask.find(task_id)
86
91
  begin
87
92
  constantize(job_module_name).perform(*args)
@@ -89,9 +94,12 @@ module Resque
89
94
  task.increment_failed_count
90
95
  raise
91
96
  end
92
-
93
97
  task.increment_completed_count
94
- task.maybe_finalize
98
+ task
99
+ end
100
+
101
+ def perform_finalization(task_id, job_module_name, *args)
102
+ perform_without_maybe_finalize(task_id, job_module_name, *args)
95
103
  end
96
104
 
97
105
  # Normally jobs that are part of a multi-step task are run
@@ -219,7 +227,6 @@ module Resque
219
227
 
220
228
  if synchronous?
221
229
  sync_finalize!
222
-
223
230
  else
224
231
  if fin_job_info = redis.lpop('finalize_jobs')
225
232
  fin_job_info = Yajl::Parser.parse(fin_job_info)
@@ -234,16 +241,15 @@ module Resque
234
241
  def sync_finalize!
235
242
  while fin_job_info = redis.lpop('finalize_jobs')
236
243
  job_class_name, *args = Yajl::Parser.parse(fin_job_info)
237
- self.class.perform(task_id, job_class_name, *args)
244
+ self.class.perform_finalization(task_id, job_class_name, *args)
238
245
  end
246
+ nuke
239
247
  end
240
248
 
241
249
  # Execute finalization sequence if it is time.
242
250
  def maybe_finalize
243
- return unless ready_for_finalization?
251
+ return unless ready_for_finalization? && !incomplete_because_of_errors?
244
252
  finalize!
245
- rescue Exception
246
- # just eat the exception
247
253
  end
248
254
 
249
255
  # Is this task at the point where finalization can occur.
@@ -262,6 +268,11 @@ module Resque
262
268
  def incomplete_because_of_errors?
263
269
  failed_count > 0 && completed_count < normal_job_count
264
270
  end
271
+
272
+ def unfinalized_because_of_errors?
273
+ failed_count > 0 && completed_count < (normal_job_count + finalize_job_count)
274
+ end
275
+
265
276
  end
266
277
  end
267
278
  end
@@ -1,66 +1,63 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{resque-multi-step}
8
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Peter Williams", "Morgan Whitney"]
12
- s.date = %q{2010-10-04}
12
+ s.date = %q{2011-01-31}
13
13
  s.description = %q{Provides multi-step tasks with finalization and progress tracking}
14
14
  s.email = %q{pezra@barelyenough.org}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.md"
17
+ "README.md"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.md",
24
- "Rakefile",
25
- "VERSION",
26
- "lib/resque-multi-step.rb",
27
- "lib/resque/plugins/multi_step_task.rb",
28
- "lib/resque/plugins/multi_step_task/assure_finalization.rb",
29
- "lib/resque/plugins/multi_step_task/atomic_counters.rb",
30
- "lib/resque/plugins/multi_step_task/constantization.rb",
31
- "lib/resque/plugins/multi_step_task/finalization_job.rb",
32
- "lib/resque_mutli_step.rb",
33
- "resque-multi-step-task.gemspec",
34
- "resque-multi-step.gemspec",
35
- "spec/acceptance/acceptance_jobs.rb",
36
- "spec/acceptance/job_handling_spec.rb",
37
- "spec/acceptance/spec_helper.rb",
38
- "spec/resque-multi-step_spec.rb",
39
- "spec/resque/plugins/multi_step_task/finalization_job_spec.rb",
40
- "spec/resque/plugins/multi_step_task_spec.rb",
41
- "spec/spec.opts",
42
- "spec/spec_helper.rb"
21
+ "LICENSE",
22
+ "README.md",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "lib/resque-multi-step.rb",
26
+ "lib/resque/plugins/multi_step_task.rb",
27
+ "lib/resque/plugins/multi_step_task/assure_finalization.rb",
28
+ "lib/resque/plugins/multi_step_task/atomic_counters.rb",
29
+ "lib/resque/plugins/multi_step_task/constantization.rb",
30
+ "lib/resque/plugins/multi_step_task/finalization_job.rb",
31
+ "lib/resque_mutli_step.rb",
32
+ "resque-multi-step.gemspec",
33
+ "spec/acceptance/acceptance_jobs.rb",
34
+ "spec/acceptance/job_handling_spec.rb",
35
+ "spec/acceptance/spec_helper.rb",
36
+ "spec/resque-multi-step_spec.rb",
37
+ "spec/resque/plugins/multi_step_task/finalization_job_spec.rb",
38
+ "spec/resque/plugins/multi_step_task_spec.rb",
39
+ "spec/spec.opts",
40
+ "spec/spec_helper.rb"
43
41
  ]
44
42
  s.homepage = %q{http://github.com/pezra/resque-multi-step}
45
- s.rdoc_options = ["--charset=UTF-8"]
46
43
  s.require_paths = ["lib"]
47
- s.rubygems_version = %q{1.3.6}
44
+ s.rubygems_version = %q{1.3.7}
48
45
  s.summary = %q{Provides multi-step tasks with finalization and progress tracking}
49
46
  s.test_files = [
50
47
  "spec/acceptance/acceptance_jobs.rb",
51
- "spec/acceptance/job_handling_spec.rb",
52
- "spec/acceptance/spec_helper.rb",
53
- "spec/resque/plugins/multi_step_task/finalization_job_spec.rb",
54
- "spec/resque/plugins/multi_step_task_spec.rb",
55
- "spec/resque-multi-step_spec.rb",
56
- "spec/spec_helper.rb"
48
+ "spec/acceptance/job_handling_spec.rb",
49
+ "spec/acceptance/spec_helper.rb",
50
+ "spec/resque-multi-step_spec.rb",
51
+ "spec/resque/plugins/multi_step_task/finalization_job_spec.rb",
52
+ "spec/resque/plugins/multi_step_task_spec.rb",
53
+ "spec/spec_helper.rb"
57
54
  ]
58
55
 
59
56
  if s.respond_to? :specification_version then
60
57
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
61
58
  s.specification_version = 3
62
59
 
63
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
60
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
64
61
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
65
62
  s.add_runtime_dependency(%q<redis-namespace>, ["~> 0.8.0"])
66
63
  s.add_runtime_dependency(%q<resque>, ["~> 1.10"])
@@ -115,6 +115,28 @@ module Resque::Plugins
115
115
  task.add_job(TestJob, "my", "args")
116
116
  task.finalizable!
117
117
  end
118
+
119
+ it "knows it has failed if a normal job raises an exception" do
120
+ TestJob.should_receive(:perform).with("my", "args").ordered.and_raise('boo')
121
+ MyFinalJob.should_not_receive(:perform)
122
+
123
+ task.add_finalization_job(MyFinalJob, "final", "args")
124
+ task.add_job(TestJob, "my", "args") rescue nil
125
+ task.finalizable!
126
+ task.should be_incomplete_because_of_errors
127
+ end
128
+
129
+ it "knows it has failed if a finalized job raises an exception" do
130
+ MyFinalJob.should_receive(:perform).with("final", "args").ordered.and_raise('boo')
131
+
132
+ task.add_finalization_job(MyFinalJob, "final", "args")
133
+
134
+ lambda{
135
+ task.finalizable!
136
+ }.should raise_error
137
+
138
+ task.should be_unfinalized_because_of_errors
139
+ end
118
140
  end
119
141
 
120
142
  describe MultiStepTask, "finalization" do
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-multi-step
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 21
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 0
8
- - 0
9
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Peter Williams
@@ -15,16 +16,18 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-10-04 00:00:00 -06:00
19
+ date: 2011-01-31 00:00:00 -07:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  name: rspec
23
24
  prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
25
27
  requirements:
26
28
  - - ">="
27
29
  - !ruby/object:Gem::Version
30
+ hash: 13
28
31
  segments:
29
32
  - 1
30
33
  - 2
@@ -36,9 +39,11 @@ dependencies:
36
39
  name: redis-namespace
37
40
  prerelease: false
38
41
  requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
39
43
  requirements:
40
44
  - - ~>
41
45
  - !ruby/object:Gem::Version
46
+ hash: 63
42
47
  segments:
43
48
  - 0
44
49
  - 8
@@ -50,9 +55,11 @@ dependencies:
50
55
  name: resque
51
56
  prerelease: false
52
57
  requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
53
59
  requirements:
54
60
  - - ~>
55
61
  - !ruby/object:Gem::Version
62
+ hash: 27
56
63
  segments:
57
64
  - 1
58
65
  - 10
@@ -63,9 +70,11 @@ dependencies:
63
70
  name: resque-fairly
64
71
  prerelease: false
65
72
  requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
66
74
  requirements:
67
75
  - - ~>
68
76
  - !ruby/object:Gem::Version
77
+ hash: 15
69
78
  segments:
70
79
  - 1
71
80
  - 0
@@ -83,7 +92,6 @@ extra_rdoc_files:
83
92
  - README.md
84
93
  files:
85
94
  - .document
86
- - .gitignore
87
95
  - LICENSE
88
96
  - README.md
89
97
  - Rakefile
@@ -95,7 +103,6 @@ files:
95
103
  - lib/resque/plugins/multi_step_task/constantization.rb
96
104
  - lib/resque/plugins/multi_step_task/finalization_job.rb
97
105
  - lib/resque_mutli_step.rb
98
- - resque-multi-step-task.gemspec
99
106
  - resque-multi-step.gemspec
100
107
  - spec/acceptance/acceptance_jobs.rb
101
108
  - spec/acceptance/job_handling_spec.rb
@@ -110,28 +117,32 @@ homepage: http://github.com/pezra/resque-multi-step
110
117
  licenses: []
111
118
 
112
119
  post_install_message:
113
- rdoc_options:
114
- - --charset=UTF-8
120
+ rdoc_options: []
121
+
115
122
  require_paths:
116
123
  - lib
117
124
  required_ruby_version: !ruby/object:Gem::Requirement
125
+ none: false
118
126
  requirements:
119
127
  - - ">="
120
128
  - !ruby/object:Gem::Version
129
+ hash: 3
121
130
  segments:
122
131
  - 0
123
132
  version: "0"
124
133
  required_rubygems_version: !ruby/object:Gem::Requirement
134
+ none: false
125
135
  requirements:
126
136
  - - ">="
127
137
  - !ruby/object:Gem::Version
138
+ hash: 3
128
139
  segments:
129
140
  - 0
130
141
  version: "0"
131
142
  requirements: []
132
143
 
133
144
  rubyforge_project:
134
- rubygems_version: 1.3.6
145
+ rubygems_version: 1.3.7
135
146
  signing_key:
136
147
  specification_version: 3
137
148
  summary: Provides multi-step tasks with finalization and progress tracking
@@ -139,7 +150,7 @@ test_files:
139
150
  - spec/acceptance/acceptance_jobs.rb
140
151
  - spec/acceptance/job_handling_spec.rb
141
152
  - spec/acceptance/spec_helper.rb
153
+ - spec/resque-multi-step_spec.rb
142
154
  - spec/resque/plugins/multi_step_task/finalization_job_spec.rb
143
155
  - spec/resque/plugins/multi_step_task_spec.rb
144
- - spec/resque-multi-step_spec.rb
145
156
  - spec/spec_helper.rb
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
@@ -1,67 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{resque-multi-step-task}
8
- s.version = "0.0.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Peter Williams"]
12
- s.date = %q{2010-09-20}
13
- s.description = %q{Provides multi-step tasks with finalization and progress tracking}
14
- s.email = %q{pezra@barelyenough.org}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.md"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.md",
24
- "Rakefile",
25
- "VERSION",
26
- "lib/resque-multi-step-task.rb",
27
- "lib/resque/plugins/multi_step_task.rb",
28
- "lib/resque/plugins/multi_step_task/assure_finalization.rb",
29
- "lib/resque/plugins/multi_step_task/atomic_counters.rb",
30
- "lib/resque/plugins/multi_step_task/constantization.rb",
31
- "lib/resque_mutli_step_task.rb",
32
- "spec/resque-multi-step-task_spec.rb",
33
- "spec/resque/plugins/multi_step_task_spec.rb",
34
- "spec/spec.opts",
35
- "spec/spec_helper.rb"
36
- ]
37
- s.homepage = %q{http://github.com/pezra/resque-multi-step-task}
38
- s.rdoc_options = ["--charset=UTF-8"]
39
- s.require_paths = ["lib"]
40
- s.rubygems_version = %q{1.3.6}
41
- s.summary = %q{Provides multi-step tasks with finalization and progress tracking}
42
- s.test_files = [
43
- "spec/resque/plugins/multi_step_task_spec.rb",
44
- "spec/resque-multi-step-task_spec.rb",
45
- "spec/spec_helper.rb"
46
- ]
47
-
48
- if s.respond_to? :specification_version then
49
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
- s.specification_version = 3
51
-
52
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
53
- s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
54
- s.add_runtime_dependency(%q<resque>, ["~> 1.10"])
55
- s.add_runtime_dependency(%q<redis-namespace>, ["~> 0.8.0"])
56
- else
57
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
58
- s.add_dependency(%q<resque>, ["~> 1.10"])
59
- s.add_dependency(%q<redis-namespace>, ["~> 0.8.0"])
60
- end
61
- else
62
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
63
- s.add_dependency(%q<resque>, ["~> 1.10"])
64
- s.add_dependency(%q<redis-namespace>, ["~> 0.8.0"])
65
- end
66
- end
67
-