worker 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ffb171d04a5691eb61e7156c19bb17cc71a179af7979d60fbea10bc74ae2cd9
4
- data.tar.gz: 2df8110bd23aa3d97c284c38a3a24fa305b712e3d55dd6e3af8e0e360f91ddc9
3
+ metadata.gz: 230e471bd7fe37454a7ba582b15e4f06ef17bdc037b021d903a60e3f3307e0c9
4
+ data.tar.gz: 3ac9095f860d85be292ca7a7b9533ad4153ddbfcb7ac736b58852cc9cb0ec85a
5
5
  SHA512:
6
- metadata.gz: 00f0dbf42c4495d8878e67f39618b99496e17f09a650f461eb05f3f8535d616d41941f96a071909c341c639aa8f324ce475e220b4c5697f924733bf37dbfaa81
7
- data.tar.gz: a4e68891bacbb67a866db310980a649a9295ade5872fef95a82df9579ac80fe3ac3be67531794660ab2cb8a37262ffea6ff21de68e35ff22ac2627f373b1ed48
6
+ metadata.gz: 40a5843f71ff52a7754ae8b3735d5b01797523057a6076a71ceea8c092edfa4d6b8e1c4ab6a71282c7c4629b7d5a0c372b9ed472cef6cab51780676503725ac4
7
+ data.tar.gz: e01fbdbb7419d413a303a42ec4cf78e7641f7b1bf4578f13d32e868ec40b8364663e849587f2c708bf2429b4c4658380f76ab9f749f53bff05c457ddc672444f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- worker (0.2.0)
4
+ worker (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/examples/args.rb ADDED
@@ -0,0 +1,18 @@
1
+ require_relative "../lib/worker"
2
+
3
+ binary = Worker.new do |a,b|
4
+ raise "binary: a not integer" unless a.is_a? Integer
5
+ raise "binary: b not integer" unless b.is_a? Integer
6
+ end
7
+
8
+ unary = Worker.new do |a|
9
+ raise "unary: a not integer" unless a.is_a? Integer
10
+ end
11
+
12
+ unary_array = Worker.new do |a|
13
+ raise "unary_array: a not array" unless a.is_a? Array
14
+ end
15
+
16
+ binary.perform 1, 2
17
+ unary.perform 1
18
+ unary_array.perform [1]
data/lib/worker.rb CHANGED
@@ -13,6 +13,7 @@ class Worker
13
13
 
14
14
  def perform(*args)
15
15
  @in.push args
16
+
16
17
  ret = @out.pop
17
18
  if ret.is_a? Exception
18
19
  raise ret
@@ -24,7 +25,7 @@ class Worker
24
25
  def run!
25
26
  @thread = Thread.new do
26
27
  loop do
27
- ret = @ctx.instance_exec @in.pop, &@block
28
+ ret = @ctx.instance_exec *@in.pop, &@block
28
29
  @out.push ret
29
30
  rescue Exception => ex
30
31
  @out.push ex
data/worker.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "worker"
7
- spec.version = "0.2.0"
7
+ spec.version = "0.3.0"
8
8
  spec.authors = ["Matti Paksula"]
9
9
  spec.email = ["matti.paksula@iki.fi"]
10
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matti Paksula
@@ -72,6 +72,7 @@ files:
72
72
  - bin/console
73
73
  - bin/setup
74
74
  - examples/adder_memo.rb
75
+ - examples/args.rb
75
76
  - examples/simple.rb
76
77
  - lib/worker.rb
77
78
  - worker.gemspec