tra 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tra/mailbox.rb +21 -7
- data/lib/tra.rb +3 -2
- data/test.rb +1 -1
- data/tra.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12350315bcfa8dc01152aa678632723a527d5e80
|
4
|
+
data.tar.gz: 6ee3aad4b5f4dd27eb1743d6b15d55d7e489f22d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9d807432a2f1e5de0f4a84ab4c609eef282cb4d70e0e96a32a6f70c2c78a6133d932624c1437a13cccc394e840f75d569e137fa51c8169a11e832f83d0f1597
|
7
|
+
data.tar.gz: 648c210b376d7089aeefec8f0d5d4034f2aa9de7d9fba7d3293188fdc6921a8d25da23f5ac5bd6cf390fa5960f81e670cb385f376f542a2b9c4e9a9aac40711f
|
data/lib/tra/mailbox.rb
CHANGED
@@ -1,16 +1,30 @@
|
|
1
1
|
module Tra
|
2
2
|
module Mailbox
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
class << self
|
4
|
+
def receive
|
5
|
+
Dir.mkdir DIRECTORY unless Dir.exist? DIRECTORY
|
6
|
+
file = FILE[Process.pid]
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
Thread.new do
|
9
|
+
Socket.unix_server_loop file do |socket|
|
10
|
+
QUEUE << (Marshal.load socket.read size_of_message_from socket)
|
11
|
+
end
|
10
12
|
end
|
13
|
+
|
14
|
+
sleep 0.01 until File.exist? file
|
11
15
|
end
|
12
16
|
|
13
|
-
|
17
|
+
private
|
18
|
+
def size_of_message_from socket
|
19
|
+
size = String.new
|
20
|
+
|
21
|
+
while digit = socket.read(1)
|
22
|
+
break if digit == ?:
|
23
|
+
size << digit
|
24
|
+
end
|
25
|
+
|
26
|
+
size.to_i
|
27
|
+
end
|
14
28
|
end
|
15
29
|
end
|
16
30
|
end
|
data/lib/tra.rb
CHANGED
@@ -7,7 +7,7 @@ require_relative 'tra/fork'
|
|
7
7
|
module Tra
|
8
8
|
QUEUE = Queue.new
|
9
9
|
|
10
|
-
DIRECTORY = "/tmp/
|
10
|
+
DIRECTORY = "/tmp/tra"
|
11
11
|
FILE = -> pid { "#{DIRECTORY}/#{pid}" }
|
12
12
|
|
13
13
|
class << self
|
@@ -33,7 +33,8 @@ module Tra
|
|
33
33
|
def patch_Integer_shamelessly
|
34
34
|
Integer.class_eval do
|
35
35
|
def put message
|
36
|
-
|
36
|
+
message = Marshal.dump message
|
37
|
+
Socket.unix(FILE[self]).write "#{message.size}:#{message}"
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
data/test.rb
CHANGED
data/tra.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anatoly Chernow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|