asciidoctor-diagram 2.2.3 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +159 -0
  3. data/README.adoc +17 -13
  4. data/lib/asciidoctor-diagram/a2s/converter.rb +7 -2
  5. data/lib/asciidoctor-diagram/barcode/converter.rb +83 -78
  6. data/lib/asciidoctor-diagram/blockdiag/converter.rb +12 -2
  7. data/lib/asciidoctor-diagram/bpmn/converter.rb +4 -1
  8. data/lib/asciidoctor-diagram/bytefield/converter.rb +4 -1
  9. data/lib/asciidoctor-diagram/d2/converter.rb +57 -0
  10. data/lib/asciidoctor-diagram/d2/extension.rb +18 -0
  11. data/lib/asciidoctor-diagram/d2.rb +8 -0
  12. data/lib/asciidoctor-diagram/dbml/converter.rb +27 -0
  13. data/lib/asciidoctor-diagram/dbml/extension.rb +18 -0
  14. data/lib/asciidoctor-diagram/dbml.rb +8 -0
  15. data/lib/asciidoctor-diagram/diagram_processor.rb +49 -9
  16. data/lib/asciidoctor-diagram/diagram_source.rb +35 -33
  17. data/lib/asciidoctor-diagram/diagrams/converter.rb +4 -1
  18. data/lib/asciidoctor-diagram/ditaa/converter.rb +15 -7
  19. data/lib/asciidoctor-diagram/ditaa/ditaa-2.2.0.jar +0 -0
  20. data/lib/asciidoctor-diagram/dpic/converter.rb +4 -1
  21. data/lib/asciidoctor-diagram/erd/converter.rb +5 -2
  22. data/lib/asciidoctor-diagram/gnuplot/converter.rb +7 -1
  23. data/lib/asciidoctor-diagram/graphviz/converter.rb +4 -1
  24. data/lib/asciidoctor-diagram/graphviz_py/converter.rb +4 -1
  25. data/lib/asciidoctor-diagram/http/converter.rb +16 -7
  26. data/lib/asciidoctor-diagram/http/server.rb +2 -2
  27. data/lib/asciidoctor-diagram/lilypond/converter.rb +3 -2
  28. data/lib/asciidoctor-diagram/meme/converter.rb +29 -3
  29. data/lib/asciidoctor-diagram/mermaid/converter.rb +4 -2
  30. data/lib/asciidoctor-diagram/msc/converter.rb +6 -2
  31. data/lib/asciidoctor-diagram/nomnoml/converter.rb +4 -1
  32. data/lib/asciidoctor-diagram/penrose/converter.rb +53 -0
  33. data/lib/asciidoctor-diagram/penrose/extension.rb +18 -0
  34. data/lib/asciidoctor-diagram/penrose.rb +8 -0
  35. data/lib/asciidoctor-diagram/pikchr/converter.rb +4 -1
  36. data/lib/asciidoctor-diagram/pintora/converter.rb +60 -0
  37. data/lib/asciidoctor-diagram/pintora/extension.rb +18 -0
  38. data/lib/asciidoctor-diagram/pintora.rb +8 -0
  39. data/lib/asciidoctor-diagram/plantuml/converter.rb +256 -43
  40. data/lib/asciidoctor-diagram/plantuml/plantuml-2.2.4.jar +0 -0
  41. data/lib/asciidoctor-diagram/shaape/converter.rb +4 -1
  42. data/lib/asciidoctor-diagram/smcat/converter.rb +5 -1
  43. data/lib/asciidoctor-diagram/structurizr/converter.rb +69 -0
  44. data/lib/asciidoctor-diagram/structurizr/extension.rb +52 -0
  45. data/lib/asciidoctor-diagram/structurizr/renderers.rb +63 -0
  46. data/lib/asciidoctor-diagram/structurizr/structurizr-2.2.2.jar +0 -0
  47. data/lib/asciidoctor-diagram/structurizr.rb +7 -0
  48. data/lib/asciidoctor-diagram/svgbob/converter.rb +6 -2
  49. data/lib/asciidoctor-diagram/symbolator/converter.rb +4 -1
  50. data/lib/asciidoctor-diagram/syntrax/converter.rb +72 -17
  51. data/lib/asciidoctor-diagram/syntrax/syntrax-2.2.0.jar +0 -0
  52. data/lib/asciidoctor-diagram/tikz/converter.rb +5 -2
  53. data/lib/asciidoctor-diagram/umlet/converter.rb +4 -1
  54. data/lib/asciidoctor-diagram/util/base64.rb +25 -0
  55. data/lib/asciidoctor-diagram/util/cli.rb +11 -3
  56. data/lib/asciidoctor-diagram/util/cli_generator.rb +1 -0
  57. data/lib/asciidoctor-diagram/util/java.rb +15 -7
  58. data/lib/asciidoctor-diagram/util/java_jruby.rb +14 -0
  59. data/lib/asciidoctor-diagram/util/java_socket.rb +4 -0
  60. data/lib/asciidoctor-diagram/util/server-2.2.3.jar +0 -0
  61. data/lib/asciidoctor-diagram/util/svg.rb +5 -3
  62. data/lib/asciidoctor-diagram/vega/converter.rb +5 -3
  63. data/lib/asciidoctor-diagram/version.rb +1 -1
  64. data/lib/asciidoctor-diagram/wavedrom/converter.rb +38 -24
  65. data/lib/asciidoctor-diagram.rb +5 -0
  66. metadata +32 -115
  67. data/Rakefile +0 -9
  68. data/docs/antora.yml +0 -3
  69. data/docs/modules/ROOT/images/asciidoctor-diagram-classes.png +0 -0
  70. data/docs/modules/ROOT/images/asciidoctor-diagram-process.png +0 -0
  71. data/docs/modules/ROOT/pages/index.adoc +0 -21
  72. data/docs/modules/ROOT/partials/advanced.adoc +0 -365
  73. data/docs/modules/ROOT/partials/create_diagram.adoc +0 -134
  74. data/docs/modules/ROOT/partials/generate.adoc +0 -15
  75. data/docs/modules/ROOT/partials/installation.adoc +0 -19
  76. data/docs/modules/ROOT/partials/uris.adoc +0 -41
  77. data/examples/Gemfile +0 -3
  78. data/examples/README.adoc +0 -18
  79. data/examples/design.adoc +0 -78
  80. data/examples/features.adoc +0 -189
  81. data/lib/asciidoctor-diagram/ditaa/ditaa-1.3.21.jar +0 -0
  82. data/lib/asciidoctor-diagram/plantuml/plantuml-1.3.21.jar +0 -0
  83. data/lib/asciidoctor-diagram/util/server-1.3.21.jar +0 -0
  84. data/spec/a2s_spec.rb +0 -33
  85. data/spec/barcode_spec.rb +0 -176
  86. data/spec/blockdiag_spec.rb +0 -20
  87. data/spec/bpmn_spec.rb +0 -60
  88. data/spec/bytefield_spec.rb +0 -96
  89. data/spec/diagrams_spec.rb +0 -27
  90. data/spec/ditaa_spec.rb +0 -191
  91. data/spec/dpic_spec.rb +0 -23
  92. data/spec/erd_spec.rb +0 -96
  93. data/spec/gnuplot_spec.rb +0 -229
  94. data/spec/graphviz_py_spec.rb +0 -33
  95. data/spec/graphviz_spec.rb +0 -24
  96. data/spec/lilypond_spec.rb +0 -17
  97. data/spec/man.jpg +0 -0
  98. data/spec/meme_spec.rb +0 -67
  99. data/spec/mermaid_spec.rb +0 -198
  100. data/spec/msc_spec.rb +0 -37
  101. data/spec/nomnoml_spec.rb +0 -36
  102. data/spec/pikchr_spec.rb +0 -73
  103. data/spec/plantuml_spec.rb +0 -772
  104. data/spec/shaape_spec.rb +0 -20
  105. data/spec/shared_examples.rb +0 -764
  106. data/spec/smcat_spec.rb +0 -30
  107. data/spec/svgbob_spec.rb +0 -33
  108. data/spec/symbolator_spec.rb +0 -27
  109. data/spec/syntrax_spec.rb +0 -22
  110. data/spec/test_helper.rb +0 -113
  111. data/spec/tikz_spec.rb +0 -181
  112. data/spec/umlet_spec.rb +0 -32
  113. data/spec/vega_spec.rb +0 -133
  114. data/spec/wavedrom_spec.rb +0 -21
