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: 2a2eec6d98bfb52e75ee34bf14e2ba4f95f5d2dc
4
- data.tar.gz: 46519dbfa6d0e4d709cf4cc760fea1f97065e506
3
+ metadata.gz: d531bf68d4aa36d2e021a6432e1fb24bb483464a
4
+ data.tar.gz: 1a508ce86e68b630d914108bd15648950ac4bd0a
5
5
  SHA512:
6
- metadata.gz: d4d9bb9cf57eb0d4cb926a6cbf8e87388b02df9cd356d336b97730fddf9bf45e7ffe05bc30993e74ebc4d719c1fb205f6f17ff05cc56a0c5b4b1fb507cd17fe0
7
- data.tar.gz: 0f35a6099deca0f41a03ab736fde1a9f3ec0c3712ad9d48ae6043178eba9ee32e5344d65222e8df348d3f35282ebf1b64f5ff4bba2fe6e3719bf7bb3941ecbf5
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
- def self.listen
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
- Office::Source.new(parent, apply_target_subs(parent, target), attributes)
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
- Office::Source.new(parent, apply_target_subs(parent, target), attributes)
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
@@ -1,7 +1,7 @@
1
1
  module Asciidoctor
2
2
  module Diagram
3
3
  module Office
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-diagram-office
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroyuki Wada