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 +4 -4
- data/.gitignore +1 -0
- data/deadly_serious.gemspec +1 -1
- data/lib/deadly_serious/engine/base_process.rb +27 -0
- data/lib/deadly_serious/engine/channel.rb +4 -1
- data/lib/deadly_serious/engine/push_pop.rb +27 -0
- data/lib/deadly_serious/engine/push_pop_send.rb +11 -0
- data/lib/deadly_serious/engine/spawner.rb +10 -1
- data/lib/deadly_serious/version.rb +1 -1
- data/lib/deadly_serious.rb +3 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68d3c2f2fb290436ae2543707c16063f4747b7c4
|
4
|
+
data.tar.gz: 76d915c5453302c81cd2b9a0cb7171824212f340
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9796184360d511d9c3dc54ef94b31d965adbd25c54f347866118f3b6afd3b8beb73ce3a1a669c026bd6fc8426f8df0be7ff2f9deb25cdd9e5e29a5100d4a57e4
|
7
|
+
data.tar.gz: 27c775a1c743c74c34c707d1176302ccf9bd23a347d606dbe3e19b699953e871d7ca9f72dd9fab47c94d5747e2eb39570dbac7e4cdb84791959d363d3b2a34d9
|
data/.gitignore
CHANGED
data/deadly_serious.gemspec
CHANGED
@@ -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
|
@@ -57,7 +57,7 @@ module DeadlySerious
|
|
57
57
|
|
58
58
|
def kill_children
|
59
59
|
@ids.each { |id| Process.kill('SIGTERM', id) }
|
60
|
-
|
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
|
data/lib/deadly_serious.rb
CHANGED
@@ -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.
|
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-
|
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
|