parallizer 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +46 -0
- data/Gemfile +1 -18
- data/Gemfile.lock +19 -34
- data/Rakefile +5 -34
- data/lib/parallizer/version.rb +3 -0
- data/lib/parallizer.rb +1 -0
- data/parallizer.gemspec +17 -58
- data/spec/parallizer/method_call_notifier_spec.rb +23 -0
- data/{test/parallizer/proxy_test.rb → spec/parallizer/proxy_spec.rb} +36 -36
- data/{test/parallizer_test.rb → spec/parallizer_spec.rb} +39 -40
- data/spec/spec_helper.rb +7 -0
- metadata +34 -66
- data/VERSION +0 -1
- data/test/helper.rb +0 -21
- data/test/parallizer/method_call_notifier_test.rb +0 -23
data/.gitignore
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
|
4
|
+
# rdoc generated
|
5
|
+
rdoc
|
6
|
+
|
7
|
+
# yard generated
|
8
|
+
doc
|
9
|
+
.yardoc
|
10
|
+
|
11
|
+
# bundler
|
12
|
+
.bundle
|
13
|
+
*.gem
|
14
|
+
|
15
|
+
# jeweler generated
|
16
|
+
pkg
|
17
|
+
|
18
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
19
|
+
#
|
20
|
+
# * Create a file at ~/.gitignore
|
21
|
+
# * Include files you want ignored
|
22
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
23
|
+
#
|
24
|
+
# After doing this, these files will be ignored in all your git projects,
|
25
|
+
# saving you from having to 'pollute' every project you touch with them
|
26
|
+
#
|
27
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
28
|
+
#
|
29
|
+
# For MacOS:
|
30
|
+
|
31
|
+
.DS_Store
|
32
|
+
|
33
|
+
# For TextMate
|
34
|
+
*.tmproj
|
35
|
+
tmtags
|
36
|
+
.tmtags
|
37
|
+
|
38
|
+
# For emacs:
|
39
|
+
*~
|
40
|
+
\#*
|
41
|
+
.\#*
|
42
|
+
|
43
|
+
# For vim:
|
44
|
+
*.swp
|
45
|
+
|
46
|
+
.rvmrc
|
data/Gemfile
CHANGED
@@ -1,21 +1,4 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
5
2
|
|
6
|
-
|
7
|
-
# Include everything needed to run rake, tests, features, etc.
|
8
|
-
gem "bundler"
|
9
|
-
gem "jeweler"
|
10
|
-
|
11
|
-
gem "work_queue", ">= 0"
|
12
|
-
|
13
|
-
group :test do
|
14
|
-
gem "minitest", "2.12.1"
|
15
|
-
gem "minitest-extra-assertions", "0.1.0", :require => nil # guarantee it gets loaded after minitest
|
16
|
-
gem "minitest-reporters", "0.7.0"
|
17
|
-
gem "always_execute", "0.0.2", :require => nil
|
18
|
-
gem "shoulda", "2.11.3", :require => nil
|
19
|
-
gem "mocha", "0.9.8", :require => nil
|
20
|
-
end
|
3
|
+
gemspec
|
21
4
|
|
data/Gemfile.lock
CHANGED
@@ -1,43 +1,28 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
parallizer (0.2.1)
|
5
|
+
work_queue (~> 2.5.2)
|
6
|
+
|
1
7
|
GEM
|
2
8
|
remote: http://rubygems.org/
|
3
9
|
specs:
|
4
|
-
always_execute (0.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
json (1.7.4)
|
15
|
-
minitest (2.12.1)
|
16
|
-
minitest-extra-assertions (0.1.0)
|
17
|
-
minitest-reporters (0.7.0)
|
18
|
-
ansi
|
19
|
-
builder
|
20
|
-
minitest (~> 2.0)
|
21
|
-
ruby-progressbar
|
22
|
-
mocha (0.9.8)
|
23
|
-
rake
|
24
|
-
rake (0.9.2.2)
|
25
|
-
rdoc (3.12)
|
26
|
-
json (~> 1.4)
|
27
|
-
ruby-progressbar (0.0.10)
|
28
|
-
shoulda (2.11.3)
|
10
|
+
always_execute (0.1.1)
|
11
|
+
diff-lcs (1.1.3)
|
12
|
+
rspec (2.9.0)
|
13
|
+
rspec-core (~> 2.9.0)
|
14
|
+
rspec-expectations (~> 2.9.0)
|
15
|
+
rspec-mocks (~> 2.9.0)
|
16
|
+
rspec-core (2.9.0)
|
17
|
+
rspec-expectations (2.9.1)
|
18
|
+
diff-lcs (~> 1.1.3)
|
19
|
+
rspec-mocks (2.9.0)
|
29
20
|
work_queue (2.5.2)
|
30
21
|
|
31
22
|
PLATFORMS
|
32
23
|
ruby
|
33
24
|
|
34
25
|
DEPENDENCIES
|
35
|
-
always_execute (
|
36
|
-
|
37
|
-
|
38
|
-
minitest (= 2.12.1)
|
39
|
-
minitest-extra-assertions (= 0.1.0)
|
40
|
-
minitest-reporters (= 0.7.0)
|
41
|
-
mocha (= 0.9.8)
|
42
|
-
shoulda (= 2.11.3)
|
43
|
-
work_queue
|
26
|
+
always_execute (~> 0.1.1)
|
27
|
+
parallizer!
|
28
|
+
rspec (~> 2.9.0)
|
data/Rakefile
CHANGED
@@ -1,36 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'rake'
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
11
3
|
|
12
|
-
|
13
|
-
|
14
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
-
gem.name = "parallizer"
|
16
|
-
gem.homepage = "http://github.com/michaelgpearce/parallizer"
|
17
|
-
gem.license = "MIT"
|
18
|
-
gem.summary = %Q{Execute your service layer in parallel.}
|
19
|
-
gem.description = %Q{Execute your service layer in parallel.}
|
20
|
-
gem.email = "michael.pearce@bookrenter.com"
|
21
|
-
gem.authors = ["Michael Pearce"]
|
22
|
-
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
-
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
-
gem.add_runtime_dependency 'work_queue', '>= 0'
|
25
|
-
gem.add_development_dependency 'shoulda', '>= 0'
|
26
|
-
end
|
27
|
-
Jeweler::RubygemsDotOrgTasks.new
|
4
|
+
desc 'Run Specs'
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
28
6
|
|
29
|
-
|
30
|
-
Rake::TestTask.new(:test) do |test|
|
31
|
-
test.libs << 'lib' << 'test'
|
32
|
-
test.pattern = 'test/**/*_test.rb'
|
33
|
-
test.verbose = true
|
34
|
-
end
|
35
|
-
|
36
|
-
task :default => :test
|
7
|
+
task :default => :spec
|
data/lib/parallizer.rb
CHANGED
data/parallizer.gemspec
CHANGED
@@ -1,65 +1,24 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
require "parallizer/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
7
|
+
s.name = "parallizer"
|
8
|
+
s.version = Parallizer::VERSION
|
9
|
+
s.authors = ["Michael Pearce"]
|
10
|
+
s.email = ["michaelgpearce@yahoo.com"]
|
11
|
+
s.homepage = "http://github.com/michaelgpearce/parallizer"
|
12
|
+
s.summary = %q{Execute your service layer in parallel}
|
13
|
+
s.description = %q{Execute your service layer in parallel.}
|
9
14
|
|
10
|
-
s.
|
11
|
-
s.authors = ["Michael Pearce"]
|
12
|
-
s.date = "2012-08-15"
|
13
|
-
s.description = "Execute your service layer in parallel."
|
14
|
-
s.email = "michael.pearce@bookrenter.com"
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE.txt",
|
17
|
-
"README.md"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
"Gemfile",
|
21
|
-
"Gemfile.lock",
|
22
|
-
"LICENSE.txt",
|
23
|
-
"README.md",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"lib/parallizer.rb",
|
27
|
-
"lib/parallizer/method_call_notifier.rb",
|
28
|
-
"lib/parallizer/proxy.rb",
|
29
|
-
"parallizer.gemspec",
|
30
|
-
"test/helper.rb",
|
31
|
-
"test/parallizer/method_call_notifier_test.rb",
|
32
|
-
"test/parallizer/proxy_test.rb",
|
33
|
-
"test/parallizer_test.rb"
|
34
|
-
]
|
35
|
-
s.homepage = "http://github.com/michaelgpearce/parallizer"
|
36
|
-
s.licenses = ["MIT"]
|
37
|
-
s.require_paths = ["lib"]
|
38
|
-
s.rubygems_version = "1.8.24"
|
39
|
-
s.summary = "Execute your service layer in parallel."
|
15
|
+
s.rubyforge_project = "parallizer"
|
40
16
|
|
41
|
-
|
42
|
-
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.require_paths = ["lib"]
|
43
20
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
s.add_runtime_dependency(%q<work_queue>, [">= 0"])
|
48
|
-
s.add_runtime_dependency(%q<work_queue>, [">= 0"])
|
49
|
-
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
50
|
-
else
|
51
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
52
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
53
|
-
s.add_dependency(%q<work_queue>, [">= 0"])
|
54
|
-
s.add_dependency(%q<work_queue>, [">= 0"])
|
55
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
56
|
-
end
|
57
|
-
else
|
58
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
59
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
60
|
-
s.add_dependency(%q<work_queue>, [">= 0"])
|
61
|
-
s.add_dependency(%q<work_queue>, [">= 0"])
|
62
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
63
|
-
end
|
21
|
+
s.add_dependency 'work_queue', '~> 2.5.2'
|
22
|
+
s.add_development_dependency 'rspec', '~> 2.9.0'
|
23
|
+
s.add_development_dependency 'always_execute', '~> 0.1.1'
|
64
24
|
end
|
65
|
-
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Parallizer::MethodCallNotifier do
|
4
|
+
describe "#method_missing" do
|
5
|
+
before do
|
6
|
+
@notifier = Parallizer::MethodCallNotifier.new do |*args|
|
7
|
+
@callback_args = args
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
execute do
|
12
|
+
@method_call_result = @notifier.call_a_method('with args')
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should call block on method call" do
|
16
|
+
@callback_args.should == [:call_a_method, 'with args']
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return the notifier" do
|
20
|
+
@method_call_result.should == @notifier
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
describe Parallizer::Proxy do
|
4
4
|
DEFAULT_RETURN_VALUE = "return value"
|
5
5
|
|
6
6
|
class TestObject
|
@@ -9,8 +9,8 @@ class Parallizer::ProxyTest < Test::Unit::TestCase
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
describe "#method_missing" do
|
13
|
+
before do
|
14
14
|
@client = TestObject.new
|
15
15
|
@call_key = []
|
16
16
|
@call_info = {:result => nil, :exception => nil, :complete? => true,
|
@@ -25,29 +25,29 @@ class Parallizer::ProxyTest < Test::Unit::TestCase
|
|
25
25
|
|
26
26
|
context "with method that exists on client" do
|
27
27
|
context "with method and arg call info" do
|
28
|
-
|
28
|
+
before do
|
29
29
|
@call_key += [:a_method, "some value"]
|
30
30
|
end
|
31
31
|
|
32
32
|
context "with not complete?" do
|
33
|
-
|
33
|
+
before do
|
34
34
|
@call_info[:complete?] = false
|
35
|
-
@call_info[:condition_variable].
|
35
|
+
@call_info[:condition_variable].should_receive(:wait).with(@call_info[:mutex])
|
36
36
|
@call_info[:result] = 'this is a value'
|
37
37
|
end
|
38
38
|
|
39
|
-
should do
|
40
|
-
|
39
|
+
it "should return the call_info result" do
|
40
|
+
@execute_result.should == @call_info[:result]
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
context "with complete? call info" do
|
45
|
-
|
45
|
+
before do
|
46
46
|
@call_info[:complete?] = true
|
47
47
|
end
|
48
48
|
|
49
49
|
context "with an exception" do
|
50
|
-
|
50
|
+
before do
|
51
51
|
@call_info[:exception] = StandardError.new('An Exception')
|
52
52
|
@call_info[:exception].set_backtrace(["/tmp/foo.rb:123:in `in a_worker_thread_method'"])
|
53
53
|
end
|
@@ -61,55 +61,55 @@ class Parallizer::ProxyTest < Test::Unit::TestCase
|
|
61
61
|
a_calling_thread_method
|
62
62
|
end
|
63
63
|
|
64
|
-
should
|
65
|
-
|
66
|
-
|
64
|
+
it "should raise exception" do
|
65
|
+
@execute_result.class.should == @call_info[:exception].class
|
66
|
+
@execute_result.message.should == @call_info[:exception].message
|
67
67
|
end
|
68
68
|
|
69
|
-
should
|
70
|
-
|
71
|
-
|
69
|
+
it "should append backtrace of current call" do
|
70
|
+
@execute_result.backtrace.join.should match /a_worker_thread_method/
|
71
|
+
@execute_result.backtrace.join.should match /a_calling_thread_method/
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
75
|
context "with a result" do
|
76
|
-
|
76
|
+
before do
|
77
77
|
@call_info[:result] = "a result"
|
78
78
|
end
|
79
79
|
|
80
|
-
should
|
81
|
-
|
80
|
+
it "should return result" do
|
81
|
+
@execute_result.should == @call_info[:result]
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
87
|
context "with no method and arg not in execute result" do
|
88
|
-
|
88
|
+
before do
|
89
89
|
@call_key += [:a_method, "some parameter"]
|
90
90
|
@call_info = nil
|
91
91
|
end
|
92
92
|
|
93
|
-
should
|
94
|
-
|
93
|
+
it "should return value from client object" do
|
94
|
+
@execute_result.should == DEFAULT_RETURN_VALUE
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
99
|
context "with method that does not exist on client" do
|
100
|
-
|
100
|
+
before do
|
101
101
|
@call_key += [:unknown_method, "some parameter"]
|
102
102
|
@call_info = nil
|
103
103
|
end
|
104
104
|
|
105
|
-
should
|
106
|
-
|
105
|
+
it "should raise exception" do
|
106
|
+
@execute_result.class.should == NoMethodError
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
|
112
|
-
|
111
|
+
describe "#respond_to?" do
|
112
|
+
before do
|
113
113
|
client = TestObject.new
|
114
114
|
call_key = [:a_method, 'valid argument']
|
115
115
|
call_info = {:result => nil, :exception => nil, :complete? => true,
|
@@ -117,20 +117,20 @@ class Parallizer::ProxyTest < Test::Unit::TestCase
|
|
117
117
|
@proxy = Parallizer::Proxy.new(client, { call_key => call_info })
|
118
118
|
end
|
119
119
|
|
120
|
-
should
|
121
|
-
|
120
|
+
it "should respond to proxy method as symbol" do
|
121
|
+
@proxy.should respond_to(:a_method)
|
122
122
|
end
|
123
123
|
|
124
|
-
should
|
125
|
-
|
124
|
+
it "should respond to proxy method as string" do
|
125
|
+
@proxy.should respond_to('a_method')
|
126
126
|
end
|
127
127
|
|
128
|
-
should
|
129
|
-
|
128
|
+
it "should respond to methods inherited from object" do
|
129
|
+
@proxy.should respond_to(:to_s)
|
130
130
|
end
|
131
131
|
|
132
|
-
should
|
133
|
-
|
132
|
+
it "should not respond to methods that do not exist" do
|
133
|
+
@proxy.should_not respond_to(:invalid_method)
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
describe Parallizer do
|
4
4
|
class TestObject
|
5
5
|
def a_method(arg)
|
6
6
|
Thread.current
|
@@ -21,8 +21,8 @@ class ParallizerTest < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
describe "#add" do
|
25
|
+
before do
|
26
26
|
@client = TestObject.new
|
27
27
|
@parallizer = Parallizer.new(@client)
|
28
28
|
end
|
@@ -31,13 +31,13 @@ class ParallizerTest < Test::Unit::TestCase
|
|
31
31
|
@parallizer.add.a_method('arg')
|
32
32
|
end
|
33
33
|
|
34
|
-
should
|
35
|
-
|
34
|
+
it "should add call to calls" do
|
35
|
+
@parallizer.calls.first.should == [:a_method, 'arg']
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
|
39
|
+
describe "#add_call" do
|
40
|
+
before do
|
41
41
|
@client = TestObject.new
|
42
42
|
@parallizer = Parallizer.new(@client)
|
43
43
|
end
|
@@ -47,38 +47,38 @@ class ParallizerTest < Test::Unit::TestCase
|
|
47
47
|
end
|
48
48
|
|
49
49
|
context "with proxy already created" do
|
50
|
-
|
51
|
-
@parallizer.instance_variable_set(:@proxy,
|
50
|
+
before do
|
51
|
+
@parallizer.instance_variable_set(:@proxy, stub('a client'))
|
52
52
|
end
|
53
53
|
|
54
|
-
should
|
55
|
-
|
54
|
+
it "should raise ArgumentError" do
|
55
|
+
@execute_result.class.should == ArgumentError
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
context "with string method name added" do
|
60
|
-
|
60
|
+
before do
|
61
61
|
@method = 'a_method'
|
62
62
|
end
|
63
63
|
|
64
|
-
should
|
65
|
-
|
64
|
+
it "should add call to calls" do
|
65
|
+
@parallizer.calls.first.should == [:a_method, 'arg']
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
context "with symbol method name" do
|
70
|
-
|
70
|
+
before do
|
71
71
|
@method = 'a_method'
|
72
72
|
end
|
73
73
|
|
74
|
-
should
|
75
|
-
|
74
|
+
it "should add call to calls" do
|
75
|
+
@parallizer.calls.first.should == [:a_method, 'arg']
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
|
81
|
-
|
80
|
+
describe "#create_proxy" do
|
81
|
+
before do
|
82
82
|
@client = TestObject.new
|
83
83
|
@parallizer = Parallizer.new(@client)
|
84
84
|
end
|
@@ -88,32 +88,32 @@ class ParallizerTest < Test::Unit::TestCase
|
|
88
88
|
end
|
89
89
|
|
90
90
|
context "with existing method on client" do
|
91
|
-
|
91
|
+
before do
|
92
92
|
@parallizer.add_call(:a_method, 'arg')
|
93
93
|
end
|
94
94
|
|
95
|
-
should
|
96
|
-
|
95
|
+
it "should execute method with add_call in a separate thread" do
|
96
|
+
@proxy.a_method('arg').should_not == Thread.current
|
97
97
|
end
|
98
98
|
|
99
|
-
should
|
100
|
-
|
99
|
+
it "should execute method not added with add_call in current thread" do
|
100
|
+
@proxy.another_method.should == Thread.current
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
104
|
context "with proxy already created" do
|
105
|
-
|
106
|
-
@parallizer.instance_variable_set(:@proxy,
|
105
|
+
before do
|
106
|
+
@parallizer.instance_variable_set(:@proxy, stub('a client'))
|
107
107
|
end
|
108
108
|
|
109
|
-
should
|
110
|
-
|
109
|
+
it "should raise ArgumentError" do
|
110
|
+
@execute_result.class.should == ArgumentError
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
115
|
context "with retries" do
|
116
|
-
|
116
|
+
before do
|
117
117
|
@retries = 3
|
118
118
|
@client = stub('a client')
|
119
119
|
@method = :a_sometimes_failing_method
|
@@ -127,25 +127,24 @@ class ParallizerTest < Test::Unit::TestCase
|
|
127
127
|
end
|
128
128
|
|
129
129
|
context "with success on last retry" do
|
130
|
-
|
131
|
-
|
132
|
-
@client.
|
133
|
-
@retries.times { @client.expects(@method).raises('an error') }
|
130
|
+
before do
|
131
|
+
@client.should_receive(@method).exactly(@retries).times.and_raise('an error')
|
132
|
+
@client.should_receive(@method).and_return('success')
|
134
133
|
end
|
135
134
|
|
136
|
-
should
|
137
|
-
|
135
|
+
it "should return successful method response" do
|
136
|
+
@execute_result.should == 'success'
|
138
137
|
end
|
139
138
|
end
|
140
139
|
|
141
140
|
|
142
141
|
context "with failures greater than retries" do
|
143
|
-
|
144
|
-
(@retries + 1).times { @client.
|
142
|
+
before do
|
143
|
+
(@retries + 1).times { @client.should_receive(@method).and_raise('an error') }
|
145
144
|
end
|
146
145
|
|
147
|
-
should
|
148
|
-
|
146
|
+
it "should return successful method response" do
|
147
|
+
@execute_result.message.should == 'an error'
|
149
148
|
end
|
150
149
|
end
|
151
150
|
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,113 +9,80 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: bundler
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: jeweler
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
14
|
- !ruby/object:Gem::Dependency
|
47
15
|
name: work_queue
|
48
16
|
requirement: !ruby/object:Gem::Requirement
|
49
17
|
none: false
|
50
18
|
requirements:
|
51
|
-
- -
|
19
|
+
- - ~>
|
52
20
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
21
|
+
version: 2.5.2
|
54
22
|
type: :runtime
|
55
23
|
prerelease: false
|
56
24
|
version_requirements: !ruby/object:Gem::Requirement
|
57
25
|
none: false
|
58
26
|
requirements:
|
59
|
-
- -
|
27
|
+
- - ~>
|
60
28
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
29
|
+
version: 2.5.2
|
62
30
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
31
|
+
name: rspec
|
64
32
|
requirement: !ruby/object:Gem::Requirement
|
65
33
|
none: false
|
66
34
|
requirements:
|
67
|
-
- -
|
35
|
+
- - ~>
|
68
36
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
70
|
-
type: :
|
37
|
+
version: 2.9.0
|
38
|
+
type: :development
|
71
39
|
prerelease: false
|
72
40
|
version_requirements: !ruby/object:Gem::Requirement
|
73
41
|
none: false
|
74
42
|
requirements:
|
75
|
-
- -
|
43
|
+
- - ~>
|
76
44
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
45
|
+
version: 2.9.0
|
78
46
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
47
|
+
name: always_execute
|
80
48
|
requirement: !ruby/object:Gem::Requirement
|
81
49
|
none: false
|
82
50
|
requirements:
|
83
|
-
- -
|
51
|
+
- - ~>
|
84
52
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
53
|
+
version: 0.1.1
|
86
54
|
type: :development
|
87
55
|
prerelease: false
|
88
56
|
version_requirements: !ruby/object:Gem::Requirement
|
89
57
|
none: false
|
90
58
|
requirements:
|
91
|
-
- -
|
59
|
+
- - ~>
|
92
60
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
61
|
+
version: 0.1.1
|
94
62
|
description: Execute your service layer in parallel.
|
95
|
-
email:
|
63
|
+
email:
|
64
|
+
- michaelgpearce@yahoo.com
|
96
65
|
executables: []
|
97
66
|
extensions: []
|
98
|
-
extra_rdoc_files:
|
99
|
-
- LICENSE.txt
|
100
|
-
- README.md
|
67
|
+
extra_rdoc_files: []
|
101
68
|
files:
|
69
|
+
- .gitignore
|
102
70
|
- Gemfile
|
103
71
|
- Gemfile.lock
|
104
72
|
- LICENSE.txt
|
105
73
|
- README.md
|
106
74
|
- Rakefile
|
107
|
-
- VERSION
|
108
75
|
- lib/parallizer.rb
|
109
76
|
- lib/parallizer/method_call_notifier.rb
|
110
77
|
- lib/parallizer/proxy.rb
|
78
|
+
- lib/parallizer/version.rb
|
111
79
|
- parallizer.gemspec
|
112
|
-
-
|
113
|
-
-
|
114
|
-
-
|
115
|
-
-
|
80
|
+
- spec/parallizer/method_call_notifier_spec.rb
|
81
|
+
- spec/parallizer/proxy_spec.rb
|
82
|
+
- spec/parallizer_spec.rb
|
83
|
+
- spec/spec_helper.rb
|
116
84
|
homepage: http://github.com/michaelgpearce/parallizer
|
117
|
-
licenses:
|
118
|
-
- MIT
|
85
|
+
licenses: []
|
119
86
|
post_install_message:
|
120
87
|
rdoc_options: []
|
121
88
|
require_paths:
|
@@ -126,9 +93,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
93
|
- - ! '>='
|
127
94
|
- !ruby/object:Gem::Version
|
128
95
|
version: '0'
|
129
|
-
segments:
|
130
|
-
- 0
|
131
|
-
hash: 1438464558148381221
|
132
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
97
|
none: false
|
134
98
|
requirements:
|
@@ -136,9 +100,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
100
|
- !ruby/object:Gem::Version
|
137
101
|
version: '0'
|
138
102
|
requirements: []
|
139
|
-
rubyforge_project:
|
103
|
+
rubyforge_project: parallizer
|
140
104
|
rubygems_version: 1.8.24
|
141
105
|
signing_key:
|
142
106
|
specification_version: 3
|
143
|
-
summary: Execute your service layer in parallel
|
144
|
-
test_files:
|
107
|
+
summary: Execute your service layer in parallel
|
108
|
+
test_files:
|
109
|
+
- spec/parallizer/method_call_notifier_spec.rb
|
110
|
+
- spec/parallizer/proxy_spec.rb
|
111
|
+
- spec/parallizer_spec.rb
|
112
|
+
- spec/spec_helper.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.2.0
|
data/test/helper.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'test/unit'
|
11
|
-
require 'shoulda'
|
12
|
-
require 'always_execute'
|
13
|
-
require 'mocha'
|
14
|
-
|
15
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
16
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
17
|
-
|
18
|
-
require 'parallizer'
|
19
|
-
|
20
|
-
class Test::Unit::TestCase
|
21
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class Parallizer::MethodCallNotifierTest < Test::Unit::TestCase
|
4
|
-
context ".method_missing" do
|
5
|
-
setup do
|
6
|
-
@notifier = Parallizer::MethodCallNotifier.new do |*args|
|
7
|
-
@callback_args = args
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
execute do
|
12
|
-
@method_call_result = @notifier.call_a_method('with args')
|
13
|
-
end
|
14
|
-
|
15
|
-
should "call block on method call" do
|
16
|
-
assert_equal [:call_a_method, 'with args'], @callback_args
|
17
|
-
end
|
18
|
-
|
19
|
-
should "return the notifier" do
|
20
|
-
assert_equal @notifier, @method_call_result
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|