asciidoctor-kroki 0.5.0 → 0.7.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
  SHA256:
3
- metadata.gz: b10096229def31407946a5f7e77eb57a991895d9407d334b6a4ca3dc7e8ba165
4
- data.tar.gz: 81497c2124169974c072a57c496b37d8cbd5e96b4793a22d59a3152fb1693c45
3
+ metadata.gz: 46f326afecfa57d4b918121fdf939c2c8dcf46897daeff74236a551628ffbfdf
4
+ data.tar.gz: c43629e9e6d4303fa59d761b61e95e6b63006cea1a27faf1dc3e80ceb9994f8c
5
5
  SHA512:
6
- metadata.gz: 03e1e7d5dc886c9e4ff9d7199f3289aa1a94d8b97a21209ba4ea9c4b505129646297bb62c02cab6390803b157a7a505e3af944ff533c49086af11927647776ce
7
- data.tar.gz: ad4cda7ce19c6ffa1223a224c1528c87e7b8864d554662f26a7534937f4bea49433e500373dad215feb09d71f748c84881ad720ea5c52765977383eb393a9f4c
6
+ metadata.gz: 70eac4468da00da494aa490e3c413189feb13474d25aa778f1d0cb301957c7ce1811bbc82cc7d1e2782a43223452f5b1de75a150b446824c2de7f9380811defc
7
+ data.tar.gz: e9d6cbbdc63c8f28dd99c1921f1496765ccbb873210756c765d879d1311994243af42f55f3d4dc18e0500be299ef89d5027bbccf5afefee24255d65c71e829d4
data/.rubocop.yml CHANGED
@@ -1,10 +1,15 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+ SuggestExtensions: false
4
+ NewCops: enable
5
+
1
6
  Style/Encoding:
2
7
  Enabled: false
3
8
 
4
9
  Layout/EndOfLine:
5
10
  EnforcedStyle: lf
6
11
 
7
- Metrics/LineLength:
12
+ Layout/LineLength:
8
13
  Max: 180
9
14
 
10
15
  Metrics/ClassLength:
@@ -20,7 +25,10 @@ Metrics/PerceivedComplexity:
20
25
  Max: 10
21
26
 
22
27
  Metrics/AbcSize:
23
- Max: 30
28
+ Max: 31
24
29
 
25
30
  Metrics/ParameterLists:
26
31
  Max: 7
32
+
33
+ Gemspec/RequiredRubyVersion:
34
+ Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.5
1
+ 3.1.2
data/Gemfile.lock CHANGED
@@ -1,52 +1,57 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- asciidoctor-kroki (0.5.0)
4
+ asciidoctor-kroki (0.7.0)
5
5
  asciidoctor (~> 2.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- asciidoctor (2.0.11)
11
- ast (2.4.1)
12
- diff-lcs (1.3)
13
- jaro_winkler (1.5.4)
14
- parallel (1.19.1)
15
- parser (2.7.1.3)
16
- ast (~> 2.4.0)
17
- rainbow (3.0.0)
18
- rake (12.3.3)
19
- rspec (3.8.0)
20
- rspec-core (~> 3.8.0)
21
- rspec-expectations (~> 3.8.0)
22
- rspec-mocks (~> 3.8.0)
23
- rspec-core (3.8.2)
24
- rspec-support (~> 3.8.0)
25
- rspec-expectations (3.8.6)
10
+ asciidoctor (2.0.17)
11
+ ast (2.4.2)
12
+ diff-lcs (1.4.4)
13
+ parallel (1.22.1)
14
+ parser (3.1.2.0)
15
+ ast (~> 2.4.1)
16
+ rainbow (3.1.1)
17
+ rake (13.0.6)
18
+ regexp_parser (2.5.0)
19
+ rexml (3.2.5)
20
+ rspec (3.10.0)
21
+ rspec-core (~> 3.10.0)
22
+ rspec-expectations (~> 3.10.0)
23
+ rspec-mocks (~> 3.10.0)
24
+ rspec-core (3.10.1)
25
+ rspec-support (~> 3.10.0)
26
+ rspec-expectations (3.10.1)
26
27
  diff-lcs (>= 1.2.0, < 2.0)
27
- rspec-support (~> 3.8.0)
28
- rspec-mocks (3.8.2)
28
+ rspec-support (~> 3.10.0)
29
+ rspec-mocks (3.10.2)
29
30
  diff-lcs (>= 1.2.0, < 2.0)
30
- rspec-support (~> 3.8.0)
31
- rspec-support (3.8.3)
32
- rubocop (0.74.0)
33
- jaro_winkler (~> 1.5.1)
31
+ rspec-support (~> 3.10.0)
32
+ rspec-support (3.10.2)
33
+ rubocop (1.30.0)
34
34
  parallel (~> 1.10)
35
- parser (>= 2.6)
35
+ parser (>= 3.1.0.0)
36
36
  rainbow (>= 2.2.2, < 4.0)
37
+ regexp_parser (>= 1.8, < 3.0)
38
+ rexml (>= 3.2.5, < 4.0)
39
+ rubocop-ast (>= 1.18.0, < 2.0)
37
40
  ruby-progressbar (~> 1.7)
38
- unicode-display_width (>= 1.4.0, < 1.7)
39
- ruby-progressbar (1.10.1)
40
- unicode-display_width (1.6.1)
41
+ unicode-display_width (>= 1.4.0, < 3.0)
42
+ rubocop-ast (1.18.0)
43
+ parser (>= 3.1.1.0)
44
+ ruby-progressbar (1.11.0)
45
+ unicode-display_width (2.1.0)
41
46
 
42
47
  PLATFORMS
43
48
  ruby
44
49
 
45
50
  DEPENDENCIES
46
51
  asciidoctor-kroki!
47
- rake (~> 12.3.2)
48
- rspec (~> 3.8.0)
49
- rubocop (~> 0.74.0)
52
+ rake (~> 13.0.6)
53
+ rspec (~> 3.10.0)
54
+ rubocop (~> 1.30)
50
55
 
51
56
  BUNDLED WITH
52
- 2.2.17
57
+ 2.3.15
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'lib/asciidoctor/extensions/asciidoctor_kroki/version'
4
+
3
5
  Gem::Specification.new do |s|
4
6
  s.name = 'asciidoctor-kroki'
5
- s.version = '0.5.0'
7
+ s.version = Asciidoctor::AsciidoctorKroki::VERSION
6
8
  s.summary = 'Asciidoctor extension to convert diagrams to images using Kroki'
7
9
  s.description = 'An extension for Asciidoctor to convert diagrams to images using https://kroki.io'
8
10
 
@@ -12,15 +14,15 @@ Gem::Specification.new do |s|
12
14
  s.license = 'MIT'
13
15
  s.metadata = {
14
16
  'bug_tracker_uri' => 'https://github.com/Mogztter/asciidoctor-kroki/issues',
15
- 'source_code_uri' => 'https://github.com/Mogztter/asciidoctor-kroki'
17
+ 'source_code_uri' => 'https://github.com/Mogztter/asciidoctor-kroki',
18
+ 'rubygems_mfa_required' => 'true'
16
19
  }
17
20
  s.files = `git ls-files`.split($RS)
18
- s.test_files = s.files.grep(%r{^(test|spec|features|tasks)/})
19
21
  s.require_paths = ['lib']
20
22
 
21
23
  s.add_runtime_dependency 'asciidoctor', '~> 2.0'
22
24
 
23
- s.add_development_dependency 'rake', '~> 12.3.2'
24
- s.add_development_dependency 'rspec', '~> 3.8.0'
25
- s.add_development_dependency 'rubocop', '~> 0.74.0'
25
+ s.add_development_dependency 'rake', '~> 13.0.6'
26
+ s.add_development_dependency 'rspec', '~> 3.10.0'
27
+ s.add_development_dependency 'rubocop', '~> 1.30'
26
28
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'cgi'
3
4
  require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
4
5
 
5
6
  # Asciidoctor extensions
@@ -38,6 +39,7 @@ module AsciidoctorExtensions
38
39
  # A block macro extension that converts a diagram into an image.
39
40
  #
40
41
  class KrokiBlockMacroProcessor < Asciidoctor::Extensions::BlockMacroProcessor
42
+ include Asciidoctor::Logging
41
43
  use_dsl
42
44
 
43
45
  name_positional_attributes 'format'
@@ -61,14 +63,14 @@ module AsciidoctorExtensions
61
63
  end
62
64
 
63
65
  unless (path = resolve_target_path(target))
64
- logger.error "#{diagram_type} block macro not found: #{target}."
65
- create_block(parent, 'paragraph', unresolved_block_macro_message(diagram_type, target), {})
66
+ logger.error message_with_context "#{diagram_type} block macro not found: #{target}.", source_location: parent.document.reader.cursor_at_mark
67
+ return create_block(parent, 'paragraph', unresolved_block_macro_message(diagram_type, target), {})
66
68
  end
67
69
 
68
70
  begin
69
71
  diagram_text = read(path)
70
- rescue => e # rubocop:disable RescueStandardError
71
- logger.error "Failed to read #{diagram_type} file: #{path}. #{e}."
72
+ rescue => e # rubocop:disable Style/RescueStandardError
73
+ logger.error message_with_context "Failed to read #{diagram_type} file: #{path}. #{e}.", source_location: parent.document.reader.cursor_at_mark
72
74
  return create_block(parent, 'paragraph', unresolved_block_macro_message(diagram_type, path), {})
73
75
  end
74
76
  KrokiProcessor.process(self, parent, attrs, diagram_type, diagram_text, @logger)
@@ -89,9 +91,9 @@ module AsciidoctorExtensions
89
91
  def read(target)
90
92
  if target.start_with?('http://') || target.start_with?('https://')
91
93
  require 'open-uri'
92
- URI.open(target, &:read)
94
+ ::OpenURI.open_uri(target, &:read)
93
95
  else
94
- File.open(target, &:read)
96
+ File.read(target, mode: 'rb:utf-8:utf-8')
95
97
  end
96
98
  end
97
99
 
@@ -126,15 +128,20 @@ module AsciidoctorExtensions
126
128
  vega
127
129
  vegalite
128
130
  wavedrom
131
+ structurizr
129
132
  ].freeze
