asciidoctor-diagram 2.2.14 → 2.2.17

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
  SHA256:
3
- metadata.gz: c2447be8f4a47717d6ef4856ed210cbf44eaa09cd0ae154bb64119f3e309384d
4
- data.tar.gz: 8e40700cddd6d026c7ae4cd7cfafdf22704e01b4941eba2d274db91e103d700e
3
+ metadata.gz: 23e0718c877d72f84af027588bb5a9d100dda3568b34e89655f26c7cf7a4eb07
4
+ data.tar.gz: a4ecd6791f531cb9654651ae982e7e52406a462075814a78106188729388f45e
5
5
  SHA512:
6
- metadata.gz: 2e4c640aaa5ce31f00f94a10398d9ab9a29eca0a97359073645a82cd777ec860ad2a90ebc5ed549e65186a88d3e1c43a9f39250c1d2b6ba2745f31d4b3dd3679
7
- data.tar.gz: 9f54def1db4fd022b510a46daf33328b4854fb0d1dd7d3ba4bbc5a5dc1c966e4a37f548fdaa82c626024fdb31bdbf62218e1edbb1e8bdf1a7bf43fbf10116567
6
+ metadata.gz: 5982bee6e194b651cac1b55af22fb0cc7ccc51341e952f08f70c978efbf2a58d1392f2095607e574ab3078bc4c3b4c9b2424f75c0420f2bad7f8e033c45b52ee
7
+ data.tar.gz: 402707bbd842e2ec8fcf3da65ee60287d08dcbb0f5b0610313ca05985899c03d06a1199aab25632b06239df57d83408f7be73b53981653aaaa49c4f4884df4b8
data/CHANGELOG.adoc CHANGED
@@ -1,5 +1,28 @@
1
1
  = Asciidoctor-diagram Changelog
2
2
 
3
+ == 2.2.17
4
+
5
+ Bugfixes::
6
+
7
+ * Issue #455: Fix regression in reading of UTF-8 source files introduced in 2.2.15
8
+
9
+ == 2.2.16
10
+
11
+ Bugfixes::
12
+
13
+ * Issue #453: Avoid internal error when WaveDrom cannot be located
14
+
15
+ == 2.2.15
16
+
17
+ Enhacements::
18
+
19
+ * Issue #453: Improve error message when WaveDrom cannot be located
20
+
21
+ Bugfixes::
22
+
23
+ * Issue #428: Improve support for reading UTF-16 encoded source files
24
+ * Issue #449: Fix resolving of relative `!include` paths in Structurizr DSL input.
25
+
3
26
  == 2.2.14
4
27
 
5
28
  Bugfixes::
data/README.adoc CHANGED
@@ -23,16 +23,16 @@ The example below shows an embedded Ditaa diagram block.
23
23
  ---------
24
24
  [ditaa]
25
25
  ----
26
- +-------------+
27
- | asciidoctor |-----------+
28
- | diagram | |
29
- +-------------+ | image
30
- ^ |
31
- | diagram source |
32
- | v
33
- +--------+ +-----+-------+ /---------------\
34
- | adoc |-->+ asciidoctor + | HTML + image |
35
- +--------+ +-------------+ \---------------/
26
+ +-------------+
27
+ | asciidoctor |---------------+
28
+ | diagram | |
29
+ +-------------+ | image
30
+ ^ |
31
+ | diagram source |
32
+ | v
33
+ +--------+ +------+------+ /--------------\
34
+ | adoc |------>+ asciidoctor +------->| HTML + image |
35
+ +--------+ +-------------+ html \--------------/
36
36
  ----
37
37
  ---------
38
38
 
@@ -138,9 +138,10 @@ module Asciidoctor
138
138
 
139
139
  config[cmd_var] = cmd_path
140
140
 
141
- if cmd_path.nil? && options.fetch(:raise_on_error, true)
142
- raise "Could not find the #{cmd_names.map { |c| "'#{c}'" }.join(', ')} executable in PATH; add it to the PATH or specify its location using the '#{attr_names[0]}' document attribute"
143
- end
141
+ end
142
+
143
+ if cmd_path.nil? && options.fetch(:raise_on_error, true)
144
+ raise "Could not find the #{cmd_names.map { |c| "'#{c}'" }.join(', ')} executable in PATH; add it to the PATH or specify its location using the '#{attr_names[0]}' document attribute"
144
145
  end
145
146
 
146
147
  cmd_path
@@ -305,8 +306,7 @@ module Asciidoctor
305
306
 
306
307
  def load_code
307
308
  if @file_name
