backgrounded-resque 2.0.0.pre1 → 2.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
data/backgrounded.gemspec CHANGED
@@ -1,10 +1,10 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- require "backgrounded/version"
3
+ require "backgrounded-resque/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "backgrounded-resque"
7
- s.version = Backgrounded::VERSION
7
+ s.version = Backgrounded::Resque::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Ryan Sonnek"]
10
10
  s.email = ["ryan@codecrate.com"]
@@ -14,11 +14,10 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = "backgrounded"
16
16
 
17
- s.add_runtime_dependency(%q<backgrounded>, [">= 2.0.0.pre1"])
17
+ s.add_runtime_dependency(%q<backgrounded>, [">= 2.0.0.rc2"])
18
18
  s.add_runtime_dependency(%q<resque>, [">= 0.17.1"])
19
19
  s.add_development_dependency(%q<shoulda>, [">= 0"])
20
20
  s.add_development_dependency(%q<resque_unit>, [">= 0.3.7"])
21
- s.add_development_dependency(%q<resque_unit>, [">= 0.3.7"])
22
21
  s.add_development_dependency(%q<mocha>, [">= 0"])
23
22
  s.add_development_dependency(%q<sqlite3-ruby>, [">= 1.3.2"])
24
23
  s.add_development_dependency(%q<rake>, [">= 0.9.2.2"])
@@ -1,13 +1,15 @@
1
1
  require 'resque'
2
+ require 'backgrounded/handler/abstract_handler'
2
3
 
3
4
  # handler that acts like the in process handler but marshalls the arguments
4
5
  # this simulates how resque encodes/decodes values to/from redis
5
6
  # useful when passing symbols to arguments and they end up being processed as strings
6
7
  module Backgrounded
7
- module Handler
8
- class PseudoResqueHandler
9
- def request(object, method, args, options={})
10
- object.send method, *Resque.decode(Resque.encode(args))
8
+ module Resque
9
+ class PseudoResqueHandler < Backgrounded::Handler::AbstractHandler
10
+ def request(object, method, args)
11
+ marshalled_args = ::Resque.decode(::Resque.encode(args))
12
+ object.send method, *marshalled_args
11
13
  end
12
14
  end
13
15
  end
@@ -1,21 +1,25 @@
1
1
  require 'resque'
2
+ require 'backgrounded/handler/abstract_handler'
2
3
 
4
+ # enqueue requests in resque
3
5
  module Backgrounded
4
- module Handler
5
- #enque requests in resque
6
- class ResqueHandler
6
+ module Resque
7
+ class ResqueHandler < Backgrounded::Handler::AbstractHandler
7
8
  DEFAULT_QUEUE = 'backgrounded'
8
9
  INVALID_ID = -1
9
10
  @@queue = DEFAULT_QUEUE
10
11
 
11
- def request(object, method, args, options={})
12
+ def request(object, method, args)
12
13
  @@queue = options[:queue] || DEFAULT_QUEUE
13
14
  instance, id = instance_identifiers(object)
14
- Resque.enqueue(ResqueHandler, instance, id, method, *args)
15
+ ::Resque.enqueue(ResqueHandler, instance, id, method, *args)
15
16
  end
16
17
  def self.queue
17
18
  @@queue
18
19
  end
20
+
21
+ # invoke the requested method
22
+ # fired from the resque workers
19
23
  def self.perform(clazz, id, method, *args)
20
24
  find_instance(clazz, id, method).send(method, *args)
21
25
  end
@@ -0,0 +1,5 @@
1
+ module Backgrounded
2
+ module Resque
3
+ VERSION = "2.0.0.rc2"
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ require 'backgrounded'
2
+ require 'backgrounded-resque/version'
3
+ require 'backgrounded-resque/resque_handler'
4
+ require 'backgrounded-resque/pseudo_resque_handler'
@@ -1,5 +1,4 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
- require 'backgrounded/handler/resque_handler'
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
3
2
  require 'resque_unit'
4
3
 
5
4
  ActiveRecord::Schema.define(:version => 1) do
@@ -39,7 +38,7 @@ class ResqueHandlerTest < Test::Unit::TestCase
39
38
  context 'when backgrounded is configured with resque' do
40
39
  setup do
41
40
  Resque.reset!
42
- @handler = Backgrounded::Handler::ResqueHandler.new
41
+ @handler = Backgrounded::Resque::ResqueHandler.new
43
42
  Backgrounded.handler = @handler
