asciidoctor-diagram 1.5.1 → 1.5.2

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.
@@ -27,15 +27,15 @@ graphviz::graphviz.txt[format="png"]
27
27
  d = load_asciidoc doc
28
28
  expect(d).to_not be_nil
29
29
 
30
- b = d.find { |b| b.context == :image }
30
+ b = d.find { |bl| bl.context == :image }
31
31
  expect(b).to_not be_nil
32
32
 
33
33
  expect(b.content_model).to eq :empty
34
34
 
35
35
  target = b.attributes['target']
36
36
  expect(target).to_not be_nil
37
- expect(target).to match /\.png$/
38
- expect(File.exists?(target)).to be true
37
+ expect(target).to match(/\.png$/)
38
+ expect(File.exist?(target)).to be true
39
39
 
40
40
  expect(b.attributes['width']).to_not be_nil
41
41
  expect(b.attributes['height']).to_not be_nil
@@ -66,15 +66,15 @@ digraph foo {
66
66
  d = load_asciidoc doc
67
67
  expect(d).to_not be_nil
68
68
 
69
- b = d.find { |b| b.context == :image }
69
+ b = d.find { |bl| bl.context == :image }
70
70
  expect(b).to_not be_nil
71
71
 
72
72
  expect(b.content_model).to eq :empty
73
73
 
74
74
  target = b.attributes['target']
75
75
  expect(target).to_not be_nil
76
- expect(target).to match /\.png$/
77
- expect(File.exists?(target)).to be true
76
+ expect(target).to match(/\.png$/)
77
+ expect(File.exist?(target)).to be true
78
78
 
79
79
  expect(b.attributes['width']).to_not be_nil
80
80
  expect(b.attributes['height']).to_not be_nil
@@ -103,15 +103,15 @@ digraph foo {
103
103
  d = load_asciidoc doc
104
104
  expect(d).to_not be_nil
105
105
 
106
- b = d.find { |b| b.context == :image }
106
+ b = d.find { |bl| bl.context == :image }
107
107
  expect(b).to_not be_nil
108
108
 
109
109
  expect(b.content_model).to eq :empty
110
110
 
111
111
  target = b.attributes['target']
112
112
  expect(target).to_not be_nil
113
- expect(target).to match /\.svg$/
114
- expect(File.exists?(target)).to be true
113
+ expect(target).to match(/\.svg$/)
114
+ expect(File.exist?(target)).to be true
115
115
 
116
116
  expect(b.attributes['width']).to_not be_nil
117
117
  expect(b.attributes['height']).to_not be_nil
@@ -129,7 +129,7 @@ Doc Writer <doc@example.com>
129
129
  ----
130
130
  eos
131
131
 
132
- expect { load_asciidoc doc }.to raise_error /support.*format/i
132
+ expect { load_asciidoc doc }.to raise_error(/support.*format/i)
133
133
  end
134
134
 
135
135
  it "should support neato layout engine" do
@@ -148,12 +148,12 @@ digraph g { rankdir=LR; Text->Graphviz->Image }
148
148
  d = load_asciidoc doc
149
149
  expect(d).to_not be_nil
150
150
 
151
- b = d.find { |b| b.context == :image }
151
+ b = d.find { |bl| bl.context == :image }
152
152
  expect(b).to_not be_nil
153
153
 
154
154
  expect(b.content_model).to eq :empty
155
155
 
156
156
  target = b.attributes['target']
157
- expect(File.exists?(target)).to be true
157
+ expect(File.exist?(target)).to be true
158
158
  end
159
159
  end
@@ -19,15 +19,15 @@ meme::man.jpg[I don't always // write unit tests, but when I do // they generate
19
19
  d = load_asciidoc doc
20
20
  expect(d).to_not be_nil
21
21
 
22
- b = d.find { |b| b.context == :image }
22
+ b = d.find { |bl| bl.context == :image }
23
23
  expect(b).to_not be_nil
24
24
 
25
25
  expect(b.content_model).to eq :empty
26
26
 
27
27
  target = b.attributes['target']
28
28
  expect(target).to_not be_nil
29
- expect(target).to match /\.png$/
30
- expect(File.exists?(target)).to be true
29
+ expect(target).to match(/\.png$/)
30
+ expect(File.exist?(target)).to be true
31
31
 
32
32
  expect(b.attributes['width']).to_not be_nil
33
33
  expect(b.attributes['height']).to_not be_nil
@@ -51,15 +51,15 @@ meme::man.jpg[I don't always // write unit tests, but when I do // they generate
51
51
  d = load_asciidoc doc
52
52
  expect(d).to_not be_nil
53
53
 
54
- b = d.find { |b| b.context == :image }
54
+ b = d.find { |bl| bl.context == :image }
55
55
  expect(b).to_not be_nil
56
56
 
57
57
  expect(b.content_model).to eq :empty
58
58
 
59
59
  target = b.attributes['target']
60
60
  expect(target).to_not be_nil
61
- expect(target).to match /\.gif/
62
- expect(File.exists?(target)).to be true
61
+ expect(target).to match(/\.gif/)
62
+ expect(File.exist?(target)).to be true
63
63
 
64
64
  expect(b.attributes['width']).to_not be_nil
65
65
  expect(b.attributes['height']).to_not be_nil
@@ -24,15 +24,15 @@ mermaid::mermaid.txt[format="png"]
24
24
  d = load_asciidoc doc
25
25
  expect(d).to_not be_nil
26
26
 
27
- b = d.find { |b| b.context == :image }
27
+ b = d.find { |bl| bl.context == :image }
28
28
  expect(b).to_not be_nil
29
29
 
30
30
  expect(b.content_model).to eq :empty
31
31
 
32
32
  target = b.attributes['target']
33
33
  expect(target).to_not be_nil
34
- expect(target).to match /\.png$/
35
- expect(File.exists?(target)).to be true
34
+ expect(target).to match(/\.png$/)
35
+ expect(File.exist?(target)).to be true
36
36
 
37
37
  expect(b.attributes['width']).to_not be_nil
38
38
  expect(b.attributes['height']).to_not be_nil
@@ -53,15 +53,15 @@ mermaid::mermaid.txt[format="svg"]
53
53
  d = load_asciidoc doc
54
54
  expect(d).to_not be_nil
55
55
 
56
- b = d.find { |b| b.context == :image }
56
+ b = d.find { |bl| bl.context == :image }
57
57
  expect(b).to_not be_nil
58
58
 
59
59
  expect(b.content_model).to eq :empty
60
60
 
61
61
  target = b.attributes['target']
62
62
  expect(target).to_not be_nil
63
- expect(target).to match /\.svg/
64
- expect(File.exists?(target)).to be true
63
+ expect(target).to match(/\.svg/)
64
+ expect(File.exist?(target)).to be true
65
65
 
66
66
  expect(b.attributes['width']).to_not be_nil
67
67
  expect(b.attributes['height']).to_not be_nil
@@ -85,15 +85,15 @@ Doc Writer <doc@example.com>
85
85
  d = load_asciidoc doc
86
86
  expect(d).to_not be_nil
87
87
 
88
- b = d.find { |b| b.context == :image }
88
+ b = d.find { |bl| bl.context == :image }
89
89
  expect(b).to_not be_nil
90
90
 
91
91
  expect(b.content_model).to eq :empty
92
92
 
93
93
  target = b.attributes['target']
94
94
  expect(target).to_not be_nil
95
- expect(target).to match /\.png$/
96
- expect(File.exists?(target)).to be true
95
+ expect(target).to match(/\.png$/)
96
+ expect(File.exist?(target)).to be true
97
97
 
98
98
  expect(b.attributes['width']).to_not be_nil
99
99
  expect(b.attributes['height']).to_not be_nil
@@ -115,15 +115,15 @@ Doc Writer <doc@example.com>
115
115
  d = load_asciidoc doc
116
116
  expect(d).to_not be_nil
117
117
 
118
- b = d.find { |b| b.context == :image }
118
+ b = d.find { |bl| bl.context == :image }
119
119
  expect(b).to_not be_nil
120
120
 
121
121
  expect(b.content_model).to eq :empty
122
122
 
123
123
  target = b.attributes['target']
124
124
  expect(target).to_not be_nil
125
- expect(target).to match /\.svg/
126
- expect(File.exists?(target)).to be true
125
+ expect(target).to match(/\.svg/)
126
+ expect(File.exist?(target)).to be true
127
127
 
128
128
  expect(b.attributes['width']).to_not be_nil
129
129
  expect(b.attributes['height']).to_not be_nil
@@ -141,7 +141,7 @@ Doc Writer <doc@example.com>
141
141
  ----
142
142
  eos
143
143
 
144
- expect { load_asciidoc doc }.to raise_error /support.*format/i
144
+ expect { load_asciidoc doc }.to raise_error(/support.*format/i)
145
145
  end
146
146
 
147
147
  it "should not regenerate images when source has not changed" do
@@ -162,7 +162,7 @@ mermaid::mermaid.txt
162
162
  eos
163
163
 
164
164
  d = load_asciidoc doc
165
- b = d.find { |b| b.context == :image }
165
+ b = d.find { |bl| bl.context == :image }
166
166
  expect(b).to_not be_nil
167
167
  target = b.attributes['target']
168
168
  mtime1 = File.mtime(target)
@@ -190,7 +190,7 @@ mermaid::mermaid.txt[]
190
190
  eos
191
191
 
192
192
  load_asciidoc doc
193
- expect(File.exists?('mermaid.png')).to be true
193
+ expect(File.exist?('mermaid.png')).to be true
194
194
  end
195
195
 
196
196
  it "should respect target attribute in block macros" do
@@ -207,9 +207,9 @@ mermaid::mermaid.txt["foobaz"]
207
207
  eos
208
208
 
209
209
  load_asciidoc doc
210
- expect(File.exists?('foobar.png')).to be true
211
- expect(File.exists?('foobaz.png')).to be true
212
- expect(File.exists?('mermaid.png')).to be false
210
+ expect(File.exist?('foobar.png')).to be true
211
+ expect(File.exist?('foobaz.png')).to be true
212
+ expect(File.exist?('mermaid.png')).to be false
213
213
  end
214
214
 
215
215
  it "should respect the sequenceConfig attribute" do
@@ -245,8 +245,8 @@ mermaid::mermaid.txt["without_config"]
245
245
  eos
246
246
 
247
247
  load_asciidoc doc
248
- expect(File.exists?('with_config.png')).to be true
249
- expect(File.exists?('without_config.png')).to be true
248
+ expect(File.exist?('with_config.png')).to be true
249
+ expect(File.exist?('without_config.png')).to be true
250
250
  expect(File.size('with_config.png')).to_not be File.size('without_config.png')
251
251
  end
252
252
 
@@ -270,8 +270,8 @@ mermaid::mermaid.txt["without_width"]
270
270
  eos
271
271
 
272
272
  load_asciidoc doc
273
- expect(File.exists?('with_width.png')).to be true
274
- expect(File.exists?('without_width.png')).to be true
273
+ expect(File.exist?('with_width.png')).to be true
274
+ expect(File.exist?('without_width.png')).to be true
275
275
  expect(File.size('with_width.png')).to_not be File.size('without_width.png')
276
276
  end
277
277
  end
@@ -23,14 +23,50 @@ plantuml::plantuml.txt[format="png"]
23
23
  d = load_asciidoc doc
24
24
  expect(d).to_not be_nil
25
25
 
26
- b = d.find { |b| b.context == :image }
26
+ b = d.find { |bl| bl.context == :image }
27
27
  expect(b).to_not be_nil
28
28
 
29
29
  expect(b.content_model).to eq :empty
30
30
 
31
31
  target = b.attributes['target']
32
32
  expect(target).to_not be_nil
33
- expect(target).to match /\.png$/
33
+ expect(target).to match(/\.png$/)
34
+ expect(File.exist?(target)).to be true
35
+
36
+ expect(b.attributes['width']).to_not be_nil
37
+ expect(b.attributes['height']).to_not be_nil
38
+ end
39
+
40
+ it "should generate PNG images when format is set to 'png'" do
41
+ code = <<-eos
42
+ User -> (Start)
43
+ User --> (Use the application) : Label
44
+
45
+ :Main Admin: ---> (Use the application) : Another label
46
+ eos
47
+
48
+ File.write('plantuml.txt', code)
49
+
50
+ doc = <<-eos
51
+ = Hello, PlantUML!
52
+ Doc Writer <doc@example.com>
53
+
54
+ == First Section
55
+
56
+ plantuml::plantuml.txt[format="png"]
57
+ eos
58
+
59
+ d = load_asciidoc doc
60
+ expect(d).to_not be_nil
61
+
62
+ b = d.find { |bl| bl.context == :image }
63
+ expect(b).to_not be_nil
64
+
65
+ expect(b.content_model).to eq :empty
66
+
67
+ target = b.attributes['target']
68
+ expect(target).to_not be_nil
69
+ expect(target).to match(/\.png$/)
34
70
  expect(File.exists?(target)).to be true
35
71
 
36
72
  expect(b.attributes['width']).to_not be_nil
@@ -60,11 +96,11 @@ plantuml::plantuml.txt[format="svg", subs=attributes+]
60
96
  d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
61
97
  expect(d).to_not be_nil
62
98
 
63
- b = d.find { |b| b.context == :image }
99
+ b = d.find { |bl| bl.context == :image }
64
100
  expect(b).to_not be_nil
65
101
 
66
102
  target = b.attributes['target']
67
- expect(File.exists?(target)).to be true
103
+ expect(File.exist?(target)).to be true
68
104
 
69
105
  content = File.read(target)
70
106
  expect(content).to include('ParentClass')
@@ -124,15 +160,15 @@ User --> (Use the application) : Label
124
160
  d = load_asciidoc doc
125
161
  expect(d).to_not be_nil
126
162
 
127
- b = d.find { |b| b.context == :image }
163
+ b = d.find { |bl| bl.context == :image }
128
164
  expect(b).to_not be_nil
129
165
 
130
166
  expect(b.content_model).to eq :empty
131
167
 
132
168
  target = b.attributes['target']
133
169
  expect(target).to_not be_nil
134
- expect(target).to match /\.png$/
135
- expect(File.exists?(target)).to be true
170
+ expect(target).to match(/\.png$/)
171
+ expect(File.exist?(target)).to be true
136
172
 
137
173
  expect(b.attributes['width']).to_not be_nil
138
174
  expect(b.attributes['height']).to_not be_nil
@@ -157,15 +193,15 @@ User --> (Use the application) : Label
157
193
  d = load_asciidoc doc
158
194
  expect(d).to_not be_nil
159
195
 
160
- b = d.find { |b| b.context == :image }
196
+ b = d.find { |bl| bl.context == :image }
161
197
  expect(b).to_not be_nil
162
198
 
163
199
  expect(b.content_model).to eq :empty
164
200
 
165
201
  target = b.attributes['target']
166
202
  expect(target).to_not be_nil
167
- expect(target).to match /\.svg/
168
- expect(File.exists?(target)).to be true
203
+ expect(target).to match(/\.svg/)
204
+ expect(File.exist?(target)).to be true
169
205
 
170
206
  expect(b.attributes['width']).to_not be_nil
171
207
  expect(b.attributes['height']).to_not be_nil
@@ -190,7 +226,7 @@ User --> (Use the application) : Label
190
226
  d = load_asciidoc doc
191
227
  expect(d).to_not be_nil
192
228
 
193
- b = d.find { |b| b.context == :literal }
229
+ b = d.find { |bl| bl.context == :literal }
194
230
  expect(b).to_not be_nil
195
231
 
196
232
  expect(b.content_model).to eq :verbatim
@@ -210,7 +246,7 @@ Doc Writer <doc@example.com>
210
246
  ----
211
247
  eos
212
248
 
213
- expect { load_asciidoc doc }.to raise_error /support.*format/i
249
+ expect { load_asciidoc doc }.to raise_error(/support.*format/i)
214
250
  end
215
251
 
216
252
  it 'should use plantuml configuration when specified as a document attribute' do
@@ -238,14 +274,14 @@ ArrowColor #DEADBE
238
274
  end
239
275
 
240
276
  d = load_asciidoc doc
241
- b = d.find { |b| b.context == :image }
277
+ b = d.find { |bl| bl.context == :image }
242
278
 
243
279
  target = b.attributes['target']
244
280
  expect(target).to_not be_nil
245
- expect(File.exists?(target)).to be true
281
+ expect(File.exist?(target)).to be true
246
282
 
247
283
  svg = File.read(target)
248
- expect(svg).to match /<path.*fill="#DEADBE"/
284
+ expect(svg).to match(/<path.*fill="#DEADBE"/)
249
285
  end
250
286
 
251
287
  it 'should not regenerate images when source has not changed' do
@@ -275,7 +311,7 @@ Foo1 -> Foo2 : To boundary
275
311
  eos
276
312
 
277
313
  d = load_asciidoc doc
278
- b = d.find { |b| b.context == :image }
314
+ b = d.find { |bl| bl.context == :image }
279
315
  target = b.attributes['target']
280
316
  mtime1 = File.mtime(target)
281
317
 
@@ -309,7 +345,7 @@ plantuml::plantuml.txt[]
309
345
  eos
310
346
 
311
347
  load_asciidoc doc
312
- expect(File.exists?('plantuml.png')).to be true
348
+ expect(File.exist?('plantuml.png')).to be true
313
349
  end
314
350
 
315
351
  it 'should respect target attribute in block macros' do
@@ -333,9 +369,9 @@ plantuml::plantuml.txt["foobaz"]
333
369
  eos
334
370
 
335
371
  load_asciidoc doc
336
- expect(File.exists?('foobar.png')).to be true
337
- expect(File.exists?('foobaz.png')).to be true
338
- expect(File.exists?('plantuml.png')).to be false
372
+ expect(File.exist?('foobar.png')).to be true
373
+ expect(File.exist?('foobaz.png')).to be true
374
+ expect(File.exist?('plantuml.png')).to be false
339
375
  end
340
376
 
341
377
  it 'should respect target attribute values with relative paths in block macros' do
@@ -359,9 +395,9 @@ plantuml::plantuml.txt["test2/foobaz"]
359
395
  eos
360
396
 
361
397
  load_asciidoc doc
362
- expect(File.exists?('test/foobar.png')).to be true
363
- expect(File.exists?('test2/foobaz.png')).to be true
364
- expect(File.exists?('plantuml.png')).to be false
398
+ expect(File.exist?('test/foobar.png')).to be true
399
+ expect(File.exist?('test2/foobaz.png')).to be true
400
+ expect(File.exist?('plantuml.png')).to be false
365
401
  end
366
402
 
367
403
  it 'should write files to outdir if set' do
@@ -380,12 +416,12 @@ Foo1 -> Foo2 : To boundary
380
416
  eos
381
417
 
382
418
  d = load_asciidoc doc, {:attributes => {'outdir' => 'foo'}}
383
- b = d.find { |b| b.context == :image }
419
+ b = d.find { |bl| bl.context == :image }
384
420
 
385
421
  target = b.attributes['target']
386
422
  expect(target).to_not be_nil
387
- expect(File.exists?(target)).to be false
388
- expect(File.exists?(File.expand_path(target, 'foo'))).to be true
423
+ expect(File.exist?(target)).to be false
424
+ expect(File.exist?(File.expand_path(target, 'foo'))).to be true
389
425
  end
390
426
 
391
427
  it 'should write files to imagesoutdir if set' do
@@ -404,13 +440,13 @@ Foo1 -> Foo2 : To boundary
404
440
  eos
405
441
 
406
442
  d = load_asciidoc doc, {:attributes => {'imagesoutdir' => 'bar', 'outdir' => 'foo'}}
407
- b = d.find { |b| b.context == :image }
443
+ b = d.find { |bl| bl.context == :image }
408
444
 
409
445
  target = b.attributes['target']
410
446
  expect(target).to_not be_nil
411
- expect(File.exists?(target)).to be false
412
- expect(File.exists?(File.expand_path(target, 'bar'))).to be true
413
- expect(File.exists?(File.expand_path(target, 'foo'))).to be false
447
+ expect(File.exist?(target)).to be false
448
+ expect(File.exist?(File.expand_path(target, 'bar'))).to be true
449
+ expect(File.exist?(File.expand_path(target, 'foo'))).to be false
414
450
  end
415
451
 
416
452
  it 'should omit width/height attributes when generating docbook' do
@@ -429,11 +465,11 @@ User -> (Start)
429
465
  d = load_asciidoc doc, :attributes => {'backend' => 'docbook5'}
430
466
  expect(d).to_not be_nil
431
467
 
432
- b = d.find { |b| b.context == :image }
468
+ b = d.find { |bl| bl.context == :image }
433
469
  expect(b).to_not be_nil
434
470
 
435
471
  target = b.attributes['target']
436
- expect(File.exists?(target)).to be true
472
+ expect(File.exist?(target)).to be true
437
473
 
438
474
  expect(b.attributes['width']).to be_nil
439
475
  expect(b.attributes['height']).to be_nil
@@ -464,11 +500,11 @@ Doc Writer <doc@example.com>
464
500
  d = load_asciidoc doc, :attributes => {'backend' => 'docbook5'}
465
501
  expect(d).to_not be_nil
466
502
 
467
- b = d.find { |b| b.context == :image }
503
+ b = d.find { |bl| bl.context == :image }
468
504
  expect(b).to_not be_nil
469
505
 
470
506
  target = b.attributes['target']
471
- expect(File.exists?(target)).to be true
507
+ expect(File.exist?(target)).to be true
472
508
 
473
509
  expect(b.attributes['width']).to be_nil
474
510
  expect(b.attributes['height']).to be_nil
@@ -500,11 +536,11 @@ salt
500
536
  d = load_asciidoc doc, :attributes => {'backend' => 'docbook5'}
501
537
  expect(d).to_not be_nil
502
538
 
503
- b = d.find { |b| b.context == :image }
539
+ b = d.find { |bl| bl.context == :image }
504
540
  expect(b).to_not be_nil
505
541
 
506
542
  target = b.attributes['target']
507
- expect(File.exists?(target)).to be true
543
+ expect(File.exist?(target)).to be true
508
544
 
509
545
  expect(b.attributes['width']).to be_nil
510
546
  expect(b.attributes['height']).to be_nil
@@ -532,11 +568,11 @@ salt
532
568
  d = load_asciidoc doc, :attributes => {'backend' => 'docbook5'}
533
569
  expect(d).to_not be_nil
534
570
 
535
- b = d.find { |b| b.context == :image }
571
+ b = d.find { |bl| bl.context == :image }
536
572
  expect(b).to_not be_nil
537
573
 
538
574
  target = b.attributes['target']
539
- expect(File.exists?(target)).to be true
575
+ expect(File.exist?(target)).to be true
540
576
 
541
577
  expect(b.attributes['width']).to be_nil
542
578
  expect(b.attributes['height']).to be_nil
@@ -568,10 +604,10 @@ A -> B
568
604
  eos
569
605
 
570
606
  d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
571
- unscaled_image = d.find { |b| b.context == :image }
607
+ unscaled_image = d.find { |bl| bl.context == :image }
572
608
 
573
609
  d = load_asciidoc scaled_doc, :attributes => {'backend' => 'html5'}
574
- scaled_image = d.find { |b| b.context == :image }
610
+ scaled_image = d.find { |bl| bl.context == :image }
575
611
 
576
612
  expect(scaled_image.attributes['width']).to be_within(1).of(unscaled_image.attributes['width'] * 1.5)
577
613
  expect(scaled_image.attributes['height']).to be_within(1).of(unscaled_image.attributes['height'] * 1.5)
@@ -649,11 +685,11 @@ class {child-class}
649
685
  d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
650
686
  expect(d).to_not be_nil
651
687
 
652
- b = d.find { |b| b.context == :image }
688
+ b = d.find { |bl| bl.context == :image }
653
689
  expect(b).to_not be_nil
654
690
 
655
691
  target = b.attributes['target']
656
- expect(File.exists?(target)).to be true
692
+ expect(File.exist?(target)).to be true
657
693
 
658
694
  content = File.read(target)
659
695
  expect(content).to include('ParentClass')