130
133
  end
131
134
 
132
135
  # Internal processor
133
136
  #
134
137
  class KrokiProcessor
138
+ include Asciidoctor::Logging
139
+
135
140
  TEXT_FORMATS = %w[txt atxt utxt].freeze
141
+ BUILTIN_ATTRIBUTES = %w[target width height format fallback link float align role caption title cloaked-context subs].freeze
136
142
 
137
143
  class << self
144
+ # rubocop:disable Metrics/AbcSize
138
145
  def process(processor, parent, attrs, diagram_type, diagram_text, logger)
139
146
  doc = parent.document
140
147
  diagram_text = prepend_plantuml_config(diagram_text, diagram_type, doc, logger)
@@ -143,20 +150,27 @@ module AsciidoctorExtensions
143
150
  if (subs = attrs['subs'])
144
151
  diagram_text = parent.apply_subs(diagram_text, parent.resolve_subs(subs))
145
152
  end
146
- title = attrs.delete('title')
147
- caption = attrs.delete('caption')
148
153
  attrs.delete('opts')
149
- role = attrs['role']
150
154
  format = get_format(doc, attrs, diagram_type)
151
- attrs['role'] = get_role(format, role)
155
+ attrs['role'] = get_role(format, attrs['role'])
152
156
  attrs['format'] = format
153
- kroki_diagram = KrokiDiagram.new(diagram_type, format, diagram_text)
154
- kroki_client = KrokiClient.new(server_url(doc), http_method(doc), KrokiHttpClient, logger, max_uri_length(doc))
157
+ opts = attrs.filter { |key, _| key.is_a?(String) && BUILTIN_ATTRIBUTES.none? { |k| key == k } && !key.end_with?('-option') }
158
+ kroki_diagram = KrokiDiagram.new(diagram_type, format, diagram_text, attrs['target'], opts)
159
+ kroki_client = KrokiClient.new({
160
+ server_url: server_url(doc),
161
+ http_method: http_method(doc),
162
+ max_uri_length: max_uri_length(doc),
163
+ source_location: doc.reader.cursor_at_mark,
164
+ http_client: KrokiHttpClient
165
+ }, logger)
166
+ alt = get_alt(attrs)
167
+ title = attrs.delete('title')
168
+ caption = attrs.delete('caption')
155
169
  if TEXT_FORMATS.include?(format)
156
170
  text_content = kroki_client.text_content(kroki_diagram)
157
171
  block = processor.create_block(parent, 'literal', text_content, attrs)
158
172
  else
159
- attrs['alt'] = get_alt(attrs)
173
+ attrs['alt'] = alt
160
174
  attrs['target'] = create_image_src(doc, kroki_diagram, kroki_client)
161
175
  block = processor.create_image_block(parent, attrs)
162
176
  end
@@ -164,6 +178,7 @@ module AsciidoctorExtensions
164
178
  block.assign_caption(caption, 'figure')
165
179
  block
166
180
  end
181
+ # rubocop:enable Metrics/AbcSize
167
182
 