308
- lines = File.readlines(@file_name)
309
- lines = prepare_source_array(lines)
309
+ lines = prepare_source_array(File.read(@file_name, :mode => 'rb'))
310
310
  @parent_block.apply_subs(lines, resolve_diagram_subs).join("\n")
311
311
  else
312
312
  ''
@@ -315,39 +315,33 @@ module Asciidoctor
315
315
 
316
316
  private
317
317
 
318
- # Byte arrays for UTF-* Byte Order Marks
319
- BOM_BYTES_UTF_8 = [0xef, 0xbb, 0xbf]
320
- BOM_BYTES_UTF_16LE = [0xff, 0xfe]
321
- BOM_BYTES_UTF_16BE = [0xfe, 0xff]
318
+ # Raw binary strings for UTF-* Byte Order Marks
319
+ BOM_BYTES_UTF_8 = String.new("\xef\xbb\xbf", :encoding => Encoding::ASCII_8BIT)
320
+ BOM_BYTES_UTF_16LE = String.new("\xff\xfe", :encoding => Encoding::ASCII_8BIT)
321
+ BOM_BYTES_UTF_16BE = String.new("\xfe\xff", :encoding => Encoding::ASCII_8BIT)
322
322
 
323
- # Prepare the source data Array for parsing.
323
+ # Prepare the source data for parsing.
324
324
  #
325
- # Encodes the data to UTF-8, if necessary, and removes any trailing
325
+ # Encodes the data to UTF-8 and removes any trailing
326
326
  # whitespace from every line.
327
327
  #
328
- # If a BOM is found at the beginning of the data, a best attempt is made to
329
- # encode it to UTF-8 from the specified source encoding.
330
- #
331
- # data - the source data Array to prepare (no nil entries allowed)
328
+ # data - the source data to prepare
332
329
  #
333
330
  # returns a String Array of prepared lines
334
331
  def prepare_source_array data
335
332
  return [] if data.empty?
336
- if (leading_2_bytes = (leading_bytes = (first = data[0]).unpack 'C3').slice 0, 2) == BOM_BYTES_UTF_16LE
337
- data[0] = first.byteslice 2, first.bytesize
338
- # NOTE you can't split a UTF-16LE string using .lines when encoding is UTF-8; doing so will cause this line to fail
339
- return data.map {|line| (line.encode ::Encoding::UTF_8, ::Encoding::UTF_16LE).rstrip}
340
- elsif leading_2_bytes == BOM_BYTES_UTF_16BE
341
- data[0] = first.byteslice 2, first.bytesize
342
- return data.map {|line| (line.encode ::Encoding::UTF_8, ::Encoding::UTF_16BE).rstrip}
343
- elsif leading_bytes == BOM_BYTES_UTF_8
344
- data[0] = first.byteslice 3, first.bytesize
345
- end
346
- if first.encoding == ::Encoding::UTF_8
347
- data.map {|line| line.rstrip}
333
+
334
+ if data.start_with?(BOM_BYTES_UTF_16LE)
335
+ utf8_data = data.byteslice(2, data.bytesize).encode(::Encoding::UTF_8, ::Encoding::UTF_16LE)
336
+ elsif data.start_with?(BOM_BYTES_UTF_16BE)
337
+ utf8_data = data.byteslice(2, data.bytesize).encode(::Encoding::UTF_8, ::Encoding::UTF_16BE)
338
+ elsif data.start_with?(BOM_BYTES_UTF_8)
339
+ utf8_data = data.byteslice(3, data.bytesize).force_encoding(::Encoding::UTF_8)
348
340
  else
349
- data.map {|line| (line.encode ::Encoding::UTF_8).rstrip}
341
+ utf8_data = data.force_encoding(::Encoding::UTF_8)
350
342
  end
343
+
344
+ utf8_data.lines.map {|line| line.rstrip}
351
345
  end
352
346
  end
353
347
  end
@@ -49,6 +49,8 @@ module Asciidoctor
49
49
  'Accept' => Renderers.mime_type(options[:renderer])
50
50
  }
51
51
  headers['X-Structurizr-View'] = options[:view] if options[:view]
52
+ headers['X-Structurizr-IncludeDir'] = Platform.native_path(source.base_dir)
53
+
52
54
 