@@ -1,764 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- RSpec.shared_examples "block_macro" do |name, code, formats|
4
- formats.each do |format|
5
- if format == :txt
6
- it "#{name} should generate literal blocks when format is set to 'txt'" do
7
- File.write("#{name}.txt", code)
8
-
9
- doc = <<-eos
10
- = Hello, #{name}!
11
- Doc Writer <doc@example.com>
12
-
13
- == First Section
14
-
15
- #{name}::#{name}.txt[#{format}]
16
- eos
17
-
18
- d = load_asciidoc doc
19
- expect(d).to_not be_nil
20
-
21
- b = d.find { |bl| bl.context == :literal }
22
- expect(b).to_not be_nil
23
-
24
- expect(b.content_model).to eq :verbatim
25
-
26
- expect(b.attributes['target']).to be_nil
27
- end
28
- else
29
- it "#{name} should generate image blocks when format is set to '#{format}'" do
30
- File.write("#{name}.txt", code)
31
-
32
- doc = <<-eos
33
- = Hello, #{name}!
34
- Doc Writer <doc@example.com>
35
-
36
- == First Section
37
-
38
- #{name}::#{name}.txt[#{format}]
39
- eos
40
-
41
- d = load_asciidoc doc
42
- expect(d).to_not be_nil
43
-
44
- b = d.find { |bl| bl.context == :image }
45
- expect(b).to_not be_nil
46
-
47
- expect(b.content_model).to eq :empty
48
-
49
- target = b.attributes['target']
50
- expect(target).to_not be_nil
51
- expect(target).to match(/\.#{format}$/)
52
- expect(File.exist?(target)).to be true
53
-
54
- unless format == :pdf
55
- expect(b.attributes['width']).to_not be_nil
56
- expect(b.attributes['height']).to_not be_nil
57
- end
58
- end
59
- end
60
- end
61
-
62
- it 'should support substitutions in the target attribute' do
63
- File.write("#{name}.txt", code)
64
-
65
- doc = <<-eos
66
- = Hello, #{name}!
67
- Doc Writer <doc@example.com>
68
- :file: #{name}
69
-
70
- == First Section
71
-
72
- #{name}::{file}.txt[subs=attributes+]
73
- eos
74
-
75
- d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
76
- expect(d).to_not be_nil
77
-
78
- b = d.find { |bl| bl.context == :image }
79
- expect(b).to_not be_nil
80
-
81
- target = b.attributes['target']
82
- expect(File.exist?(target)).to be true
83
- end
84
-
85
- it 'should support substitutions in the format attribute' do
86
- File.write("#{name}.txt", code)
87
-
88
- doc = <<-eos
89
- = Hello, #{name}!
90
- Doc Writer <doc@example.com>
91
- :file: #{name}
92
- :outputformat: #{formats[0]}
93
-
94
- == First Section
95
-
96
- #{name}::{file}.txt[format="{outputformat}", subs=attributes+]
97
- eos
98
-
99
- d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
100
- expect(d).to_not be_nil
101
-
102
- b = d.find { |bl| bl.context == :image }
103
- expect(b).to_not be_nil
104
-
105
- target = b.attributes['target']
106
- expect(target).to match(/\.#{formats[0]}$/)
107
- expect(File.exist?(target)).to be true
108
-
109
- unless formats[0] == :pdf
110
- expect(b.attributes['width']).to_not be_nil
111
- expect(b.attributes['height']).to_not be_nil
112
- end
113
- end
114
-
115
- it 'should generate blocks with figure captions' do
116
- File.write("#{name}.txt", code)
117
-
118
- doc = <<-eos
119
- = Hello, #{name}!
120
- Doc Writer <doc@example.com>
121
-
122
- == First Section
123
-
124
- .This is a diagram
125
- #{name}::#{name}.txt[]
126
- eos
127
-
128
- d = load_asciidoc doc
129
- expect(d).to_not be_nil
130
-
131
- b = d.find { |bl| bl.context == :image }
132
- expect(b).to_not be_nil
133
-
134
- expect(b.caption).to match(/Figure \d+/)
135
- end
136
-
137
- it 'should handle two block macros with the same source' do
138
- File.write("#{name}.txt", code)
139
-
140
- doc = <<-eos
141
- = Hello, #{name}!
142
- Doc Writer <doc@example.com>
143
-
144
- == First Section
145
-
146
- #{name}::#{name}.txt[]
147
- #{name}::#{name}.txt[]
148
- eos
149
-
150
- d = load_asciidoc doc
151
-
152
- b = d.find { |bl| bl.context == :image }
153
- expect(b).to_not be_nil
154
-
155
- target = b.attributes['target']
156
- expect(File.exist?(target)).to be true
157
- end
158
-
159
- it 'should respect target attribute in block macros' do
160
- File.write("#{name}.txt", code)
161
-
162
- doc = <<-eos
163
- = Hello, #{name}!
164
- Doc Writer <doc@example.com>
165
-
166
- == First Section
167
-
168
- #{name}::#{name}.txt[target="foobar"]
169
- #{name}::#{name}.txt[target="foobaz"]
170
- eos
171
-
172
- load_asciidoc doc
173
- expect(File.exist?("foobar.#{formats[0]}")).to be true
174
- expect(File.exist?("foobaz.#{formats[0]}")).to be true
175
- expect(File.exist?("#{name}.#{formats[0]}")).to be false
176
- end
177
-
178
- it 'should respect target attribute values with relative paths in block macros' do
179
- File.write("#{name}.txt", code)
180
-
181
- doc = <<-eos
182
- = Hello, #{name}!
183
- Doc Writer <doc@example.com>
184
-
185
- == First Section
186
-
187
- #{name}::#{name}.txt[target="test/foobar"]
188
- #{name}::#{name}.txt[target="test2/foobaz"]
189
- eos
190
-
191
- load_asciidoc doc
192
- expect(File.exist?("test/foobar.#{formats[0]}")).to be true
193
- expect(File.exist?("test2/foobaz.#{formats[0]}")).to be true
194
- expect(File.exist?("#{name}.#{formats[0]}")).to be false
195
- end
196
- end
197
-
198
- RSpec.shared_examples "inline_macro" do |name, code, formats|
199
- formats.each do |format|
200
- it "#{name} should generate image tags when format is set to '#{format}'" do
201
- File.write("#{name}.txt", code)
202
-
203
- doc = <<-eos
204
- = Hello, #{name}!
205
- Doc Writer <doc@example.com>
206
-
207
- == First Section
208
-
209
- #{name}:#{name}.txt[#{format}]
210
- eos
211
-
212
- d = load_asciidoc doc
213
- expect(d).to_not be_nil
214
-
215
- b = d.find { |bl| bl.context == :paragraph }
216
- expect(b).to_not be_nil
217
-
218
- output = b.convert
219
- img_match = /<img[^>]*>/.match(output)
220
- expect(img_match).to_not be_nil
221
- img = img_match.to_s
222
-
223
- src_match = /src="([^"]*)"/.match(img)
224
- expect(src_match).to_not be_nil
225
- src = src_match[1]
226
-
227
- expect(src).to_not be_nil
228
- expect(src).to match(/\.#{format}$/)
229
- expect(File.exist?(src)).to be true
230
-
231
- unless format == :pdf
232
- expect(/width="([^"]*)"/.match(img)).to_not be_nil
233
- expect(/height="([^"]*)"/.match(img)).to_not be_nil
234
- end
235
- end
236
- end
237
-
238
- it 'should support substitutions in the target attribute' do
239
- File.write("#{name}.txt", code)
240
-
241
- doc = <<-eos
242
- = Hello, #{name}!
243
- Doc Writer <doc@example.com>
244
- :file: #{name}
245
-
246
- == First Section
247
-
248
- #{name}:{file}.txt[subs=attributes+]
249
- eos
250
-
251
- d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
252
- expect(d).to_not be_nil
253
-
254
- b = d.find { |bl| bl.context == :paragraph }
255
- expect(b).to_not be_nil
256
-
257
- output = b.convert
258
- img_match = /<img[^>]*>/.match(output)
259
- expect(img_match).to_not be_nil
260
- img = img_match.to_s
261
-
262
- src_match = /src="([^"]*)"/.match(img)
263
- expect(src_match).to_not be_nil
264
- src = src_match[1]
265
-
266
- expect(src).to_not be_nil
267
- expect(src).to match(/\.#{formats[0]}$/)
268
- expect(File.exist?(src)).to be true
269
- end
270
-
271
- it 'should support substitutions in the format attribute' do
272
- File.write("#{name}.txt", code)
273
-
274
- doc = <<-eos
275
- = Hello, #{name}!
276
- Doc Writer <doc@example.com>
277
- :file: #{name}
278
- :outputformat: #{formats[0]}
279
-
280
- == First Section
281
-
282
- #{name}:{file}.txt[format="{outputformat}", subs=attributes+]
283
- eos
284
-
285
- d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
286
- expect(d).to_not be_nil
287
-
288
- b = d.find { |bl| bl.context == :paragraph }
289
- expect(b).to_not be_nil
290
-
291
- output = b.convert
292
- img_match = /<img[^>]*>/.match(output)
293
- expect(img_match).to_not be_nil
294
- img = img_match.to_s
295
-
296
- src_match = /src="([^"]*)"/.match(img)
297
- expect(src_match).to_not be_nil
298
- src = src_match[1]
299
-
300
- expect(src).to_not be_nil
301
- expect(src).to match(/\.#{formats[0]}$/)
302
- expect(File.exist?(src)).to be true
303
-
304
- unless formats[0] == :pdf
305
- expect(/width="([^"]*)"/.match(img)).to_not be_nil
306
- expect(/height="([^"]*)"/.match(img)).to_not be_nil
307
- end
308
- end
309
-
310
- it 'should respect target attribute in inline macros' do
311
- File.write("#{name}.txt", code)
312
-
313
- doc = <<-eos
314
- = Hello, #{name}!
315
- Doc Writer <doc@example.com>
316
-
317
- == First Section
318
-
319
- #{name}:#{name}.txt[target="foobar"]
320
- #{name}:#{name}.txt[target="foobaz"]
321
- eos
322
-
323
- d = load_asciidoc doc
324
-
325
- b = d.find { |bl| bl.context == :paragraph }
326
- expect(b).to_not be_nil
327
- b.convert
328
-
329
- expect(File.exist?("foobar.#{formats[0]}")).to be true
330
- expect(File.exist?("foobaz.#{formats[0]}")).to be true
331
- expect(File.exist?("#{name}.#{formats[0]}")).to be false
332
- end
333
-
334
- it 'should respect target attribute values with relative paths in inline macros' do
335
- File.write("#{name}.txt", code)
336
-
337
- doc = <<-eos
338
- = Hello, #{name}!
339
- Doc Writer <doc@example.com>
340
-
341
- == First Section
342
-
343
- #{name}:#{name}.txt[target="test/foobar"]
344
- #{name}:#{name}.txt[target="test2/foobaz"]
345
- eos
346
-
347
- d = load_asciidoc doc
348
-
349
- b = d.find { |bl| bl.context == :paragraph }
350
- expect(b).to_not be_nil
351
- b.convert
352
-
353
- expect(File.exist?("test/foobar.#{formats[0]}")).to be true
354
- expect(File.exist?("test2/foobaz.#{formats[0]}")).to be true
355
- expect(File.exist?("#{name}.#{formats[0]}")).to be false
356
- end
357
- end
358
-
359
- RSpec.shared_examples "block" do |name, code, formats|
360
- formats.each do |format|
361
- if format == :txt
362
- it "#{name} should generate literal blocks when format is set to 'txt'" do
363
- doc = <<-eos
364
- = Hello, #{name}!
365
- Doc Writer <doc@example.com>
366
-
367
- == First Section
368
-
369
- [#{name}, format="#{format}"]
370
- ----
371
- #{code}
372
- ----
373
- eos
374
-
375
- d = load_asciidoc doc
376
- expect(d).to_not be_nil
377
-
378
- b = d.find { |bl| bl.context == :literal }
379
- expect(b).to_not be_nil
380
-
381
- expect(b.content_model).to eq :verbatim
382
-
383
- expect(b.attributes['target']).to be_nil
384
- end
385
- else
386
- it "#{name} should generate image blocks when format is set to '#{format}'" do
387
- doc = <<-eos
388
- = Hello, #{name}!
389
- Doc Writer <doc@example.com>
390
-
391
- == First Section
392
-
393
- [#{name}, format="#{format}"]
394
- ----
395
- #{code}
396
- ----
397
- eos
398
-
399
- d = load_asciidoc doc
400
- expect(d).to_not be_nil
401
-
402
- b = d.find { |bl| bl.context == :image }
403
- expect(b).to_not be_nil
404
-
405
- expect(b.content_model).to eq :empty
406
-
407
- target = b.attributes['target']
408
- expect(target).to_not be_nil
409
- expect(target).to match(/\.#{format}$/)
410
- expect(File.exist?(target)).to be true
411
-
412
- unless format == :pdf
413
- expect(b.attributes['width']).to_not be_nil
414
- expect(b.attributes['height']).to_not be_nil
415
- end
416
- end
417
- end
418
- end
419
-
420
- if formats.include? :svg
421
- it "#{name} should respect the svg-type attribute when format is set to 'svg'" do
422
- doc = <<-eos
423
- = Hello, #{name}!
424
- Doc Writer <doc@example.com>
425
-
426
- == First Section
427
-
428
- [#{name}, format="svg", svg-type="inline"]
429
- ----
430
- #{code}
431
- ----
432
- eos
433
-
434
- d = load_asciidoc doc
435
- expect(d).to_not be_nil
436
-
437
- b = d.find { |bl| bl.context == :image }
438
- expect(b).to_not be_nil
439
-
440
- expect(b.content_model).to eq :empty
441
-
442
- target = b.attributes['target']
443
- expect(target).to_not be_nil
444
- expect(target).to match(/\.svg/)
445
- expect(File.exist?(target)).to be true
446
-
447
- expect(b.option?('inline')).to be_truthy
448
-
449
- unless formats[0] == :pdf
450
- expect(b.attributes['width']).to_not be_nil
451
- expect(b.attributes['height']).to_not be_nil
452
- end
453
- end
454
-
455
- it "#{name} should respect the diagram-svg-type attribute when format is set to 'svg'" do
456
- doc = <<-eos
457
- = Hello, #{name}!
458
- :diagram-svg-type: inline
459
- Doc Writer <doc@example.com>
460
-
461
- == First Section
462
-
463
- [#{name}, format="svg"]
464
- ----
465
- #{code}
466
- ----
467
- eos
468
-
469
- d = load_asciidoc doc
470
- expect(d).to_not be_nil
471
-
472
- b = d.find { |bl| bl.context == :image }
473
- expect(b).to_not be_nil
474
-
475
- expect(b.content_model).to eq :empty
476
-
477
- target = b.attributes['target']
478
- expect(target).to_not be_nil
479
- expect(target).to match(/\.svg/)
480
- expect(File.exist?(target)).to be true
481
-
482
- expect(b.option?('inline')).to be_truthy
483
-
484
- unless formats[0] == :pdf
485
- expect(b.attributes['width']).to_not be_nil
486
- expect(b.attributes['height']).to_not be_nil
487
- end
488
- end
489
- end
490
-
491
- it 'should raise an error when when format is set to an invalid value' do
492
- doc = <<-eos
493
- = Hello, #{name}!
494
- Doc Writer <doc@example.com>
495
-
496
- == First Section
497
-
498
- [#{name}, format="foobar"]
499
- ----
500
- ----
501
- eos
502
-
503
- expect { load_asciidoc doc }.to raise_error(/support.*format/i)
504
- end
505
-
506
- it 'should not regenerate images when source has not changed' do
507
- doc = <<-eos
508
- = Hello, #{name}!
509
- Doc Writer <doc@example.com>
510
-
511
- == First Section
512
-
513
- [#{name}]
514
- ----
515
- #{code}
516
- ----
517
- eos
518
-
519
- d = load_asciidoc doc
520
- b1 = d.find { |bl| bl.context == :image }
521
- target1 = b1.attributes['target']
522
- mtime1 = File.mtime(target1)
523
-
524
- sleep 1
525
-
526
- d = load_asciidoc doc
527
- b2 = d.find { |bl| bl.context == :image }
528
- target2 = b2.attributes['target']
529
-
530
- mtime2 = File.mtime(target1)
531
-
532
- expect(mtime2).to eq mtime1
533
- end
534
-
535
- it 'should write files to outdir if set' do
536
- doc = <<-eos
537
- = Hello, #{name}!
538
- Doc Writer <doc@example.com>
539
-
540
- == First Section
541
-
542
- [#{name}]
543
- ----
544
- #{code}
545
- ----
546
- eos
547
-
548
- d = load_asciidoc doc, {:attributes => {'outdir' => 'foo'}}
549
- b = d.find { |bl| bl.context == :image }
550
-
551
- target = b.attributes['target']
552
- expect(target).to_not be_nil
553
- expect(File.exist?(target)).to be false
554
- expect(File.exist?(File.expand_path(target, 'foo'))).to be true
555
- end
556
-
557
- it 'should write files to to_dir if set' do
558
- doc = <<-eos
559
- = Hello, #{name}!
560
- Doc Writer <doc@example.com>
561
-
562
- == First Section
563
-
564
- [#{name}]
565
- ----
566
- #{code}
567
- ----
568
- eos
569
-
570
- d = load_asciidoc doc, {:to_dir => 'foo'}
571
- b = d.find { |bl| bl.context == :image }
572
-
573
- target = b.attributes['target']
574
- expect(target).to_not be_nil
575
- expect(File.exist?(target)).to be false
576
- expect(File.exist?(File.expand_path(target, 'foo'))).to be true
577
- end
578
-
579
- it 'should write files to to_dir if set in safe mode' do
580
- doc = <<-eos
581
- = Hello, #{name}!
582
- Doc Writer <doc@example.com>
583
-
584
- == First Section
585
-
586
- [#{name}]
587
- ----
588
- #{code}
589
- ----
590
- eos
591
-
592
- to_dir = File.expand_path('foo')
593
- d = load_asciidoc doc, {:to_dir => to_dir, :safe => :safe}
594
- b = d.find { |bl| bl.context == :image }
595
-
596
- target = b.attributes['target']
597
- expect(target).to_not be_nil
598
- expect(File.exist?(target)).to be false
599
- expect(File.exist?(File.expand_path(target, to_dir))).to be true
600
- end
601
-
602
- it 'should write files to to_dir if set when embedded in table' do
603
- doc = <<-eos
604
- = Hello, #{name}!
605
- Doc Writer <doc@example.com>
606
-
607
- == First Section
608
-
609
- |===
610
- |Type | Example
611
-
612
- |graphviz
613
- a|
614
- [#{name}]
615
- ----
616
- #{code.gsub('|', '\|')}
617
- ----
618
- |===
619
- eos
620
-
621
- d = load_asciidoc doc, {:to_dir => 'foo'}
622
- b = d.find { |bl| bl.context == :image }
623
-
624
- target = b.attributes['target']
625
- expect(target).to_not be_nil
626
- expect(File.exist?(target)).to be false
627
- expect(File.exist?(File.expand_path(target, 'foo'))).to be true
628
- end
629
-
630
- it 'should write files to imagesoutdir if set' do
631
- doc = <<-eos
632
- = Hello, #{name}!
633
- Doc Writer <doc@example.com>
634
-
635
- == First Section
636
-
637
- [#{name}]
638
- ----
639
- #{code}
640
- ----
641
- eos
642
-
643
- d = load_asciidoc doc, {:attributes => {'imagesoutdir' => 'bar', 'outdir' => 'foo'}}
644
- b = d.find { |bl| bl.context == :image }
645
-
646
- target = b.attributes['target']
647
- expect(target).to_not be_nil
648
- expect(File.exist?(target)).to be false
649
- expect(File.exist?(File.expand_path(target, 'bar'))).to be true
650
- expect(File.exist?(File.expand_path(target, 'foo'))).to be false
651
- end
652
-
653
- it 'should write files to imagesoutdir if set in safe mode' do
654
- doc = <<-eos
655
- = Hello, #{name}!
656
- Doc Writer <doc@example.com>
657
-
658
- == First Section
659
-
660
- [#{name}]
661
- ----
662
- #{code}
663
- ----
664
- eos
665
-
666
- out_dir = File.expand_path('foo')
667
- images_out_dir = File.expand_path('bar')
668
-
669
- d = load_asciidoc doc, {:attributes => {'imagesoutdir' => images_out_dir, 'outdir' => out_dir}, :safe => :safe}
670
- b = d.find { |bl| bl.context == :image }
671
-
672
- target = b.attributes['target']
673
- expect(target).to_not be_nil
674
- expect(File.exist?(target)).to be false
675
- expect(File.exist?(File.expand_path(target, images_out_dir))).to be true
676
- expect(File.exist?(File.expand_path(target, out_dir))).to be false
677
- end
678
-
679
- it 'should omit width/height attributes when generating docbook' do
680
- doc = <<-eos
681
- = Hello, #{name}!
682
- Doc Writer <doc@example.com>
683
-
684
- == First Section
685
-
686
- [#{name}]
687
- ----
688
- #{code}
689
- ----
690
- eos
691
-
692
- d = load_asciidoc doc, :attributes => {'backend' => 'docbook5'}
693
- expect(d).to_not be_nil
694
-
695
- b = d.find { |bl| bl.context == :image }
696
- expect(b).to_not be_nil
697
-
698
- target = b.attributes['target']
699
- expect(File.exist?(target)).to be true
700
-
701
- expect(b.attributes['width']).to be_nil
702
- expect(b.attributes['height']).to be_nil
703
- end
704
-
705
- it 'should generate blocks with figure captions' do
706
- doc = <<-eos
707
- = Hello, #{name}!
708
- Doc Writer <doc@example.com>
709
-
710
- == First Section
711
-
712
- .Caption for my diagram
713
- [#{name}]
714
- ----
715
- #{code}
716
- ----
717
- eos
718
-
719
- d = load_asciidoc doc
720
- expect(d).to_not be_nil
721
-
722
- b = d.find { |bl| bl.context == :image }
723
- expect(b).to_not be_nil
724
-
725
- expect(b.caption).to match(/Figure \d+/)
726
- end
727
-
728
- it 'should support scaling diagrams' do
729
- doc = <<-eos
730
- = Hello, #{name}!
731
- Doc Writer <doc@example.com>
732
-
733
- == First Section
734
-
735
- [#{name}, target="unscaled"]
736
- ----
737
- #{code}
738
- ----
739
- eos
740
-
741
- scaled_doc = <<-eos
742
- = Hello, #{name}!
743
- Doc Writer <doc@example.com>
744
-
745
- == First Section
746
-
747
- [#{name}, scale="2", target="scaled"]
748
- ----
749
- #{code}
750
- ----
751
- eos
752
-
753
- d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
754
- unscaled_image = d.find { |bl| bl.context == :image }
755
-
756
- d = load_asciidoc scaled_doc, :attributes => {'backend' => 'html5'}
757
- scaled_image = d.find { |bl| bl.context == :image }
758
-
759
- unless formats[0] == :pdf
760
- expect(scaled_image.attributes['width']).to be_within(1).of(unscaled_image.attributes['width'] * 2)
761
- expect(scaled_image.attributes['height']).to be_within(1).of(unscaled_image.attributes['height'] * 2)
762
- end
763
- end
764
- end