168
183
  private
169
184
 
@@ -174,9 +189,10 @@ module AsciidoctorExtensions
174
189
  plantuml_include_path = doc.normalize_system_path(doc.attr('kroki-plantuml-include'))
175
190
  if ::File.readable? plantuml_include_path
176
191
  config = File.read(plantuml_include_path)
177
- diagram_text = config + "\n" + diagram_text
192
+ diagram_text = "#{config}\n#{diagram_text}"
178
193
  else
179
- logger.warn "Unable to read plantuml-include. File not found or not readable: #{plantuml_include_path}."
194
+ logger.warn message_with_context "Unable to read plantuml-include. File not found or not readable: #{plantuml_include_path}.",
195
+ source_location: doc.reader.cursor_at_mark
180
196
  end
181
197
  end
182
198
  diagram_text
@@ -205,13 +221,13 @@ module AsciidoctorExtensions
205
221
  end
206
222
 
207
223
  def get_format(doc, attrs, diagram_type)
208
- format = attrs['format'] || 'svg'
209
- # The JavaFX preview doesn't support SVG well, therefore we'll use PNG format...
210
- if doc.attr?('env-idea') && format == 'svg'
211
- # ... unless the diagram library does not support PNG as output format!
212
- # Currently, mermaid, nomnoml, svgbob, wavedrom only support SVG as output format.
213
- svg_only_diagram_types = %w[:mermaid :nomnoml :svgbob :wavedrom]
214
- format = 'png' unless svg_only_diagram_types.include?(diagram_type)
224
+ format = attrs['format'] || doc.attr('kroki-default-format') || 'svg'
225
+ if format == 'png'
226
+ # redirect PNG format to SVG if the diagram library only supports SVG as output format.
227
+ # this is useful when the default format has been set to PNG
228
+ # Currently, nomnoml, svgbob, wavedrom only support SVG as output format.
229
+ svg_only_diagram_types = %i[nomnoml svgbob wavedrom]
230
+ format = 'svg' if svg_only_diagram_types.include?(diagram_type)
215
231
  end
216
232
  format
217
233
  end
@@ -240,10 +256,9 @@ module AsciidoctorExtensions
240
256
  images_dir = doc.attr('imagesdir', '')
241
257
  if (images_output_dir = doc.attr('imagesoutdir'))
242
258
  images_output_dir
243
- elsif (out_dir = doc.attr('outdir'))
259
+ # the nested document logic will become obsolete once https://github.com/asciidoctor/asciidoctor/commit/7edc9da023522be67b17e2a085d72e056703a438 is released
260
+ elsif (out_dir = doc.attr('outdir') || (doc.nested? ? doc.parent_document : doc).options[:to_dir])
244
261
  File.join(out_dir, images_dir)
245
- elsif (to_dir = doc.attr('to_dir'))
246
- File.join(to_dir, images_dir)
247
262
  else
248
263
  File.join(doc.base_dir, images_dir)
249
264
  end
@@ -258,18 +273,19 @@ module AsciidoctorExtensions
258
273
  require 'zlib'
259
274
  require 'digest'
260
275
 
261
- attr_reader :type
262
- attr_reader :text
263
- attr_reader :format
276
+ attr_reader :type, :text, :format, :target, :opts
264
277
 
265
- def initialize(type, format, text)
278
+ def initialize(type, format, text, target = nil, opts = {})
266
279
  @text = text
267
280
  @type = type
268
281
  @format = format
282
+ @target = target
283
+ @opts = opts
269
284
  end
270
285
 
271
286
  def get_diagram_uri(server_url)
272
- _join_uri_segments(server_url, @type, @format, encode)
287
+ query_params = opts.map { |k, v| "#{k}=#{_url_encode(v.to_s)}" }.join('&') unless opts.empty?
288
+ _join_uri_segments(server_url, @type, @format, encode) + (query_params ? "?#{query_params}" : '')
273
289
  end
274
290
 
275
291
  def encode
@@ -278,37 +294,39 @@ module AsciidoctorExtensions
278
294
 
279
295
  def save(output_dir_path, kroki_client)
280
296
  diagram_url = get_diagram_uri(kroki_client.server_url)
281
- diagram_name = "diag-#{Digest::SHA256.hexdigest diagram_url}.#{@format}"
297
+ diagram_name = "#{@target || 'diag'}-#{Digest::SHA256.hexdigest diagram_url}.#{@format}"
282
298
  file_path = File.join(output_dir_path, diagram_name)
283
- encoding = if @format == 'txt' || @format == 'atxt' || @format == 'utxt'
299
+ encoding = case @format
300
+ when 'txt', 'atxt', 'utxt', 'svg'
284
301
  'utf8'
285
- elsif @format == 'svg'
286
- 'binary'
287
302
  else
288
303
  'binary'
289
304
  end
290
305
  # file is either (already) on the file system or we should read it from Kroki
291
- contents = File.exist?(file_path) ? File.open(file_path, &:read) : kroki_client.get_image(self, encoding)
292
- FileUtils.mkdir_p(output_dir_path)
293
- if encoding == 'binary'
294
- File.binwrite(file_path, contents)
295
- else
296
- File.write(file_path, contents)
306
+ unless File.exist?(file_path)
307
+ contents = kroki_client.get_image(self, encoding)
308
+ FileUtils.mkdir_p(output_dir_path)
309
+ File.write(file_path, contents, mode: 'wb')
297
310
  end
311
+
298
312
  diagram_name
299
313
  end
300
314
 
301
315
  private
302
316
 
317
+ def _url_encode(text)
318
+ CGI.escape(text).gsub(/\+/, '%20')
319
+ end
320
+
303
321
  def _join_uri_segments(base, *uris)
304
322
  segments = []
305
323
  # remove trailing slashes
306
- segments.push(base.gsub(%r{[/]+$}, ''))
324
+ segments.push(base.gsub(%r{/+$}, ''))
307
325
  segments.concat(uris.map do |uri|
308
326
  # remove leading and trailing slashes
309
327
  uri.to_s
310
- .gsub(%r{^[/]+}, '')
311
- .gsub(%r{[/]+$}, '')
328
+ .gsub(%r{^/+}, '')
329
+ .gsub(%r{/+$}, '')
312
330
  end)
313
331
  segments.join('/')
314
332
  end
@@ -317,21 +335,23 @@ module AsciidoctorExtensions
317
335
  # Kroki client
318
336
  #
319
337
  class KrokiClient
320
- attr_reader :server_url
321
- attr_reader :method
322
- attr_reader :max_uri_length
338
+ include Asciidoctor::Logging
339
+
340
+ attr_reader :server_url, :method, :max_uri_length
323
341
 
