asciidoctor-diagram-office 0.1.1 → 0.1.2
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: d531bf68d4aa36d2e021a6432e1fb24bb483464a
|
4
|
+
data.tar.gz: 1a508ce86e68b630d914108bd15648950ac4bd0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06c18b6a3ee0a5cc6bea3dd89c8f36c806af6a73e0d1c7be12116e4f9025806636daf903d835e5bf120cb11aa8b3ed017802c7fcf02119bb18508693b7b62feb
|
7
|
+
data.tar.gz: 04acbaebdf8e6983df3e051a33ae2358df698a2fa445fe7ac66eceea355884b23d57019358d66f202187080c4494771340f3fccce8c919904c7125e2acdd3304
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'timeout'
|
1
2
|
require 'asciidoctor-diagram/extensions'
|
2
3
|
require 'asciidoctor-diagram/util/cli'
|
3
4
|
require 'asciidoctor-diagram/util/cli_generator'
|
@@ -8,10 +9,12 @@ module Asciidoctor
|
|
8
9
|
module Diagram
|
9
10
|
# @private
|
10
11
|
module OfficeServer
|
11
|
-
|
12
|
+
def self.listen
|
12
13
|
unless defined?(@office_listener) && @office_listener
|
13
|
-
pid = spawn('unoconv --listener')
|
14
|
+
pid = spawn('unoconv --listener > /dev/null 2>&1')
|
14
15
|
thr = Process.detach(pid)
|
16
|
+
is_port_open?
|
17
|
+
|
15
18
|
at_exit do
|
16
19
|
begin
|
17
20
|
Process.kill(:TERM, pid)
|
@@ -21,6 +24,23 @@ module Asciidoctor
|
|
21
24
|
@office_listener = true
|
22
25
|
end
|
23
26
|
end
|
27
|
+
|
28
|
+
def self.is_port_open?()
|
29
|
+
begin
|
30
|
+
Timeout::timeout(10) do
|
31
|
+
begin
|
32
|
+
s = TCPSocket.open('localhost', 2002)
|
33
|
+
s.close
|
34
|
+
return true
|
35
|
+
rescue
|
36
|
+
sleep(1)
|
37
|
+
retry
|
38
|
+
end
|
39
|
+
end
|
40
|
+
rescue Timeout::Error
|
41
|
+
raise 'Failed to start office listener'
|
42
|
+
end
|
43
|
+
end
|
24
44
|
end
|
25
45
|
|
26
46
|
# @private
|
@@ -99,7 +119,8 @@ module Asciidoctor
|
|
99
119
|
include Office
|
100
120
|
|
101
121
|
def create_source(parent, target, attributes)
|
102
|
-
|
122
|
+
image_file = parent.normalize_system_path(target, parent.attr('imagesdir'))
|
123
|
+
Office::Source.new(parent, image_file, attributes)
|
103
124
|
end
|
104
125
|
end
|
105
126
|
|
@@ -107,7 +128,8 @@ module Asciidoctor
|
|
107
128
|
include Office
|
108
129
|
|
109
130
|
def create_source(parent, target, attributes)
|
110
|
-
|
131
|
+
image_file = parent.normalize_system_path(target, parent.attr('imagesdir'))
|
132
|
+
Office::Source.new(parent, image_file, attributes)
|
111
133
|
end
|
112
134
|
end
|
113
135
|
end
|