resque_manager 3.3.8 → 3.3.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,7 @@ class WorkerTest < Test::Unit::TestCase
13
13
 
14
14
  context '#local_ip' do
15
15
  should 'set the local_ip' do
16
- assert_equal IPSocket.getaddress(Socket.gethostname), @worker.local_ip
16
+ assert_equal UDPSocket.open { |s| s.connect('google.com', 1); s.addr.last }, @worker.local_ip
17
17
  end
18
18
  end
19
19
 
@@ -21,7 +21,7 @@ class WorkerTest < Test::Unit::TestCase
21
21
  should 'return the correct string representation of the worker'do
22
22
  Process.stubs(:pid).returns(27415)
23
23
  object_id = Thread.current.object_id
24
- assert_equal "#{Socket.gethostname}(#{IPSocket.getaddress(Socket.gethostname)}):27415:#{object_id}:path:*", @worker.to_s
24
+ assert_equal "#{Socket.gethostname}(#{UDPSocket.open { |s| s.connect('google.com', 1); s.addr.last }}):27415:#{object_id}:path:*", @worker.to_s
25
25
  end
26
26
 
27
27
  should 'alias to_s as id' do
@@ -32,7 +32,7 @@ class WorkerTest < Test::Unit::TestCase
32
32
  context '#pause' do
33
33
  should 'return a correctly formatted pause key' do
34
34
  Process.stubs(:pid).returns(27415)
35
- assert_equal "worker:#{Socket.gethostname}(#{IPSocket.getaddress(Socket.gethostname)}):27415:all_workers:paused", @worker.pause_key
35
+ assert_equal "worker:#{Socket.gethostname}(#{UDPSocket.open { |s| s.connect('google.com', 1); s.addr.last }}):27415:all_workers:paused", @worker.pause_key
36
36
  end
37
37
  end
38
38
 
@@ -74,7 +74,7 @@ class WorkerTest < Test::Unit::TestCase
74
74
 
75
75
  context '#ip' do
76
76
  should 'return the correct ip' do
77
- assert_equal IPSocket.getaddress(Socket.gethostname), @worker.ip
77
+ assert_equal UDPSocket.open { |s| s.connect('google.com', 1); s.addr.last }, @worker.ip
78
78
  end
79
79
  end
80
80
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.8
4
+ version: 3.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Tyll
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-05 00:00:00.000000000 Z
11
+ date: 2014-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -216,7 +216,6 @@ files:
216
216
  - lib/resque_manager.rb
217
217
  - lib/resque_manager/engine.rb
218
218
  - lib/resque_manager/overrides/resque/failure/redis.rb
219
- - lib/resque_manager/overrides/resque/job.rb
220
219
  - lib/resque_manager/overrides/resque/resque.rb
221
220
  - lib/resque_manager/overrides/resque/worker.rb
222
221
  - lib/resque_manager/overrides/resque_scheduler/resque_scheduler.rb
@@ -226,8 +225,8 @@ files:
226
225
  - lib/resque_manager/recipes.rb
227
226
  - lib/resque_manager/version.rb
228
227
  - lib/tasks/failure.rake
228
+ - lib/tasks/resque.rake
229
229
  - lib/tasks/scheduler.rake
230
- - lib/tasks/worker.rake
231
230
  - test/dummy/README.rdoc
232
231
  - test/dummy/Rakefile
233
232
  - test/dummy/app/assets/javascripts/application.js
@@ -319,7 +318,7 @@ files:
319
318
  - test/unit/overrides/resque_status/status_test.rb
320
319
  homepage: https://github.com/kevintyll/resque_manager
321
320
  licenses:
322
- - MIT
321
+ - " MIT "
323
322
  metadata: {}
324
323
  post_install_message:
325
324
  rdoc_options: []
@@ -1,69 +0,0 @@
1
- module Resque
2
- class Job
3
- # Attempts to perform the work represented by this job instance.
4
- # Calls #perform on the class given in the payload with the
5
- # arguments given in the payload.
6
- # A block is sent so a message can be yielded back to be set in the worker.
7
- def perform
8
- job = payload_class
9
- job_args = args || []
10
- job_was_performed = false
11
-
12
- begin
13
- # Execute before_perform hook. Abort the job gracefully if
14
- # Resque::DontPerform is raised.
15
- begin
16
- before_hooks.each do |hook|
17
- job.send(hook, *job_args)
18
- end
19
- rescue DontPerform
20
- return false
21
- end
22
-
23
- # Execute the job. Do it in an around_perform hook if available.
24
- if around_hooks.empty?
25
- job.perform(*job_args) do |status|
26
- self.worker
27
- end
28
- job_was_performed = true
29
- else
30
- # We want to nest all around_perform plugins, with the last one
31
- # finally calling perform
32
- stack = around_hooks.reverse.inject(nil) do |last_hook, hook|
33
- if last_hook
34
- lambda do
35
- job.send(hook, *job_args) { last_hook.call }
36
- end
37
- else
38
- lambda do
39
- job.send(hook, *job_args) do
40
- result = job.perform(*job_args) do |status|
41
- self.worker
42
- end
43
- job_was_performed = true
44
- result
45
- end
46
- end
47
- end
48
- end
49
- stack.call
50
- end
51
-
52
- # Execute after_perform hook
53
- after_hooks.each do |hook|
54
- job.send(hook, *job_args)
55
- end
56
-
57
- # Return true if the job was performed
58
- return job_was_performed
59
-
60
- # If an exception occurs during the job execution, look for an
61
- # on_failure hook then re-raise.
62
- rescue Object => e
63
- failure_hooks.each { |hook| job.send(hook, e, *job_args) }
64
- raise e
65
- end
66
- end
67
-
68
- end
69
- end