deadly_serious 0.5.3 → 0.6.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
  SHA1:
3
- metadata.gz: d23e28dcbb3b663230662efee896380d76d50c35
4
- data.tar.gz: 26f2d96349624ea4c96610da398a32247a305023
3
+ metadata.gz: e2660edb3604e3dd346527a39f1534c4b16911e1
4
+ data.tar.gz: e37197eb3b3a5baaa731a6be7ab9a5a664a264f0
5
5
  SHA512:
6
- metadata.gz: da85a130c1aea27bdc2d25f2205937a894d21bfc09fb6b9ebe9c56c37c73fc0a8e8d47e045f243355780aabe5b95838617b66bfe00de04740956cbf42571f87f
7
- data.tar.gz: 4d0379d0437f184b1478ecb5ddc7965873b5303c9755dd561953e1a9ce8e78f5dc51b27fc4a7e40c9e75821d94d3a327f1151655fce91df6b7e0b9b4bf70ccae
6
+ metadata.gz: bcbee1a6698414cb4ca2b05fda4f77521c011092fe49ca3cb9ee212c7f2fcf8a8d621e8bedc48f89929c0478adfbe9b79143fffbaa2140f80fd4d9e33e3af298
7
+ data.tar.gz: 706924bd1b8a6343b0e7c494f0933431fe3c7bc06d977132710100f4882e55011d6ecb2e805c77126e54913a333cd640bc169b797e4d2627ca2386eca198423f
@@ -5,12 +5,13 @@ module DeadlySerious
5
5
  reader = readers.first
6
6
  @writer = writers.first
7
7
 
8
- reader.each { |packet| super(packet.chomp) }
9
- end
10
-
11
- # Alias to #send
12
- def emit(packet = nil)
13
- send(packet)
8
+ if reader
9
+ reader.each { |packet| super(packet.chomp) }
10
+ else
11
+ super()
12
+ end
13
+ rescue Errno::EPIPE
14
+ # Ignore it. We expect that sometimes =)
14
15
  end
15
16
 
16
17
  # Send a packet to the next process
@@ -19,6 +20,8 @@ module DeadlySerious
19
20
  flush_buffer
20
21
  end
21
22
 
23
+ alias :emit :send
24
+
22
25
  # Send a packet to the next process,
23
26
  # however, accumulate some of them
24
27
  # before send to gain a little
@@ -0,0 +1,32 @@
1
+ require 'deadly_serious/engine/json_io'
2
+
3
+ module DeadlySerious
4
+ module Engine
5
+ module SimpleJsonProcess
6
+
7
+ def run(readers: [], writers: [])
8
+ reader = JsonIo.new(readers.first) unless readers.empty?
9
+ @writer = JsonIo.new(writers.first) unless writers.empty?
10
+
11
+ if reader
12
+ reader.each do |packet|
13
+ super(*packet)
14
+ end
15
+ else
16
+ super()
17
+ end
18
+ rescue Errno::EPIPE
19
+ # Ignore it. We expect that sometimes =)
20
+ end
21
+
22
+ # Send a packet to the next process
23
+ def send(*packet)
24
+ raise 'No "writer" defined' unless @writer
25
+ @writer << packet unless packet.empty?
26
+ end
27
+
28
+ alias :emit :send
29
+ end
30
+ end
31
+ end
32
+
@@ -26,9 +26,15 @@ module DeadlySerious
26
26
  def spawn_process(a_class, *args, process_name: a_class.name, readers: [], writers: [])
27
27
  writers.each { |writer| create_pipe(writer) }
28
28
  fork_it do
29
- set_process_name(process_name)
30
- append_open_io_if_needed(a_class)
31
- a_class.new.run(*args, readers: readers, writers: writers)
29
+ begin
30
+ set_process_name(process_name)
31
+ append_open_io_if_needed(a_class)
32
+ the_object = a_class.new
33
+ the_object.run(*args, readers: readers, writers: writers)
34
+ rescue => e
35
+ the_object.finalize if the_object.respond_to?(:finalize)
36
+ raise e
37
+ end
32
38
  end
33
39
  end
34
40
 
@@ -1,3 +1,3 @@
1
1
  module DeadlySerious
2
- VERSION = "0.5.3"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deadly_serious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ronie Uliana
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-06 00:00:00.000000000 Z
11
+ date: 2014-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -74,6 +74,7 @@ files:
74
74
  - lib/deadly_serious/engine/open_io.rb
75
75
  - lib/deadly_serious/engine/push_pop.rb
76
76
  - lib/deadly_serious/engine/push_pop_send.rb
77
+ - lib/deadly_serious/engine/simple_json_process.rb
77
78
  - lib/deadly_serious/engine/spawner.rb
78
79
  - lib/deadly_serious/processes/db_source.rb
79
80
  - lib/deadly_serious/processes/joiner.rb