324
342
  SUPPORTED_HTTP_METHODS = %w[get post adaptive].freeze
325
343
 
326
- def initialize(server_url, http_method, http_client, logger = ::Asciidoctor::LoggerManager.logger, max_uri_length = 4000)
327
- @server_url = server_url
328
- @max_uri_length = max_uri_length
329
- @http_client = http_client
330
- method = (http_method || 'adaptive').downcase
344
+ def initialize(opts, logger = ::Asciidoctor::LoggerManager.logger)
345
+ @server_url = opts[:server_url]
346
+ @max_uri_length = opts.fetch(:max_uri_length, 4000)
347
+ @http_client = opts[:http_client]
348
+ method = opts.fetch(:http_method, 'adaptive').downcase
331
349
  if SUPPORTED_HTTP_METHODS.include?(method)
332
350
  @method = method
333
351
  else
334
- logger.warn "Invalid value '#{method}' for kroki-http-method attribute. The value must be either: 'get', 'post' or 'adaptive'. Proceeding using: 'adaptive'."
352
+ logger.warn message_with_context "Invalid value '#{method}' for kroki-http-method attribute. The value must be either: " \
353
+ "'get', 'post' or 'adaptive'. Proceeding using: 'adaptive'.",
354
+ source_location: opts[:source_location]
335
355
  @method = 'adaptive'
336
356
  end
337
357
  end
@@ -344,6 +364,7 @@ module AsciidoctorExtensions
344
364
  type = kroki_diagram.type
345
365
  format = kroki_diagram.format
346
366
  text = kroki_diagram.text
367
+ opts = kroki_diagram.opts
347
368
  if @method == 'adaptive' || @method == 'get'
348
369
  uri = kroki_diagram.get_diagram_uri(server_url)
349
370
  if uri.length > @max_uri_length
@@ -351,15 +372,15 @@ module AsciidoctorExtensions
351
372
  if @method == 'get'
352
373
  # The request might be rejected by the server with a 414 Request-URI Too Large.
353
374
  # Consider using the attribute kroki-http-method with the value 'adaptive'.
354
- @http_client.get(uri, encoding)
375
+ @http_client.get(uri, opts, encoding)
355
376
  else
356
- @http_client.post("#{@server_url}/#{type}/#{format}", text, encoding)
377
+ @http_client.post("#{@server_url}/#{type}/#{format}", text, opts, encoding)
357
378
  end
358
379
  else
359
- @http_client.get(uri, encoding)
380
+ @http_client.get(uri, opts, encoding)
360
381
  end
361
382
  else
362
- @http_client.post("#{@server_url}/#{type}/#{format}", text, encoding)
383
+ @http_client.post("#{@server_url}/#{type}/#{format}", text, opts, encoding)
363
384
  end
364
385
  end
365
386
  end
@@ -372,12 +393,33 @@ module AsciidoctorExtensions
372
393
  require 'json'
373
394
 
374
395
  class << self
375
- def get(uri, _)
376
- ::OpenURI.open_uri(uri, 'r', &:read)
396
+ REFERER = "asciidoctor/kroki.rb/#{Asciidoctor::AsciidoctorKroki::VERSION}"
397
+
398
+ def get(uri, opts, _)
399
+ uri = URI(uri)
400
+ headers = opts.transform_keys { |key| "Kroki-Diagram-Options-#{key}" }
401
+ .merge({ 'referer' => REFERER })
402
+ request = ::Net::HTTP::Get.new(uri, headers)
403
+ ::Net::HTTP.start(
404
+ uri.hostname,
405
+ uri.port,
406
+ use_ssl: (uri.scheme == 'https')
407
+ ) do |http|
408
+ http.request(request).body
409
+ end
377
410
  end
378
411
 
379
- def post(uri, data, _)
380
- res = ::Net::HTTP.request_post(uri, data)
412
+ def post(uri, data, opts, _)
413
+ headers = opts.transform_keys { |key| "Kroki-Diagram-Options-#{key}" }
414
+ .merge({
415
+ 'Content-Type' => 'text/plain',
416
+ 'referer' => REFERER
417
+ })
418
+ res = ::Net::HTTP.post(
419
+ URI(uri),
420
+ data,
421
+ headers
422
+ )
381
423
  res.body
382
424
  end
383
425
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Asciidoctor
4
+ module AsciidoctorKroki
5
+ VERSION = '0.7.0'
6
+ end
7
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
4
+ require_relative 'asciidoctor_kroki/version'
4
5
  require_relative 'asciidoctor_kroki/extension'
5
6
 
6
7
  Asciidoctor::Extensions.register do
@@ -1,3 +1,4 @@
1
+ # rubocop:disable Lint/ConstantDefinitionInBlock
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require 'rspec_helper'
@@ -88,7 +89,7 @@ describe ::AsciidoctorExtensions::KrokiBlockMacroProcessor do
88
89
  </div>
89
90
  </div>)
90
91
  end
91
- it 'should display unresolved block macro message when the traget cannot be resolved' do
92
+ it 'should display unresolved block macro message when the target cannot be resolved' do
92
93
  # noinspection RubyClassModuleNamingConvention
93
94
  class UnresolvedTargetKrokiBlockMacroProcessor < ::AsciidoctorExtensions::KrokiBlockMacroProcessor
94
95
  def resolve_target_path(_target)
@@ -103,7 +104,7 @@ describe ::AsciidoctorExtensions::KrokiBlockMacroProcessor do
103
104
  ADOC
104
105
  output = Asciidoctor.convert(input, standalone: false, extension_registry: registry)
105
106
  (expect output).to eql %(<div class="paragraph">
106
- <p>Unresolved block macro - plantuml::[]</p>
107
+ <p>Unresolved block macro - plantuml::alice.puml[]</p>
107
108
  </div>)
108
109
  end
109
110
  it 'should override the unresolved block macro message' do
@@ -126,3 +127,4 @@ describe ::AsciidoctorExtensions::KrokiBlockMacroProcessor do
126
127
  end
127
128
  end
128
129
  end
130
+ # rubocop:enable Lint/ConstantDefinitionInBlock
@@ -7,27 +7,27 @@ require_relative '../lib/asciidoctor/extensions/asciidoctor_kroki'
7
7
  describe ::AsciidoctorExtensions::KrokiClient do
8
8
  it 'should use adaptive method when http method is invalid' do
9
9
  kroki_http_client = ::AsciidoctorExtensions::KrokiHttpClient
10
- kroki_client = ::AsciidoctorExtensions::KrokiClient.new('http://localhost:8000', 'patch', kroki_http_client)
10
+ kroki_client = ::AsciidoctorExtensions::KrokiClient.new(server_url: 'http://localhost:8000', http_method: 'patch', http_client: kroki_http_client)
11
11
  expect(kroki_client.method).to eq('adaptive')
12
12
  end
13
13
  it 'should use post method when http method is post' do
14
14
  kroki_http_client = ::AsciidoctorExtensions::KrokiHttpClient
15
- kroki_client = ::AsciidoctorExtensions::KrokiClient.new('http://localhost:8000', 'POST', kroki_http_client)
15
+ kroki_client = ::AsciidoctorExtensions::KrokiClient.new(server_url: 'http://localhost:8000', http_method: 'POST', http_client: kroki_http_client)
16
16
  expect(kroki_client.method).to eq('post')
17
17
  end
18
18
  it 'should use get method when http method is get' do
19
19
  kroki_http_client = ::AsciidoctorExtensions::KrokiHttpClient
20
- kroki_client = ::AsciidoctorExtensions::KrokiClient.new('http://localhost:8000', 'get', kroki_http_client)
20
+ kroki_client = ::AsciidoctorExtensions::KrokiClient.new(server_url: 'http://localhost:8000', http_method: 'get', http_client: kroki_http_client)
21
21
  expect(kroki_client.method).to eq('get')
22
22
  end
23
23
  it 'should use 4000 as the default max URI length' do
24
24
  kroki_http_client = ::AsciidoctorExtensions::KrokiHttpClient
25
- kroki_client = ::AsciidoctorExtensions::KrokiClient.new('http://localhost:8000', 'get', kroki_http_client)
25
+ kroki_client = ::AsciidoctorExtensions::KrokiClient.new(server_url: 'http://localhost:8000', http_method: 'get', http_client: kroki_http_client)
26
26
  expect(kroki_client.max_uri_length).to eq(4000)
27
27
  end
28
28
  it 'should use a custom value as max URI length' do
29
29
  kroki_http_client = ::AsciidoctorExtensions::KrokiHttpClient
30
- kroki_client = ::AsciidoctorExtensions::KrokiClient.new('http://localhost:8000', 'get', kroki_http_client, nil, 8000)
30
+ kroki_client = ::AsciidoctorExtensions::KrokiClient.new(server_url: 'http://localhost:8000', http_method: 'get', http_client: kroki_http_client, max_uri_length: 8000)
31
31
  expect(kroki_client.max_uri_length).to eq(8000)
32
32
  end
33
33
  it 'should get an image with POST request if the URI length is greater than the value configured' do
@@ -37,54 +37,56 @@ describe ::AsciidoctorExtensions::KrokiClient do
37
37
  "GET #{uri}"
38
38
  end
39
39
 
40
- def post(uri, data, _)
40
+ def post(uri, data, _, _)
41
41
  "POST #{uri} - #{data}"
42
42
  end
43
43
  end
44
44
  end
45
45
  kroki_diagram = Class.new do
46
- attr_reader :type, :text, :format
46
+ attr_reader :type, :text, :format, :opts
47
47
 
48
- def initialize(type, format, text)
48
+ def initialize(type, format, text, opts = {})
49
49
  @text = text
50
50
  @type = type
51
51
  @format = format
52
+ @opts = opts
52
53
  end
53
54
 
54
55
  def get_diagram_uri(_)
55
56
  'diagram-uri'
56
57
  end
57
58
  end.new('type', 'format', 'text')
58
- kroki_client = ::AsciidoctorExtensions::KrokiClient.new('http://localhost:8000', 'adaptive', kroki_http_client, nil, 10)
59
+ kroki_client = ::AsciidoctorExtensions::KrokiClient.new(server_url: 'http://localhost:8000', http_method: 'adaptive', http_client: kroki_http_client, max_uri_length: 10)
59
60
  result = kroki_client.get_image(kroki_diagram, 'utf8')
60
61
  expect(result).to eq('POST http://localhost:8000/type/format - text')
61
62
  end
62
63
  it 'should get an image with GET request if the URI length is lower or equals than the value configured' do
63
64
  kroki_http_client = Class.new do
64
65
  class << self
65
- def get(uri, _)
66
+ def get(uri, _, _)
66
67
  "GET #{uri}"
67
68
  end
68
69
 
69
- def post(uri, data, _)
70
+ def post(uri, data, _, _)
70
71
  "POST #{uri} - #{data}"
71
72
  end
72
73
  end
73
74
  end
74
75
  kroki_diagram = Class.new do
75
- attr_reader :type, :text, :format
76
+ attr_reader :type, :text, :format, :opts
76
77
 
77
- def initialize(type, format, text)
78
+ def initialize(type, format, text, opts = {})
78
79
  @text = text
79
80
  @type = type
80
81
  @format = format
82
+ @opts = opts
81
83
  end
82
84
 
83
85
  def get_diagram_uri(_)
84
86
  'diagram-uri'
85
87
  end
86
88
  end.new('type', 'format', 'text')
87
- kroki_client = ::AsciidoctorExtensions::KrokiClient.new('http://localhost:8000', 'adaptive', kroki_http_client, nil, 11)
89
+ kroki_client = ::AsciidoctorExtensions::KrokiClient.new(server_url: 'http://localhost:8000', http_method: 'adaptive', http_client: kroki_http_client, max_uri_length: 11)
88
90
  result = kroki_client.get_image(kroki_diagram, 'utf8')
89
91
  expect(result).to eq('GET diagram-uri')
90
92
  end
@@ -20,6 +20,24 @@ describe ::AsciidoctorExtensions::KrokiDiagram do
20
20
  diagram_uri = kroki_diagram.get_diagram_uri('https://my-server/kroki//')
21
21
  expect(diagram_uri).to eq('https://my-server/kroki/vegalite/png/eNqrrgUAAXUA-Q==')
22
22
  end
