iprocess 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -10,21 +10,19 @@ __OVERVIEW__
10
10
 
11
11
  __DESCRIPTION__
12
12
 
13
- Provides a number of abstractions on top of spawning subprocesses and interprocess
14
- communication. It has a simple and easy to use API that supports synchronous and
15
- asynchronous method calls plus one or two other useful features shown in the
16
- examples below.
13
+ Provides a number of abstractions on top of spawning subprocesses and
14
+ interprocess communication. It has a simple and easy to use API that
15
+ supports synchronous and asynchronous method calls plus one or two other
16
+ useful features shown in the examples below.
17
17
 
18
18
  __EXAMPLES__
19
19
 
20
- The first two examples(one & two) are using the synchronous APIs, a little below
21
- those(3) demos the asynchronous API.
22
-
23
20
  __1.__
24
21
 
25
- Three subprocesses are spawned. The return value of the block, even though executed
26
- in a subprocess, is returned to the parent process as long as it may be serialized
27
- by Marshal(or the serializer of your choice, this is configurable):
22
+ Three subprocesses are spawned. The return value of the block, even though
23
+ executed in a subprocess, is returned to the parent process as long as it may
24
+ be serialized by Marshal(or the serializer of your choice, this is
25
+ configurable):
28
26
 
29
27
  messages = IProcess.spawn(3) { {msg: "hello"} }
30
28
  p messages # => [{msg: "hello"}, {msg: "hello"}, {msg: "hello"}]
@@ -44,11 +42,11 @@ try this:
44
42
  @num + 1
45
43
  end
46
44
  end
47
- IProcess.spawn(5, Worker.new) # => [2, 2, 2, 2, 2]
45
+ IProcess.spawn 5, Worker.new # => [2, 2, 2, 2, 2]
48
46
 
49
47
  __3.__
50
48
 
51
- A subprocess is spawned asynchronously.
49
+ A demo of how you would spawn two subprocesses asynchronously:
52
50
 
53
51
  class Inbox
54
52
  def initialize
@@ -60,7 +58,7 @@ A subprocess is spawned asynchronously.
60
58
  end
61
59
  end
62
60
  inbox = Inbox.new
63
- jobs = IProcess.spawn! { Process.pid }
61
+ jobs = IProcess.spawn!(2) { Process.pid }
64
62
  jobs.map { |job| job.report_to(inbox) }
65
63
 
66
64
  __SERIALIZERS__
data/Rakefile CHANGED
@@ -1,9 +1,7 @@
1
1
  require 'bundler/gem_tasks'
2
-
3
- desc 'Run test suite.'
4
2
  task :test do
5
- require './test/setup'
3
+ Dir["test/test_*.rb"].each do |test|
4
+ require_relative test
5
+ end
6
6
  end
7
-
8
7
  task :default => :test
9
-
@@ -1,3 +1,3 @@
1
1
  class IProcess
2
- VERSION = '3.1.1'
2
+ VERSION = '3.1.2'
3
3
  end
data/lib/iprocess.rb CHANGED
@@ -64,7 +64,7 @@ class IProcess
64
64
 
65
65
  #
66
66
  # @param [#call] worker
67
- # A block or any object that implements #call.
67
+ # Any object that implements #call.
68
68
  #
69
69
  # @raise [ArgumentError]
70
70
  # If 'worker' does not respond to #call.
data/test/setup.rb CHANGED
@@ -1,9 +1,5 @@
1
1
  require 'iprocess'
2
- require 'minitest/spec'
3
- require 'minitest/autorun'
4
-
5
- alias :context :describe
6
-
2
+ require 'test/unit'
7
3
  Dir.glob("test/*.rb").each do |test|
8
4
  require "./#{test}"
9
5
  end
@@ -1,26 +1,25 @@
1
- context IProcess do
2
- context 'spawn' do
3
- it 'spawns two Proc workers.' do
4
- topic = IProcess.spawn(2) { :ok }
5
- topic.must_equal([:ok, :ok])
6
- end
1
+ require_relative "setup"
2
+ class IProcessTest < Test::Unit::TestCase
3
+ def test_serializer_default_value
4
+ assert_equal Marshal, IProcess.serializer
5
+ end
7
6
 
8
- it 'spawns two non-Proc workers.' do
9
- worker =
10
- Class.new do
11
- def call
12
- :ok
13
- end
14
- end
7
+ def test_block_worker
8
+ messages = IProcess.spawn(2) { :hello }
9
+ assert_equal [:hello, :hello], messages
10
+ end
15
11
 
16
- topic = IProcess.spawn(2, worker.new)
17
- topic.must_equal([:ok, :ok])
18
- end
12
+ def test_duck_typed_worker
13
+ messages = IProcess.spawn 2, worker.new
14
+ assert_equal [:hello, :hello], messages
19
15
  end
20
16
 
21
- context 'initialize' do
22
- it "raises if given an object who cannot respond to #call." do
23
- proc { IProcess.new(nil) }.must_raise(ArgumentError)
17
+ private
18
+ def worker
19
+ Class.new do
20
+ def call
21
+ :hello
22
+ end
24
23
  end
25
24
  end
26
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iprocess
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: