deadly_serious 0.1.0 → 0.2.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d49228267a17e2649bbc4809171dfc08bb7680e
|
4
|
+
data.tar.gz: a830668ca8fe3fc3bd571453abc4fdf398d17aae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78856ba4d5335ec4721c6f44c9abc8f2e85deacf439d98832aea4a65172c1eb653399b2f201317a8e3fa24e99543273d96679eb07f47a836b8e04e07aa8ca0b1
|
7
|
+
data.tar.gz: ee8f976cbb6e80a9cc9f9d5b9f3345e91bde39ddf92b14f1f9c446c828e1fab93d85dd4a22fb39e09cb08e02b5bd6a84189c5cd12c0f497cf0fb9988561a4cc4
|
@@ -1,11 +1,15 @@
|
|
1
1
|
module DeadlySerious
|
2
2
|
module Engine
|
3
3
|
class Channel
|
4
|
-
def initialize(name,
|
4
|
+
def initialize(name, data_dir: nil, pipe_dir: nil)
|
5
5
|
matcher = name.match(/^(>?)(.*)$/)
|
6
6
|
@type = matcher[1] == '>' ? :file : :pipe
|
7
7
|
name = matcher[2]
|
8
|
-
@io_name =
|
8
|
+
@io_name = if @type == :file
|
9
|
+
"#{data_dir}/#{name}"
|
10
|
+
else
|
11
|
+
"#{pipe_dir}/#{name}"
|
12
|
+
end
|
9
13
|
end
|
10
14
|
|
11
15
|
def create
|
@@ -4,7 +4,8 @@ require 'deadly_serious/engine/channel'
|
|
4
4
|
module DeadlySerious
|
5
5
|
module Engine
|
6
6
|
class Spawner
|
7
|
-
def initialize(pipe_dir: "/tmp/deadly_serious/#{Process.pid}", preserve_pipe_dir: false)
|
7
|
+
def initialize(data_dir: './data', pipe_dir: "/tmp/deadly_serious/#{Process.pid}", preserve_pipe_dir: false)
|
8
|
+
@data_dir = data_dir
|
8
9
|
@pipe_dir = pipe_dir
|
9
10
|
@ids = []
|
10
11
|
|
@@ -23,16 +24,20 @@ module DeadlySerious
|
|
23
24
|
$0 = "ruby #{self.class.dasherize(name)}"
|
24
25
|
end
|
25
26
|
|
27
|
+
def channel_for(pipe_name)
|
28
|
+
Channel.new(pipe_name, data_dir: @data_dir, pipe_dir: @pipe_dir)
|
29
|
+
end
|
30
|
+
|
26
31
|
def create_pipe(pipe_name)
|
27
|
-
|
32
|
+
channel_for(pipe_name).create
|
28
33
|
end
|
29
34
|
|
30
35
|
def read_pipe(pipe_name)
|
31
|
-
|
36
|
+
channel_for(pipe_name).open_reader
|
32
37
|
end
|
33
38
|
|
34
39
|
def write_pipe(pipe_name)
|
35
|
-
channel =
|
40
|
+
channel = channel_for(pipe_name)
|
36
41
|
return channel.open_writer unless block_given?
|
37
42
|
|
38
43
|
channel.open_writer do |io|
|