backgrounded 0.6.1 → 0.6.2
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/VERSION.yml +1 -1
- data/backgrounded.gemspec +4 -2
- data/lib/backgrounded/class_methods.rb +2 -1
- data/test/backgrounded/handler/delayed_job_handler_test.rb +22 -19
- data/test/backgrounded/handler/resque_handler_test.rb +9 -9
- data/test/backgrounded/handler/workling_handler_test.rb +48 -0
- data/test/backgrounded_test.rb +45 -23
- metadata +6 -4
data/VERSION.yml
CHANGED
data/backgrounded.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{backgrounded}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ryan Sonnek"]
|
12
|
-
s.date = %q{2010-10-
|
12
|
+
s.date = %q{2010-10-27}
|
13
13
|
s.email = %q{ryan.sonnek@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
"lib/backgrounded/handler/workling_handler.rb",
|
31
31
|
"test/backgrounded/handler/delayed_job_handler_test.rb",
|
32
32
|
"test/backgrounded/handler/resque_handler_test.rb",
|
33
|
+
"test/backgrounded/handler/workling_handler_test.rb",
|
33
34
|
"test/backgrounded_test.rb",
|
34
35
|
"test/database.yml",
|
35
36
|
"test/test_helper.rb"
|
@@ -42,6 +43,7 @@ Gem::Specification.new do |s|
|
|
42
43
|
s.test_files = [
|
43
44
|
"test/backgrounded/handler/delayed_job_handler_test.rb",
|
44
45
|
"test/backgrounded/handler/resque_handler_test.rb",
|
46
|
+
"test/backgrounded/handler/workling_handler_test.rb",
|
45
47
|
"test/backgrounded_test.rb",
|
46
48
|
"test/test_helper.rb"
|
47
49
|
]
|
@@ -19,14 +19,15 @@ ActiveRecord::Schema.define(:version => 1) do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
class
|
23
|
-
|
22
|
+
class DelayedJobHandlerTest < Test::Unit::TestCase
|
23
|
+
|
24
|
+
class User < ActiveRecord::Base
|
25
|
+
backgrounded :do_stuff
|
24
26
|
|
25
|
-
|
27
|
+
def do_stuff
|
28
|
+
end
|
26
29
|
end
|
27
|
-
end
|
28
30
|
|
29
|
-
class DelayedJobHandlerTest < Test::Unit::TestCase
|
30
31
|
context 'when backgrounded is configured with delayed_job' do
|
31
32
|
setup do
|
32
33
|
Delayed::Worker.backend = :active_record
|
@@ -34,20 +35,22 @@ class DelayedJobHandlerTest < Test::Unit::TestCase
|
|
34
35
|
Backgrounded.handler = @handler
|
35
36
|
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
@user = User.create
|
40
|
-
end
|
41
|
-
context "invoking backgrounded method" do
|
42
|
-
setup do
|
43
|
-
@user.do_stuff_backgrounded
|
44
|
-
end
|
45
|
-
should_create Delayed::Job
|
46
|
-
should 'create delayed job' do
|
47
|
-
job = Delayed::Job.last
|
48
|
-
puts job.inspect
|
49
|
-
end
|
50
|
-
end
|
38
|
+
should 'be configured' do
|
39
|
+
fail 'delayed job not recognizing activerecord config'
|
51
40
|
end
|
41
|
+
# context 'a persisted object with a single backgrounded method' do
|
42
|
+
# setup do
|
43
|
+
# @user = User.create
|
44
|
+
# end
|
45
|
+
# context "invoking backgrounded method" do
|
46
|
+
# setup do
|
47
|
+
# @user.do_stuff_backgrounded
|
48
|
+
# end
|
49
|
+
# should_create Delayed::Job
|
50
|
+
# should 'create delayed job' do
|
51
|
+
# job = Delayed::Job.last
|
52
|
+
# end
|
53
|
+
# end
|
54
|
+
# end
|
52
55
|
end
|
53
56
|
end
|
@@ -11,21 +11,21 @@ ActiveRecord::Schema.define(:version => 1) do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
class
|
15
|
-
|
14
|
+
class ResqueHandlerTest < Test::Unit::TestCase
|
15
|
+
class User < ActiveRecord::Base
|
16
|
+
backgrounded :do_stuff
|
16
17
|
|
17
|
-
|
18
|
+
def do_stuff
|
19
|
+
end
|
18
20
|
end
|
19
|
-
end
|
20
21
|
|
21
|
-
class Post < ActiveRecord::Base
|
22
|
-
|
22
|
+
class Post < ActiveRecord::Base
|
23
|
+
backgrounded :do_stuff => {:queue => 'important'}
|
23
24
|
|
24
|
-
|
25
|
+
def do_stuff
|
26
|
+
end
|
25
27
|
end
|
26
|
-
end
|
27
28
|
|
28
|
-
class ResqueHandlerTest < Test::Unit::TestCase
|
29
29
|
context 'when backgrounded is configured with resque' do
|
30
30
|
setup do
|
31
31
|
Resque.reset!
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
2
|
+
RAILS_DEFAULT_LOGGER = Logger.new 'foo'
|
3
|
+
RAILS_ENV = 'test'
|
4
|
+
require 'newrelic_rpm'
|
5
|
+
require 'memcache'
|
6
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'socialcast', 'vendor', 'plugins', 'workling', 'lib', 'workling')
|
7
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'socialcast', 'vendor', 'plugins', 'workling', 'lib', 'workling', 'base')
|
8
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'socialcast', 'vendor', 'plugins', 'workling', 'lib', 'workling', 'discovery')
|
9
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'socialcast', 'vendor', 'plugins', 'workling', 'lib', 'workling', 'routing', 'class_and_method_routing')
|
10
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'socialcast', 'vendor', 'plugins', 'workling', 'lib', 'workling', 'remote', 'invokers', 'threaded_poller')
|
11
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'socialcast', 'vendor', 'plugins', 'workling', 'lib', 'workling', 'remote')
|
12
|
+
require 'backgrounded/handler/workling_handler'
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 1) do
|
15
|
+
create_table :users, :force => true do |t|
|
16
|
+
t.column :name, :string
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class WorklingHandlerTest < Test::Unit::TestCase
|
21
|
+
|
22
|
+
class User < ActiveRecord::Base
|
23
|
+
backgrounded :do_stuff
|
24
|
+
|
25
|
+
def do_stuff
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when backgrounded is configured with workling' do
|
30
|
+
setup do
|
31
|
+
@handler = Backgrounded::Handler::WorklingHandler.new
|
32
|
+
Backgrounded.handler = @handler
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'a persisted object with a single backgrounded method' do
|
36
|
+
setup do
|
37
|
+
@user = User.create
|
38
|
+
end
|
39
|
+
context "invoking backgrounded method" do
|
40
|
+
setup do
|
41
|
+
User.any_instance.expects(:do_stuff).with('a string')
|
42
|
+
@user.do_stuff_backgrounded 'a string'
|
43
|
+
end
|
44
|
+
should 'dispatch through workling back to the object' do end #see expectations
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/test/backgrounded_test.rb
CHANGED
@@ -1,43 +1,55 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
2
|
|
3
|
-
class
|
4
|
-
|
3
|
+
class BackgroundedTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
class User
|
6
|
+
backgrounded :do_stuff
|
5
7
|
|
6
|
-
|
8
|
+
def do_stuff
|
9
|
+
end
|
7
10
|
end
|
8
|
-
end
|
9
11
|
|
10
|
-
class Person
|
11
|
-
|
12
|
+
class Person
|
13
|
+
backgrounded :do_stuff
|
12
14
|
|
13
|
-
|
15
|
+
def do_stuff(name, place, location)
|
16
|
+
end
|
14
17
|
end
|
15
|
-
end
|
16
18
|
|
17
|
-
class Post
|
18
|
-
|
19
|
+
class Post
|
20
|
+
backgrounded :do_stuff, :notify_users
|
19
21
|
|
20
|
-
|
22
|
+
def do_stuff
|
23
|
+
end
|
24
|
+
def notify_users
|
25
|
+
end
|
21
26
|
end
|
22
|
-
|
27
|
+
|
28
|
+
class Comment
|
29
|
+
backgrounded :delete_spam!
|
30
|
+
|
31
|
+
def delete_spam!
|
32
|
+
end
|
23
33
|
end
|
24
|
-
end
|
25
34
|
|
26
|
-
class
|
27
|
-
|
28
|
-
|
29
|
-
|
35
|
+
class Dog
|
36
|
+
backgrounded :bark => {:priority => :low}
|
37
|
+
|
38
|
+
def bark
|
39
|
+
end
|
30
40
|
end
|
31
|
-
end
|
32
41
|
|
33
|
-
class
|
34
|
-
|
42
|
+
class Entry
|
43
|
+
backgrounded :do_stuff
|
44
|
+
backgrounded :notify_users
|
35
45
|
|
36
|
-
|
46
|
+
def do_stuff
|
47
|
+
end
|
48
|
+
def notify_users
|
49
|
+
end
|
37
50
|
end
|
38
|
-
end
|
39
51
|
|
40
|
-
|
52
|
+
|
41
53
|
context 'an object with a single backgrounded method' do
|
42
54
|
setup do
|
43
55
|
@user = User.new
|
@@ -80,6 +92,16 @@ class BackgroundedTest < Test::Unit::TestCase
|
|
80
92
|
end
|
81
93
|
end
|
82
94
|
|
95
|
+
context 'an object with multiple backgrounded invokations' do
|
96
|
+
setup do
|
97
|
+
@post = Entry.new
|
98
|
+
end
|
99
|
+
should "setup options for both methods" do
|
100
|
+
assert_not_nil Entry.backgrounded_options[:do_stuff]
|
101
|
+
assert_not_nil Entry.backgrounded_options[:notify_users]
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
83
105
|
context 'an object with backgrounded method options' do
|
84
106
|
setup do
|
85
107
|
@dog = Dog.new
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backgrounded
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 2
|
10
|
+
version: 0.6.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Sonnek
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-27 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/backgrounded/handler/workling_handler.rb
|
103
103
|
- test/backgrounded/handler/delayed_job_handler_test.rb
|
104
104
|
- test/backgrounded/handler/resque_handler_test.rb
|
105
|
+
- test/backgrounded/handler/workling_handler_test.rb
|
105
106
|
- test/backgrounded_test.rb
|
106
107
|
- test/database.yml
|
107
108
|
- test/test_helper.rb
|
@@ -142,5 +143,6 @@ summary: Simple API to run Model methods in the background
|
|
142
143
|
test_files:
|
143
144
|
- test/backgrounded/handler/delayed_job_handler_test.rb
|
144
145
|
- test/backgrounded/handler/resque_handler_test.rb
|
146
|
+
- test/backgrounded/handler/workling_handler_test.rb
|
145
147
|
- test/backgrounded_test.rb
|
146
148
|
- test/test_helper.rb
|