53
55
  response = Java.send_request(
54
56
  :url => '/structurizr',
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Diagram
3
- VERSION = "2.2.14"
3
+ VERSION = "2.2.17"
4
4
  end
5
5
  end
@@ -9,48 +9,53 @@ module Asciidoctor
9
9
  include DiagramConverter
10
10
  include CliGenerator
11
11
 
12
-
13
12
  def supported_formats
14
13
  [:png, :svg]
15
14
  end
16
15
 
17
-
18
16
  def convert(source, format, options)
19
- wavedrom_cli = source.find_command('wavedrom-cli', :raise_on_error => false)
20
- if wavedrom_cli
21
- generate_file(wavedrom_cli, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
17
+ wavedrom = source.find_command('wavedrom-cli', :attrs => ['wavedrom'], :raise_on_error => false)
18
+
19
+ unless wavedrom
20
+ wavedrom = source.find_command('wavedrom', :raise_on_error => false)
21
+ end
22
+
23
+ unless wavedrom
24
+ if ::Asciidoctor::Diagram::Platform.os == :macosx
25
+ wavedrom = source.find_command('WaveDromEditor.app', :alt_cmds => ['wavedrom-editor.app'], :attrs => ['WaveDromEditorApp'], :path => ['/Applications'], :raise_on_error => false)
26
+ if wavedrom
27
+ wavedrom = File.join(wavedrom, 'Contents/MacOS/nwjs')
28
+ end
29
+ else
30
+ wavedrom = source.find_command('WaveDromEditor', :raise_on_error => false)
31
+ end
32
+ end
33
+
34
+ unless wavedrom
35
+ source.find_command('wavedrom-cli', :attrs => ['wavedrom'])
36
+ end
37
+
38
+ if wavedrom.end_with?('-cli')
39
+ generate_file(wavedrom, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
22
40
  {
23
41
  :args => [Platform.native_path(tool_path), '--input', Platform.native_path(input_path), "--#{format.to_s}", Platform.native_path(output_path)],
24
42
  :chdir => source.base_dir
25
43
  }
26
44
  end
45
+ elsif wavedrom.include?('WaveDromEditor')
46
+ generate_file(wavedrom, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
47
+ {
48
+ :args => [tool_path, 'source', Platform.native_path(input_path), format.to_s, Platform.native_path(output_path)],
49
+ :chdir => source.base_dir
50
+ }
51
+ end
27
52
  else
28
- wavedrom_cli = source.find_command('wavedrom', :raise_on_error => false)
29
- phantomjs = source.find_command('phantomjs', :alt_attrs => ['phantomjs_2'], :raise_on_error => false)
30
-
31
- if wavedrom_cli && !wavedrom_cli.include?('WaveDromEditor') && phantomjs
32
- generate_file(wavedrom_cli, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
33
- {
34
- :args => [phantomjs, Platform.native_path(tool_path), '-i', Platform.native_path(input_path), "-#{format.to_s[0]}", Platform.native_path(output_path)],
35
- :chdir => source.base_dir
36
- }
37
- end
38
- else
39
- if ::Asciidoctor::Diagram::Platform.os == :macosx
40
- wavedrom = source.find_command('WaveDromEditor.app', :alt_cmds => ['wavedrom-editor.app'], :attrs => ['WaveDromEditorApp'], :path => ['/Applications'])
41
- if wavedrom
42
- wavedrom = File.join(wavedrom, 'Contents/MacOS/nwjs')
43
- end
44
- else
45
- wavedrom = source.find_command('WaveDromEditor')
46
- end
47
-
48
- generate_file(wavedrom, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
49
- {
50
- :args => [tool_path, 'source', Platform.native_path(input_path), format.to_s, Platform.native_path(output_path)],
51
- :chdir => source.base_dir
52
- }
53
- end
53
+ phantomjs = source.find_command('phantomjs', :alt_attrs => ['phantomjs_2'])
54
+ generate_file(wavedrom, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
55
+ {
56
+ :args => [phantomjs, Platform.native_path(tool_path), '-i', Platform.native_path(input_path), "-#{format.to_s[0]}", Platform.native_path(output_path)],
57
+ :chdir => source.base_dir
58
+ }
54
59
  end
55
60
  end
56
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-diagram
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.14
4
+ version: 2.2.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pepijn Van Eeckhoudt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-20 00:00:00.000000000 Z
11
+ date: 2024-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -211,7 +211,7 @@ files:
211
211
  - lib/asciidoctor-diagram/structurizr/converter.rb
212
212
  - lib/asciidoctor-diagram/structurizr/extension.rb
213
213
  - lib/asciidoctor-diagram/structurizr/renderers.rb
214
- - lib/asciidoctor-diagram/structurizr/structurizr-2.0.3.jar
214
+ - lib/asciidoctor-diagram/structurizr/structurizr-2.0.5.jar
215
215
  - lib/asciidoctor-diagram/svgbob.rb
216
216
  - lib/asciidoctor-diagram/svgbob/converter.rb
217
217
  - lib/asciidoctor-diagram/svgbob/extension.rb