44
43
  end
45
44
 
@@ -49,8 +48,8 @@ class ResqueHandlerTest < Test::Unit::TestCase
49
48
  Blog.backgrounded.do_stuff
50
49
  end
51
50
  should "enqueue job to resque" do
52
- assert_queued Backgrounded::Handler::ResqueHandler, [Blog.to_s, -1, 'do_stuff']
53
- assert_equal Backgrounded::Handler::ResqueHandler::DEFAULT_QUEUE, Resque.queue_from_class(Backgrounded::Handler::ResqueHandler)
51
+ assert_queued Backgrounded::Resque::ResqueHandler, [Blog.to_s, -1, 'do_stuff']
52
+ assert_equal Backgrounded::Resque::ResqueHandler::DEFAULT_QUEUE, Resque.queue_from_class(Backgrounded::Resque::ResqueHandler)
54
53
  end
55
54
  context "running background job" do
56
55
  setup do
@@ -66,8 +65,8 @@ class ResqueHandlerTest < Test::Unit::TestCase
66
65
  @blog.backgrounded.do_stuff
67
66
  end
68
67
  should "enqueue instance method job to resque" do
69
- assert_queued Backgrounded::Handler::ResqueHandler, [Blog.to_s, @blog.id, 'do_stuff']
70
- assert_equal Backgrounded::Handler::ResqueHandler::DEFAULT_QUEUE, Resque.queue_from_class(Backgrounded::Handler::ResqueHandler)
68
+ assert_queued Backgrounded::Resque::ResqueHandler, [Blog.to_s, @blog.id, 'do_stuff']
69
+ assert_equal Backgrounded::Resque::ResqueHandler::DEFAULT_QUEUE, Resque.queue_from_class(Backgrounded::Resque::ResqueHandler)
71
70
  end
72
71
  context "running background job" do
73
72
  setup do
@@ -89,8 +88,8 @@ class ResqueHandlerTest < Test::Unit::TestCase
89
88
  @user.backgrounded.do_stuff
90
89
  end
91
90
  should "enqueue job to resque" do
92
- assert_queued Backgrounded::Handler::ResqueHandler, [User.to_s, @user.id, 'do_stuff']
93
- assert_equal Backgrounded::Handler::ResqueHandler::DEFAULT_QUEUE, Resque.queue_from_class(Backgrounded::Handler::ResqueHandler)
91
+ assert_queued Backgrounded::Resque::ResqueHandler, [User.to_s, @user.id, 'do_stuff']
92
+ assert_equal Backgrounded::Resque::ResqueHandler::DEFAULT_QUEUE, Resque.queue_from_class(Backgrounded::Resque::ResqueHandler)
94
93
  end
95
94
  context "running background job" do
96
95
  should "invoke method on user object" do
@@ -109,8 +108,8 @@ class ResqueHandlerTest < Test::Unit::TestCase
109
108
  @post.backgrounded(:queue => 'important').do_stuff
110
109
  end
111
110
  should "use configured queue" do
112
- assert_equal 'important', Backgrounded::Handler::ResqueHandler.queue
113
- assert_equal 'important', Resque.queue_from_class(Backgrounded::Handler::ResqueHandler)
111
+ assert_equal 'important', Backgrounded::Resque::ResqueHandler.queue
112
+ assert_equal 'important', Resque.queue_from_class(Backgrounded::Resque::ResqueHandler)
114
113
  assert_equal 1, Resque.queue('important').length
115
114
  end
116
115
  end
data/test/test_helper.rb CHANGED
@@ -14,7 +14,7 @@ require 'active_record'
14
14
 
15
15
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
16
16
  $LOAD_PATH.unshift(File.dirname(__FILE__))
17
- require 'backgrounded'
17
+ require 'backgrounded-resque'
18
18
 
19
19
  Backgrounded.logger.level = Logger::DEBUG