23
+ it 'should compute a diagram URI with query parameters' do
24
+ text = %q{
25
+ .---.
26
+ /-o-/--
27
+ .-/ / /->
28
+ ( * \/
29
+ '-. \
30
+ \ /
31
+ '
32
+ }
33
+ opts = {
34
+ 'stroke-width' => 1,
35
+ 'background' => 'black'
36
+ }
37
+ kroki_diagram = ::AsciidoctorExtensions::KrokiDiagram.new('svgbob', 'png', text, nil, opts)
38
+ diagram_uri = kroki_diagram.get_diagram_uri('http://localhost:8000')
39
+ expect(diagram_uri).to eq('http://localhost:8000/svgbob/png/eNrjUoAAPV1dXT0uCFtfN19XX1eXCyysrwCEunZAjoaCloJCjD5IWF1XD8gEK49R0IdoUwdTAN3kC7U=?stroke-width=1&background=black')
40
+ end
23
41
  it 'should encode a diagram text definition' do
24
42
  kroki_diagram = ::AsciidoctorExtensions::KrokiDiagram.new('plantuml', 'txt', ' alice -> bob: hello')
25
43
  diagram_definition_encoded = kroki_diagram.encode
@@ -28,11 +46,32 @@ describe ::AsciidoctorExtensions::KrokiDiagram do
28
46
  it 'should fetch a diagram from Kroki and save it to disk' do
29
47
  kroki_diagram = ::AsciidoctorExtensions::KrokiDiagram.new('plantuml', 'txt', ' alice -> bob: hello')
30
48
  kroki_http_client = ::AsciidoctorExtensions::KrokiHttpClient
31
- kroki_client = ::AsciidoctorExtensions::KrokiClient.new('https://kroki.io', 'get', kroki_http_client)
49
+ kroki_client = ::AsciidoctorExtensions::KrokiClient.new(server_url: 'https://kroki.io', http_method: 'get', http_client: kroki_http_client)
50
+ output_dir_path = "#{__dir__}/../.asciidoctor/kroki"
51
+ diagram_name = kroki_diagram.save(output_dir_path, kroki_client)
52
+ diagram_path = File.join(output_dir_path, diagram_name)
53
+ expect(File.exist?(diagram_path)).to be_truthy, "diagram should be saved at: #{diagram_path}"
54
+ content = <<-TXT.chomp
55
+ ,-----. ,---.
56
+ |alice| |bob|
57
+ `--+--' `-+-'
58
+ | hello |
59
+ |-------------->|
60
+ ,--+--. ,-+-.
61
+ |alice| |bob|
62
+ `-----' `---'
63
+ TXT
64
+ expect(File.read(diagram_path).split("\n").map(&:rstrip).join("\n")).to eq(content)
65
+ end
66
+ it 'should fetch a diagram from Kroki and save it to disk using the target name' do
67
+ kroki_diagram = ::AsciidoctorExtensions::KrokiDiagram.new('plantuml', 'txt', ' alice -> bob: hello', 'hello-world')
68
+ kroki_http_client = ::AsciidoctorExtensions::KrokiHttpClient
69
+ kroki_client = ::AsciidoctorExtensions::KrokiClient.new(server_url: 'https://kroki.io', http_method: 'get', http_client: kroki_http_client)
32
70
  output_dir_path = "#{__dir__}/../.asciidoctor/kroki"
33
71
  diagram_name = kroki_diagram.save(output_dir_path, kroki_client)
34
72
  diagram_path = File.join(output_dir_path, diagram_name)
35
- expect(File.exist?(diagram_path)).to be_truthy, "expected diagram to be saved at #{diagram_path}"
73
+ expect(diagram_name).to start_with('hello-world-'), "diagram name should use the target as a prefix, got: #{diagram_name}"
74
+ expect(File.exist?(diagram_path)).to be_truthy, "diagram should be saved at: #{diagram_path}"
36
75
  content = <<-TXT.chomp
37
76
  ,-----. ,---.
38
77
  |alice| |bob|
@@ -48,14 +87,16 @@ describe ::AsciidoctorExtensions::KrokiDiagram do
48
87
  it 'should fetch a diagram from Kroki with the same definition only once' do
49
88
  kroki_diagram = ::AsciidoctorExtensions::KrokiDiagram.new('plantuml', 'png', ' guillaume -> dan: hello')
50
89
  kroki_http_client = ::AsciidoctorExtensions::KrokiHttpClient
51
- kroki_client = ::AsciidoctorExtensions::KrokiClient.new('https://kroki.io', 'get', kroki_http_client)
90
+ kroki_client = ::AsciidoctorExtensions::KrokiClient.new(server_url: 'https://kroki.io', http_method: 'get', http_client: kroki_http_client)
52
91
  output_dir_path = "#{__dir__}/../.asciidoctor/kroki"
53
92
  # make sure that we are doing only one GET request
54
- expect(kroki_http_client).to receive(:get).once
93
+ diagram_contents = File.read("#{__dir__}/fixtures/plantuml-diagram.png", mode: 'rb')
94
+ expect(kroki_http_client).to receive(:get).once.and_return(diagram_contents)
55
95
  diagram_name = kroki_diagram.save(output_dir_path, kroki_client)
56
96
  diagram_path = File.join(output_dir_path, diagram_name)
57
- expect(File.exist?(diagram_path)).to be_truthy, "expected diagram to be saved at #{diagram_path}"
97
+ expect(File.exist?(diagram_path)).to be_truthy, "diagram should be saved at: #{diagram_path}"
58
98
  # calling again... should read the file from disk (and not do a GET request)
59
99
  kroki_diagram.save(output_dir_path, kroki_client)
100
+ expect(File.size(diagram_path)).to be_eql(diagram_contents.length), 'diagram should be fully saved on disk'
60
101
  end
61
102
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rspec_helper'
4
+ require 'asciidoctor'
5
+ require_relative '../lib/asciidoctor/extensions/asciidoctor_kroki'
6
+
7
+ describe '::AsciidoctorExtensions::KrokiProcessor' do
8
+ it 'should return the images output directory (imagesoutdir attribute)' do
9
+ doc = Asciidoctor.load('hello', attributes: { 'imagesoutdir' => '.asciidoctor/kroki/images', 'imagesdir' => '../images' })
10
+ output_dir_path = AsciidoctorExtensions::KrokiProcessor.send(:output_dir_path, doc)
11
+ expect(output_dir_path).to eq '.asciidoctor/kroki/images'
12
+ end
13
+ it 'should return a path relative to output directory (to_dir option)' do
14
+ doc = Asciidoctor.load('hello', to_dir: '.asciidoctor/kroki/relative', attributes: { 'imagesdir' => '../images' })
15
+ output_dir_path = AsciidoctorExtensions::KrokiProcessor.send(:output_dir_path, doc)
16
+ expect(output_dir_path).to eq '.asciidoctor/kroki/relative/../images'
17
+ end
18
+ it 'should return a path relative to output directory (outdir attribute)' do
19
+ doc = Asciidoctor.load('hello', attributes: { 'imagesdir' => 'resources/images', 'outdir' => '.asciidoctor/kroki/out' })
20
+ output_dir_path = AsciidoctorExtensions::KrokiProcessor.send(:output_dir_path, doc)
21
+ expect(output_dir_path).to eq '.asciidoctor/kroki/out/resources/images'
22
+ end
23
+ it 'should return a path relative to the base directory (base_dir option)' do
24
+ doc = Asciidoctor.load('hello', base_dir: '.asciidoctor/kroki', attributes: { 'imagesdir' => 'img' })
25
+ output_dir_path = AsciidoctorExtensions::KrokiProcessor.send(:output_dir_path, doc)
26
+ expect(output_dir_path).to eq "#{::Dir.pwd}/.asciidoctor/kroki/img"
27
+ end
28
+ it 'should return a path relative to the base directory (default value is current working directory)' do
29
+ doc = Asciidoctor.load('hello', attributes: { 'imagesdir' => 'img' })
30
+ output_dir_path = AsciidoctorExtensions::KrokiProcessor.send(:output_dir_path, doc)
31
+ expect(output_dir_path).to eq "#{::Dir.pwd}/img"
32
+ end
33
+ end
@@ -20,18 +20,64 @@ describe ::AsciidoctorExtensions::KrokiBlockProcessor do
20
20
  </div>
21
21
  </div>)
