deadly_serious 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
  SHA1:
3
- metadata.gz: 6d49228267a17e2649bbc4809171dfc08bb7680e
4
- data.tar.gz: a830668ca8fe3fc3bd571453abc4fdf398d17aae
3
+ metadata.gz: 68d3c2f2fb290436ae2543707c16063f4747b7c4
4
+ data.tar.gz: 76d915c5453302c81cd2b9a0cb7171824212f340
5
5
  SHA512:
6
- metadata.gz: 78856ba4d5335ec4721c6f44c9abc8f2e85deacf439d98832aea4a65172c1eb653399b2f201317a8e3fa24e99543273d96679eb07f47a836b8e04e07aa8ca0b1
7
- data.tar.gz: ee8f976cbb6e80a9cc9f9d5b9f3345e91bde39ddf92b14f1f9c446c828e1fab93d85dd4a22fb39e09cb08e02b5bd6a84189c5cd12c0f497cf0fb9988561a4cc4
6
+ metadata.gz: 9796184360d511d9c3dc54ef94b31d965adbd25c54f347866118f3b6afd3b8beb73ce3a1a669c026bd6fc8426f8df0be7ff2f9deb25cdd9e5e29a5100d4a57e4
7
+ data.tar.gz: 27c775a1c743c74c34c707d1176302ccf9bd23a347d606dbe3e19b699953e871d7ca9f72dd9fab47c94d5747e2eb39570dbac7e4cdb84791959d363d3b2a34d9
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ output.data
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = 'https://github.com/ruliana/deadly_serious'
14
14
  spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files`.split($/)
16
+ spec.files = `git ls-files`.split($/).reject { |file| file =~ /^examples\// }
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
@@ -0,0 +1,27 @@
1
+ module DeadlySerious
2
+ module Engine
3
+ module BaseProcess
4
+ def run(readers: [], writers:[])
5
+ reader = readers.first
6
+ @writer = writers.first
7
+
8
+ reader.each { |packet| super(packet.chomp) }
9
+ end
10
+
11
+ def send(packet = nil)
12
+ send_buffered(packet)
13
+ flush_buffer
14
+ end
15
+
16
+ def send_buffered(packet = nil)
17
+ @writer << packet if packet
18
+ @writer << "\n"
19
+ end
20
+
21
+ def flush_buffer
22
+ @writer.flush
23
+ end
24
+ end
25
+ end
26
+ end
27
+
@@ -12,13 +12,16 @@ module DeadlySerious
12
12
  end
13
13
  end
14
14
 
15
+ # Create a pipe or file (acording to name)
16
+ # and returns the full name of the thing created.
15
17
  def create
16
- return if File.exist?(@io_name)
18
+ return @io_name if File.exist?(@io_name)
17
19
  if @type == :file
18
20
  `touch #{@io_name}`
19
21
  else
20
22
  `mkfifo #{@io_name}`
21
23
  end
24
+ @io_name
22
25
  end
23
26
 
24
27
  def open_reader
@@ -0,0 +1,27 @@
1
+ module DeadlySerious
2
+ module Engine
3
+ module PushPop
4
+ attr_reader :stack
5
+
6
+ def push(value)
7
+ stack.push(value)
8
+ end
9
+
10
+ def pop
11
+ stack.pop
12
+ end
13
+
14
+ def top_stack(quantity)
15
+ stack[(-quantity)..-1]
16
+ end
17
+
18
+ def stack
19
+ @stack ||= []
20
+ end
21
+
22
+ def reset_stack
23
+ @stack = []
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,11 @@
1
+ require 'deadly_serious/engine/push_pop'
2
+ require 'deadly_serious/engine/base_process'
3
+
4
+ module DeadlySerious
5
+ module Engine
6
+ module PushPopSend
7
+ include PushPop
8
+ include BaseProcess
9
+ end
10
+ end
11
+ end
@@ -57,7 +57,7 @@ module DeadlySerious
57
57
 
58
58
  def kill_children
59
59
  @ids.each { |id| Process.kill('SIGTERM', id) }
60
- Process.wait
60
+ wait_children
61
61
  end
62
62
 
63
63
  def spawn_source(a_class, *args, writer: self.class.dasherize(a_class.name))
@@ -85,6 +85,15 @@ module DeadlySerious
85
85
  end
86
86
  end
87
87
 
88
+ def spawn_command(a_shell_command)
89
+ command = a_shell_command.dup
90
+ a_shell_command.scan(/\(\((.*?)\)\)/) do |(pipe_name)|
91
+ pipe_path = create_pipe(pipe_name)
92
+ command.gsub!("((#{pipe_name}))", pipe_path)
93
+ end
94
+ @ids << spawn(command)
95
+ end
96
+
88
97
  def run
89
98
  run_pipeline
90
99
  wait_children
@@ -1,3 +1,3 @@
1
1
  module DeadlySerious
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,5 +1,8 @@
1
1
  require 'deadly_serious/version'
2
2
  require 'deadly_serious/engine/spawner'
3
+ require 'deadly_serious/engine/base_process'
4
+ require 'deadly_serious/engine/push_pop'
5
+ require 'deadly_serious/engine/push_pop_send' # Compatibility with 0.2.0
3
6
 
4
7
  # Loading all predefined processes
5
8
  Dir[File.dirname(__FILE__) + '/deadly_serious/processes/*.rb'].each do |file|
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.2.0
4
+ version: 0.3.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: 2013-07-01 00:00:00.000000000 Z
11
+ date: 2013-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,9 +66,12 @@ files:
66
66
  - Rakefile
67
67
  - deadly_serious.gemspec
68
68
  - lib/deadly_serious.rb
69
+ - lib/deadly_serious/engine/base_process.rb
69
70
  - lib/deadly_serious/engine/channel.rb
70
71
  - lib/deadly_serious/engine/json_io.rb
71
72
  - lib/deadly_serious/engine/json_process.rb
73
+ - lib/deadly_serious/engine/push_pop.rb
74
+ - lib/deadly_serious/engine/push_pop_send.rb
72
75
  - lib/deadly_serious/engine/spawner.rb
73
76
  - lib/deadly_serious/processes/db_source.rb
74
77
  - lib/deadly_serious/processes/joiner.rb