20
20
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backgrounded-resque
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre1
4
+ version: 2.0.0.rc2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-22 00:00:00.000000000 Z
12
+ date: 2012-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: backgrounded
16
- requirement: &2179202580 !ruby/object:Gem::Requirement
16
+ requirement: &2175063400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 2.0.0.pre1
21
+ version: 2.0.0.rc2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2179202580
24
+ version_requirements: *2175063400
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: resque
27
- requirement: &2179202060 !ruby/object:Gem::Requirement
27
+ requirement: &2175062880 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.17.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2179202060
35
+ version_requirements: *2175062880
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: shoulda
38
- requirement: &2179201580 !ruby/object:Gem::Requirement
38
+ requirement: &2175062400 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2179201580
46
+ version_requirements: *2175062400
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: resque_unit
49
- requirement: &2179201100 !ruby/object:Gem::Requirement
49
+ requirement: &2175061920 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,21 +54,10 @@ dependencies:
54
54
  version: 0.3.7
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2179201100
58
- - !ruby/object:Gem::Dependency
59
- name: resque_unit
60
- requirement: &2179200620 !ruby/object:Gem::Requirement
61
- none: false
62
- requirements:
63
- - - ! '>='
64
- - !ruby/object:Gem::Version
65
- version: 0.3.7
66
- type: :development
67
- prerelease: false
68
- version_requirements: *2179200620
57
+ version_requirements: *2175061920
69
58
  - !ruby/object:Gem::Dependency
70
59
  name: mocha
71
- requirement: &2179200140 !ruby/object:Gem::Requirement
60
+ requirement: &2175061440 !ruby/object:Gem::Requirement
72
61
  none: false
73
62
  requirements:
74
63
  - - ! '>='
@@ -76,10 +65,10 @@ dependencies:
76
65
  version: '0'
77
66
  type: :development
78
67
  prerelease: false
79
- version_requirements: *2179200140
68
+ version_requirements: *2175061440
80
69
  - !ruby/object:Gem::Dependency
81
70
  name: sqlite3-ruby
82
- requirement: &2179199660 !ruby/object:Gem::Requirement
71
+ requirement: &2175060960 !ruby/object:Gem::Requirement
83
72
  none: false
84
73
  requirements:
85
74
  - - ! '>='
@@ -87,10 +76,10 @@ dependencies:
87
76
  version: 1.3.2
88
77
  type: :development
89
78
  prerelease: false
90
- version_requirements: *2179199660
79
+ version_requirements: *2175060960
91
80
  - !ruby/object:Gem::Dependency
92
81
  name: rake
93
- requirement: &2179199180 !ruby/object:Gem::Requirement
82
+ requirement: &2175060480 !ruby/object:Gem::Requirement
94
83
  none: false
95
84
  requirements:
96
85
  - - ! '>='
@@ -98,7 +87,7 @@ dependencies:
98
87
  version: 0.9.2.2
99
88
  type: :development
100
89
  prerelease: false
101
- version_requirements: *2179199180
90
+ version_requirements: *2175060480
102
91
  description: Execute any ActiveRecord Model method in the background
103
92
  email:
104
93
  - ryan@codecrate.com
@@ -113,11 +102,12 @@ files:
113
102
  - README.rdoc
114
103
  - Rakefile
115
104
  - backgrounded.gemspec
116
- - lib/backgrounded/handler/pseudo_resque_handler.rb
117
- - lib/backgrounded/handler/resque_handler.rb
118
- - lib/backgrounded/version.rb
119
- - test/backgrounded/handler/resque_handler_test.rb
105
+ - lib/backgrounded-resque.rb
106
+ - lib/backgrounded-resque/pseudo_resque_handler.rb
107
+ - lib/backgrounded-resque/resque_handler.rb
108
+ - lib/backgrounded-resque/version.rb
120
109
  - test/database.yml
110
+ - test/resque_handler_test.rb
121
111
  - test/test_helper.rb
122
112
  homepage: http://github.com/wireframe/backgrounded
123
113
  licenses: []
@@ -133,7 +123,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
123
  version: '0'
134
124
  segments:
135
125
  - 0
136
- hash: 3144533850957425411
126
+ hash: -1104768520332548292
137
127
  required_rubygems_version: !ruby/object:Gem::Requirement
138
128
  none: false
139
129
  requirements:
@@ -147,6 +137,6 @@ signing_key:
147
137
  specification_version: 3
148
138
  summary: Simple API to perform work in the background
149
139
  test_files:
150
- - test/backgrounded/handler/resque_handler_test.rb
151
140
  - test/database.yml
141
+ - test/resque_handler_test.rb
152
142
  - test/test_helper.rb
@@ -1,3 +0,0 @@
1
- module Backgrounded
2
- VERSION = "2.0.0.pre1"
3
- end