22
22
  end
23
- it 'should use png if env-idea is defined' do
23
+ it 'should only pass diagram options as query parameters' do
24
+ input = <<~'ADOC'
25
+ [plantuml,alice-bob,svg,role=sequence,width=100,format=svg,link=https://asciidoc.org/,align=center,float=right,theme=bluegray]
26
+ ....
27
+ alice -> bob: hello
28
+ ....
29
+ ADOC
30
+ output = Asciidoctor.convert(input, standalone: false)
31
+ (expect output).to eql %(<div class="imageblock right text-center sequence kroki-format-svg kroki">
32
+ <div class="content">
33
+ <a class="image" href="https://asciidoc.org/"><img src="https://kroki.io/plantuml/svg/eNpLzMlMTlXQtVNIyk-yUshIzcnJBwA9iwZL?theme=bluegray" alt="alice-bob" width="100"></a>
34
+ </div>
35
+ </div>)
36
+ end
37
+ it 'should use the title attribute as the alt value' do
38
+ input = <<~'ADOC'
39
+ [plantuml,title="Alice saying hello to Bob"]
40
+ ....
41
+ alice -> bob: hello
42
+ ....
43
+ ADOC
44
+ output = Asciidoctor.convert(input, standalone: false)
45
+ (expect output).to eql %(<div class="imageblock kroki">
46
+ <div class="content">
47
+ <img src="https://kroki.io/plantuml/svg/eNpLzMlMTlXQtVNIyk-yUshIzcnJBwA9iwZL" alt="Alice saying hello to Bob">
48
+ </div>
49
+ <div class="title">Figure 1. Alice saying hello to Bob</div>
50
+ </div>)
51
+ end
52
+ it 'should use png if kroki-default-format is set to png' do
24
53
  input = <<~'ADOC'
25
54
  [plantuml]
26
55
  ....
27
56
  alice -> bob: hello
28
57
  ....
29
58
  ADOC
30
- output = Asciidoctor.convert(input, attributes: { 'env-idea' => '' }, standalone: false)
59
+ output = Asciidoctor.convert(input, attributes: { 'kroki-default-format' => 'png' }, standalone: false)
31
60
  (expect output).to eql %(<div class="imageblock kroki">
32
61
  <div class="content">
33
62
  <img src="https://kroki.io/plantuml/png/eNpLzMlMTlXQtVNIyk-yUshIzcnJBwA9iwZL" alt="Diagram">
34
63
  </div>
64
+ </div>)
65
+ end
66
+ it 'should use svg if kroki-default-format is set to png and the diagram type does not support png' do
67
+ input = <<~'ADOC'
68
+ [nomnoml]
69
+ ....
70
+ [Pirate|eyeCount: Int|raid();pillage()|
71
+ [beard]--[parrot]
72
+ [beard]-:>[foul mouth]
73
+ ]
74
+ ....
75
+ ADOC
76
+ output = Asciidoctor.convert(input, attributes: { 'kroki-default-format' => 'png' }, standalone: false)
77
+ (expect output).to eql %(<div class="imageblock kroki">
78
+ <div class="content">
79
+ <img src="https://kroki.io/nomnoml/svg/eNqLDsgsSixJrUmtTHXOL80rsVLwzCupKUrMTNHQtC7IzMlJTE_V0KzhUlCITkpNLEqJ1dWNLkgsKsoviUUSs7KLTssvzVHIzS8tyYjligUAMhEd0g==" alt="Diagram">
80
+ </div>
35
81
  </div>)
36
82
  end
37
83
  it 'should include the plantuml-include file when safe mode is safe' do
@@ -41,10 +87,12 @@ describe ::AsciidoctorExtensions::KrokiBlockProcessor do
41
87
  alice -> bob: hello
42
88
  ....
43
89
  ADOC
44
- output = Asciidoctor.convert(input, attributes: { 'env-idea' => '', 'kroki-plantuml-include' => 'spec/fixtures/config.puml' }, standalone: false, safe: :safe)
90
+ output = Asciidoctor.convert(input,
91
+ attributes: { 'kroki-plantuml-include' => 'spec/fixtures/config.puml' },
92
+ standalone: false, safe: :safe)
45
93
  (expect output).to eql %(<div class="imageblock kroki">
46
94
  <div class="content">
47
- <img src="https://kroki.io/plantuml/png/eNorzs7MK0gsSsxVyM3Py0_OKMrPTVUoKSpN5eJKzMlMTlXQtVNIyk-yUshIzcnJBwCT9xBc" alt="Diagram">
95
+ <img src="https://kroki.io/plantuml/svg/eNorzs7MK0gsSsxVyM3Py0_OKMrPTVUoKSpN5eJKzMlMTlXQtVNIyk-yUshIzcnJBwCT9xBc" alt="Diagram">
48
96
  </div>
49
97
  </div>)
50
98
  end
@@ -55,10 +103,10 @@ describe ::AsciidoctorExtensions::KrokiBlockProcessor do
55
103
  alice -> bob: hello
56
104
  ....
57
105
  ADOC
58
- output = Asciidoctor.convert(input, attributes: { 'env-idea' => '', 'kroki-plantuml-include' => '../../../spec/fixtures/config.puml' }, standalone: false, safe: :safe)
106
+ output = Asciidoctor.convert(input, attributes: { 'kroki-plantuml-include' => '../../../spec/fixtures/config.puml' }, standalone: false, safe: :safe)
59
107
  (expect output).to eql %(<div class="imageblock kroki">
60
108
  <div class="content">
61
- <img src="https://kroki.io/plantuml/png/eNorzs7MK0gsSsxVyM3Py0_OKMrPTVUoKSpN5eJKzMlMTlXQtVNIyk-yUshIzcnJBwCT9xBc" alt="Diagram">
109
+ <img src="https://kroki.io/plantuml/svg/eNorzs7MK0gsSsxVyM3Py0_OKMrPTVUoKSpN5eJKzMlMTlXQtVNIyk-yUshIzcnJBwCT9xBc" alt="Diagram">
62
110
  </div>
63
111
  </div>)
64
112
  end
@@ -69,10 +117,10 @@ describe ::AsciidoctorExtensions::KrokiBlockProcessor do
69
117
  alice -> bob: hello
70
118
  ....
71
119
  ADOC
72
- output = Asciidoctor.convert(input, attributes: { 'env-idea' => '', 'kroki-plantuml-include' => '/etc/passwd' }, standalone: false, safe: :safe)
120
+ output = Asciidoctor.convert(input, attributes: { 'kroki-plantuml-include' => '/etc/passwd' }, standalone: false, safe: :safe)
73
121
  (expect output).to eql %(<div class="imageblock kroki">
74
122
  <div class="content">
75
- <img src="https://kroki.io/plantuml/png/eNpLzMlMTlXQtVNIyk-yUshIzcnJBwA9iwZL" alt="Diagram">
123
+ <img src="https://kroki.io/plantuml/svg/eNpLzMlMTlXQtVNIyk-yUshIzcnJBwA9iwZL" alt="Diagram">
76
124
  </div>
77
125
  </div>)
78
126
  end
@@ -83,10 +131,10 @@ describe ::AsciidoctorExtensions::KrokiBlockProcessor do
83
131
  alice -> bob: hello
84
132
  ....
85
133
  ADOC
86
- output = Asciidoctor.convert(input, attributes: { 'env-idea' => '', 'kroki-plantuml-include' => 'spec/fixtures/config.puml' }, standalone: false, safe: :secure)
134
+ output = Asciidoctor.convert(input, attributes: { 'kroki-plantuml-include' => 'spec/fixtures/config.puml' }, standalone: false, safe: :secure)
87
135
  (expect output).to eql %(<div class="imageblock kroki">
88
136
  <div class="content">
89
- <img src="https://kroki.io/plantuml/png/eNpLzMlMTlXQtVNIyk-yUshIzcnJBwA9iwZL" alt="Diagram">
137
+ <img src="https://kroki.io/plantuml/svg/eNpLzMlMTlXQtVNIyk-yUshIzcnJBwA9iwZL" alt="Diagram">
90
138
  </div>
91
139
  </div>)
92
140
  end
@@ -134,7 +182,7 @@ describe ::AsciidoctorExtensions::KrokiBlockProcessor do
134
182
  it 'should instantiate block processor without warning' do
135
183
  original_stderr = $stderr
136
184
  $stderr = StringIO.new
137
- ::AsciidoctorExtensions::KrokiBlockProcessor.new 'plantuml'.to_sym, {}
185
+ ::AsciidoctorExtensions::KrokiBlockProcessor.new :plantuml, {}
138
186
  output = $stderr.string
139
187
  (expect output).to eql ''
140
188
  ensure
@@ -146,7 +194,7 @@ end
146
194
  describe ::AsciidoctorExtensions::Kroki do
147
195
  it 'should return the list of supported diagrams' do
148
196
  diagram_names = ::AsciidoctorExtensions::Kroki::SUPPORTED_DIAGRAM_NAMES
149
- expect(diagram_names).to include('vegalite', 'plantuml', 'bytefield', 'bpmn', 'excalidraw', 'wavedrom', 'pikchr')
197
+ expect(diagram_names).to include('vegalite', 'plantuml', 'bytefield', 'bpmn', 'excalidraw', 'wavedrom', 'pikchr', 'structurizr')
150
198
  end
151
199
  it 'should register the extension for the list of supported diagrams' do
152
200
  doc = Asciidoctor::Document.new
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-kroki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Grossetie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-05 00:00:00.000000000 Z
11
+ date: 2022-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -30,42 +30,42 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 12.3.2
33
+ version: 13.0.6
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 12.3.2
40
+ version: 13.0.6
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 3.8.0
47
+ version: 3.10.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 3.8.0
54
+ version: 3.10.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.74.0
61
+ version: '1.30'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.74.0
68
+ version: '1.30'
69
69
  description: An extension for Asciidoctor to convert diagrams to images using https://kroki.io
70
70
  email:
71
71
  - ggrossetie@yuzutech.fr
@@ -84,13 +84,16 @@ files:
84
84
  - lib/asciidoctor-kroki.rb
85
85
  - lib/asciidoctor/extensions/asciidoctor_kroki.rb
86
86
  - lib/asciidoctor/extensions/asciidoctor_kroki/extension.rb
87
+ - lib/asciidoctor/extensions/asciidoctor_kroki/version.rb
87
88
  - spec/.rubocop.yml
88
89
  - spec/asciidoctor_kroki_block_macro_spec.rb
89
90
  - spec/asciidoctor_kroki_client_spec.rb
90
91
  - spec/asciidoctor_kroki_diagram_spec.rb
92
+ - spec/asciidoctor_kroki_processor_spec.rb
91
93
  - spec/asciidoctor_kroki_spec.rb
92
94
  - spec/fixtures/alice.puml
93
95
  - spec/fixtures/config.puml
96
+ - spec/fixtures/plantuml-diagram.png
94
97
  - spec/require_spec.rb
95
98
  - spec/rspec_helper.rb
96
99
  - tasks/bundler.rake
@@ -102,6 +105,7 @@ licenses:
102
105
  metadata:
103
106
  bug_tracker_uri: https://github.com/Mogztter/asciidoctor-kroki/issues
104
107
  source_code_uri: https://github.com/Mogztter/asciidoctor-kroki
108
+ rubygems_mfa_required: 'true'
105
109
  post_install_message:
106
110
  rdoc_options: []
107
111
  require_paths:
@@ -121,16 +125,4 @@ rubygems_version: 3.1.6
121
125
  signing_key:
122
126
  specification_version: 4
123
127
  summary: Asciidoctor extension to convert diagrams to images using Kroki
124
- test_files:
125
- - spec/.rubocop.yml
126
- - spec/asciidoctor_kroki_block_macro_spec.rb
127
- - spec/asciidoctor_kroki_client_spec.rb
128
- - spec/asciidoctor_kroki_diagram_spec.rb
129
- - spec/asciidoctor_kroki_spec.rb
130
- - spec/fixtures/alice.puml
131
- - spec/fixtures/config.puml
132
- - spec/require_spec.rb
133
- - spec/rspec_helper.rb
134
- - tasks/bundler.rake
135
- - tasks/lint.rake
136
- - tasks/rspec.rake
128
+ test_files: []