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.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +12 -0
- data/README.adoc +4 -1
- data/lib/asciidoctor-diagram.rb +1 -0
- data/lib/asciidoctor-diagram/blockdiag/extension.rb +5 -4
- data/lib/asciidoctor-diagram/erd.rb +7 -0
- data/lib/asciidoctor-diagram/erd/extension.rb +43 -0
- data/lib/asciidoctor-diagram/extensions.rb +9 -5
- data/lib/asciidoctor-diagram/graphviz/extension.rb +2 -1
- data/lib/asciidoctor-diagram/meme/extension.rb +4 -4
- data/lib/asciidoctor-diagram/mermaid/extension.rb +4 -2
- data/lib/asciidoctor-diagram/plantuml/extension.rb +1 -1
- data/lib/asciidoctor-diagram/shaape/extension.rb +2 -1
- data/lib/asciidoctor-diagram/util/cli.rb +19 -0
- data/lib/asciidoctor-diagram/util/cli_generator.rb +5 -15
- data/lib/asciidoctor-diagram/util/java.rb +1 -1
- data/lib/asciidoctor-diagram/util/java_socket.rb +96 -28
- data/lib/asciidoctor-diagram/util/platform.rb +35 -14
- data/lib/asciidoctor-diagram/version.rb +1 -1
- data/lib/asciidoctor-diagram/wavedrom/extension.rb +3 -2
- data/spec/blockdiag_spec.rb +15 -15
- data/spec/ditaa_spec.rb +14 -14
- data/spec/erd_spec.rb +289 -0
- data/spec/graphviz_spec.rb +12 -12
- data/spec/meme_spec.rb +6 -6
- data/spec/mermaid_spec.rb +22 -22
- data/spec/plantuml_spec.rb +78 -42
- data/spec/shaape_spec.rb +15 -15
- data/spec/test_helper.rb +8 -3
- data/spec/wavedrom_spec.rb +18 -18
- metadata +8 -4
@@ -4,31 +4,52 @@ module Asciidoctor
|
|
4
4
|
module Diagram
|
5
5
|
module Platform
|
6
6
|
def self.os
|
7
|
+
os_info[:os]
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.os_variant
|
11
|
+
os_info[:os_variant]
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.path_separator
|
15
|
+
os_info[:path_sep]
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.os_info
|
7
19
|
@os ||= (
|
8
20
|
host_os = RbConfig::CONFIG['host_os']
|
21
|
+
|
22
|
+
path_sep = '/'
|
23
|
+
variant = nil
|
9
24
|
case host_os
|
10
|
-
when /mswin|
|
11
|
-
:windows
|
12
|
-
|
13
|
-
|
14
|
-
when /
|
15
|
-
:
|
16
|
-
|
17
|
-
|
25
|
+
when /(mswin|bccwin|wince|emc)/i
|
26
|
+
os = :windows
|
27
|
+
variant = $1.downcase.to_sym
|
28
|
+
path_sep = '\\'
|
29
|
+
when /(msys|mingw|cygwin)/i
|
30
|
+
os = :windows
|
31
|
+
variant = $1.downcase.to_sym
|
32
|
+
when /darwin|mac os/i
|
33
|
+
os = :macosx
|
34
|
+
when /linux/i
|
35
|
+
os = :linux
|
18
36
|
else
|
19
|
-
|
37
|
+
os = :unix
|
20
38
|
end
|
39
|
+
{
|
40
|
+
:os => os, :os_variant => variant || os, :path_sep => path_sep
|
41
|
+
}
|
21
42
|
)
|
22
43
|
end
|
23
44
|
|
24
45
|
def self.native_path(path)
|
25
46
|
return path if path.nil?
|
26
47
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
48
|
+
path_sep = path_separator
|
49
|
+
if path_sep != '/'
|
50
|
+
path.to_s.gsub('/', path_sep)
|
51
|
+
else
|
52
|
+
path.to_s
|
32
53
|
end
|
33
54
|
end
|
34
55
|
end
|
@@ -7,6 +7,7 @@ module Asciidoctor
|
|
7
7
|
module Diagram
|
8
8
|
# @private
|
9
9
|
module Wavedrom
|
10
|
+
include CliGenerator
|
10
11
|
include Which
|
11
12
|
|
12
13
|
def self.included(mod)
|
@@ -22,7 +23,7 @@ module Asciidoctor
|
|
22
23
|
phantomjs = which(parent, 'phantomjs', :alt_attrs => ['phantomjs_2'], :raise_on_error => false)
|
23
24
|
|
24
25
|
if wavedrom_cli && !wavedrom_cli.include?('WaveDromEditor') && phantomjs
|
25
|
-
|
26
|
+
generate_file(wavedrom_cli, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
|
26
27
|
[phantomjs, Platform.native_path(tool_path), '-i', Platform.native_path(input_path), "-#{format.to_s[0]}", Platform.native_path(output_path)]
|
27
28
|
end
|
28
29
|
else
|
@@ -35,7 +36,7 @@ module Asciidoctor
|
|
35
36
|
wavedrom = which(parent, 'WaveDromEditor', :alt_attrs => ['wavedrom'])
|
36
37
|
end
|
37
38
|
|
38
|
-
|
39
|
+
generate_file(wavedrom, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
|
39
40
|
[tool_path, 'source', Platform.native_path(input_path), format.to_s, Platform.native_path(output_path)]
|
40
41
|
end
|
41
42
|
end
|
data/spec/blockdiag_spec.rb
CHANGED
@@ -23,15 +23,15 @@ blockdiag::blockdiag.txt[format="png"]
|
|
23
23
|
d = load_asciidoc doc
|
24
24
|
expect(d).to_not be_nil
|
25
25
|
|
26
|
-
b = d.find { |
|
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
|
34
|
-
expect(File.
|
33
|
+
expect(target).to match(/\.png$/)
|
34
|
+
expect(File.exist?(target)).to be true
|
35
35
|
|
36
36
|
expect(b.attributes['width']).to_not be_nil
|
37
37
|
expect(b.attributes['height']).to_not be_nil
|
@@ -55,15 +55,15 @@ Doc Writer <doc@example.com>
|
|
55
55
|
d = load_asciidoc doc
|
56
56
|
expect(d).to_not be_nil
|
57
57
|
|
58
|
-
b = d.find { |
|
58
|
+
b = d.find { |bl| bl.context == :image }
|
59
59
|
expect(b).to_not be_nil
|
60
60
|
|
61
61
|
expect(b.content_model).to eq :empty
|
62
62
|
|
63
63
|
target = b.attributes['target']
|
64
64
|
expect(target).to_not be_nil
|
65
|
-
expect(target).to match
|
66
|
-
expect(File.
|
65
|
+
expect(target).to match(/\.png$/)
|
66
|
+
expect(File.exist?(target)).to be true
|
67
67
|
|
68
68
|
expect(b.attributes['width']).to_not be_nil
|
69
69
|
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 { |
|
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
|
96
|
-
expect(File.
|
95
|
+
expect(target).to match(/\.svg/)
|
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
|
@@ -111,7 +111,7 @@ Doc Writer <doc@example.com>
|
|
111
111
|
----
|
112
112
|
eos
|
113
113
|
|
114
|
-
expect { load_asciidoc doc }.to raise_error
|
114
|
+
expect { load_asciidoc doc }.to raise_error(/support.*format/i)
|
115
115
|
end
|
116
116
|
|
117
117
|
it "should not regenerate images when source has not changed" do
|
@@ -132,7 +132,7 @@ blockdiag::blockdiag.txt
|
|
132
132
|
eos
|
133
133
|
|
134
134
|
d = load_asciidoc doc
|
135
|
-
b = d.find { |
|
135
|
+
b = d.find { |bl| bl.context == :image }
|
136
136
|
expect(b).to_not be_nil
|
137
137
|
target = b.attributes['target']
|
138
138
|
mtime1 = File.mtime(target)
|
@@ -160,7 +160,7 @@ blockdiag::blockdiag.txt[]
|
|
160
160
|
eos
|
161
161
|
|
162
162
|
load_asciidoc doc
|
163
|
-
expect(File.
|
163
|
+
expect(File.exist?('blockdiag.png')).to be true
|
164
164
|
end
|
165
165
|
|
166
166
|
it "should respect target attribute in block macros" do
|
@@ -177,8 +177,8 @@ blockdiag::blockdiag.txt["foobaz"]
|
|
177
177
|
eos
|
178
178
|
|
179
179
|
load_asciidoc doc
|
180
|
-
expect(File.
|
181
|
-
expect(File.
|
182
|
-
expect(File.
|
180
|
+
expect(File.exist?('foobar.png')).to be true
|
181
|
+
expect(File.exist?('foobaz.png')).to be true
|
182
|
+
expect(File.exist?('blockdiag.png')).to be false
|
183
183
|
end
|
184
184
|
end
|
data/spec/ditaa_spec.rb
CHANGED
@@ -28,15 +28,15 @@ ditaa::ditaa.txt[format="png"]
|
|
28
28
|
d = load_asciidoc doc
|
29
29
|
expect(d).to_not be_nil
|
30
30
|
|
31
|
-
b = d.find { |
|
31
|
+
b = d.find { |bl| bl.context == :image }
|
32
32
|
expect(b).to_not be_nil
|
33
33
|
|
34
34
|
expect(b.content_model).to eq :empty
|
35
35
|
|
36
36
|
target = b.attributes['target']
|
37
37
|
expect(target).to_not be_nil
|
38
|
-
expect(target).to match
|
39
|
-
expect(File.
|
38
|
+
expect(target).to match(/\.png$/)
|
39
|
+
expect(File.exist?(target)).to be true
|
40
40
|
|
41
41
|
expect(b.attributes['width']).to_not be_nil
|
42
42
|
expect(b.attributes['height']).to_not be_nil
|
@@ -68,15 +68,15 @@ Doc Writer <doc@example.com>
|
|
68
68
|
d = load_asciidoc doc
|
69
69
|
expect(d).to_not be_nil
|
70
70
|
|
71
|
-
b = d.find { |
|
71
|
+
b = d.find { |bl| bl.context == :image }
|
72
72
|
expect(b).to_not be_nil
|
73
73
|
|
74
74
|
expect(b.content_model).to eq :empty
|
75
75
|
|
76
76
|
target = b.attributes['target']
|
77
77
|
expect(target).to_not be_nil
|
78
|
-
expect(target).to match
|
79
|
-
expect(File.
|
78
|
+
expect(target).to match(/\.png$/)
|
79
|
+
expect(File.exist?(target)).to be true
|
80
80
|
|
81
81
|
expect(b.attributes['width']).to_not be_nil
|
82
82
|
expect(b.attributes['height']).to_not be_nil
|
@@ -94,7 +94,7 @@ Doc Writer <doc@example.com>
|
|
94
94
|
----
|
95
95
|
eos
|
96
96
|
|
97
|
-
expect { load_asciidoc doc }.to raise_error
|
97
|
+
expect { load_asciidoc doc }.to raise_error(/support.*format/i)
|
98
98
|
end
|
99
99
|
|
100
100
|
it "should use a default format when none was given" do
|
@@ -112,11 +112,11 @@ Doc Writer <doc@example.com>
|
|
112
112
|
d = load_asciidoc doc
|
113
113
|
expect(d).to_not be_nil
|
114
114
|
|
115
|
-
b = d.find { |
|
115
|
+
b = d.find { |bl| bl.context == :image }
|
116
116
|
expect(b).to_not be_nil
|
117
117
|
target = b.attributes['target']
|
118
|
-
expect(target).to match
|
119
|
-
expect(File.
|
118
|
+
expect(target).to match(/\.png$/)
|
119
|
+
expect(File.exist?(target)).to be true
|
120
120
|
end
|
121
121
|
|
122
122
|
it "should support ditaa options as attributes" do
|
@@ -145,11 +145,11 @@ Doc Writer <doc@example.com>
|
|
145
145
|
d = load_asciidoc doc
|
146
146
|
expect(d).to_not be_nil
|
147
147
|
|
148
|
-
b = d.find { |
|
148
|
+
b = d.find { |bl| bl.context == :image }
|
149
149
|
expect(b).to_not be_nil
|
150
150
|
target = b.attributes['target']
|
151
|
-
expect(target).to match
|
152
|
-
expect(File.
|
151
|
+
expect(target).to match(/\.png$/)
|
152
|
+
expect(File.exist?(target)).to be true
|
153
153
|
end
|
154
154
|
|
155
155
|
it "should regenerate images when options change" do
|
@@ -174,7 +174,7 @@ Doc Writer <doc@example.com>
|
|
174
174
|
eos
|
175
175
|
|
176
176
|
d = load_asciidoc(doc.sub('{opts}', 'shadow=false'))
|
177
|
-
b = d.find { |
|
177
|
+
b = d.find { |bl| bl.context == :image }
|
178
178
|
target = b.attributes['target']
|
179
179
|
mtime1 = File.mtime(target)
|
180
180
|
|
data/spec/erd_spec.rb
ADDED
@@ -0,0 +1,289 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
code = <<-eos
|
4
|
+
title {label: "nfldb Entity-Relationship diagram (condensed)", size: "20"}
|
5
|
+
|
6
|
+
# Entities
|
7
|
+
|
8
|
+
[player] {bgcolor: "#d0e0d0"}
|
9
|
+
*player_id {label: "varchar, not null"}
|
10
|
+
full_name {label: "varchar, null"}
|
11
|
+
team {label: "varchar, not null"}
|
12
|
+
position {label: "player_pos, not null"}
|
13
|
+
status {label: "player_status, not null"}
|
14
|
+
|
15
|
+
[team] {bgcolor: "#d0e0d0"}
|
16
|
+
*team_id {label: "varchar, not null"}
|
17
|
+
city {label: "varchar, not null"}
|
18
|
+
name {label: "varchar, not null"}
|
19
|
+
|
20
|
+
[game] {bgcolor: "#ececfc"}
|
21
|
+
*gsis_id {label: "gameid, not null"}
|
22
|
+
start_time {label: "utctime, not null"}
|
23
|
+
week {label: "usmallint, not null"}
|
24
|
+
season_year {label: "usmallint, not null"}
|
25
|
+
season_type {label: "season_phase, not null"}
|
26
|
+
finished {label: "boolean, not null"}
|
27
|
+
home_team {label: "varchar, not null"}
|
28
|
+
home_score {label: "usmallint, not null"}
|
29
|
+
away_team {label: "varchar, not null"}
|
30
|
+
away_score {label: "usmallint, not null"}
|
31
|
+
|
32
|
+
[drive] {bgcolor: "#ececfc"}
|
33
|
+
*+gsis_id {label: "gameid, not null"}
|
34
|
+
*drive_id {label: "usmallint, not null"}
|
35
|
+
start_field {label: "field_pos, null"}
|
36
|
+
start_time {label: "game_time, not null"}
|
37
|
+
end_field {label: "field_pos, null"}
|
38
|
+
end_time {label: "game_time, not null"}
|
39
|
+
pos_team {label: "varchar, not null"}
|
40
|
+
pos_time {label: "pos_period, null"}
|
41
|
+
|
42
|
+
[play] {bgcolor: "#ececfc"}
|
43
|
+
*+gsis_id {label: "gameid, not null"}
|
44
|
+
*+drive_id {label: "usmallint, not null"}
|
45
|
+
*play_id {label: "usmallint, not null"}
|
46
|
+
time {label: "game_time, not null"}
|
47
|
+
pos_team {label: "varchar, not null"}
|
48
|
+
yardline {label: "field_pos, null"}
|
49
|
+
down {label: "smallint, null"}
|
50
|
+
yards_to_go {label: "smallint, null"}
|
51
|
+
|
52
|
+
[play_player] {bgcolor: "#ececfc"}
|
53
|
+
*+gsis_id {label: "gameid, not null"}
|
54
|
+
*+drive_id {label: "usmallint, not null"}
|
55
|
+
*+play_id {label: "usmallint, not null"}
|
56
|
+
*+player_id {label: "varchar, not null"}
|
57
|
+
team {label: "varchar, not null"}
|
58
|
+
|
59
|
+
[meta] {bgcolor: "#fcecec"}
|
60
|
+
version {label: "smallint, null"}
|
61
|
+
season_type {label: "season_phase, null"}
|
62
|
+
season_year {label: "usmallint, null"}
|
63
|
+
week {label: "usmallint, null"}
|
64
|
+
|
65
|
+
# Relationships
|
66
|
+
|
67
|
+
player *--1 team
|
68
|
+
game *--1 team {label: "home"}
|
69
|
+
game *--1 team {label: "away"}
|
70
|
+
drive *--1 team
|
71
|
+
play *--1 team
|
72
|
+
play_player *--1 team
|
73
|
+
|
74
|
+
game 1--* drive
|
75
|
+
game 1--* play
|
76
|
+
game 1--* play_player
|
77
|
+
|
78
|
+
drive 1--* play
|
79
|
+
drive 1--* play_player
|
80
|
+
|
81
|
+
play 1--* play_player
|
82
|
+
|
83
|
+
player 1--* play_player
|
84
|
+
eos
|
85
|
+
|
86
|
+
describe Asciidoctor::Diagram::ErdBlockMacroProcessor, :broken_on_travis, :broken_on_windows do
|
87
|
+
it "should generate PNG images when format is set to 'png'" do
|
88
|
+
File.write('erd.txt', code)
|
89
|
+
|
90
|
+
doc = <<-eos
|
91
|
+
= Hello, Erd!
|
92
|
+
Doc Writer <doc@example.com>
|
93
|
+
|
94
|
+
== First Section
|
95
|
+
|
96
|
+
erd::erd.txt[format="png"]
|
97
|
+
eos
|
98
|
+
|
99
|
+
d = load_asciidoc doc
|
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
|
+
expect(b.content_model).to eq :empty
|
106
|
+
|
107
|
+
target = b.attributes['target']
|
108
|
+
expect(target).to_not be_nil
|
109
|
+
expect(target).to match(/\.png$/)
|
110
|
+
expect(File.exist?(target)).to be true
|
111
|
+
|
112
|
+
expect(b.attributes['width']).to_not be_nil
|
113
|
+
expect(b.attributes['height']).to_not be_nil
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should generate SVG images when format is set to 'svg'" do
|
117
|
+
File.write('erd.txt', code)
|
118
|
+
|
119
|
+
doc = <<-eos
|
120
|
+
= Hello, Erd!
|
121
|
+
Doc Writer <doc@example.com>
|
122
|
+
|
123
|
+
== First Section
|
124
|
+
|
125
|
+
erd::erd.txt[format="svg"]
|
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.content_model).to eq :empty
|
135
|
+
|
136
|
+
target = b.attributes['target']
|
137
|
+
expect(target).to_not be_nil
|
138
|
+
expect(target).to match(/\.svg/)
|
139
|
+
expect(File.exist?(target)).to be true
|
140
|
+
|
141
|
+
expect(b.attributes['width']).to_not be_nil
|
142
|
+
expect(b.attributes['height']).to_not be_nil
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe Asciidoctor::Diagram::ErdBlockProcessor, :broken_on_travis, :broken_on_windows do
|
147
|
+
it "should generate PNG images when format is set to 'png'" do
|
148
|
+
doc = <<-eos
|
149
|
+
= Hello, Erd!
|
150
|
+
Doc Writer <doc@example.com>
|
151
|
+
|
152
|
+
== First Section
|
153
|
+
|
154
|
+
[erd, format="png"]
|
155
|
+
----
|
156
|
+
#{code}
|
157
|
+
----
|
158
|
+
eos
|
159
|
+
|
160
|
+
d = load_asciidoc doc
|
161
|
+
expect(d).to_not be_nil
|
162
|
+
|
163
|
+
b = d.find { |bl| bl.context == :image }
|
164
|
+
expect(b).to_not be_nil
|
165
|
+
|
166
|
+
expect(b.content_model).to eq :empty
|
167
|
+
|
168
|
+
target = b.attributes['target']
|
169
|
+
expect(target).to_not be_nil
|
170
|
+
expect(target).to match(/\.png$/)
|
171
|
+
expect(File.exist?(target)).to be true
|
172
|
+
|
173
|
+
expect(b.attributes['width']).to_not be_nil
|
174
|
+
expect(b.attributes['height']).to_not be_nil
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should generate SVG images when format is set to 'svg'" do
|
178
|
+
doc = <<-eos
|
179
|
+
= Hello, Erd!
|
180
|
+
Doc Writer <doc@example.com>
|
181
|
+
|
182
|
+
== First Section
|
183
|
+
|
184
|
+
[erd, format="svg"]
|
185
|
+
----
|
186
|
+
#{code}
|
187
|
+
----
|
188
|
+
eos
|
189
|
+
|
190
|
+
d = load_asciidoc doc
|
191
|
+
expect(d).to_not be_nil
|
192
|
+
|
193
|
+
b = d.find { |bl| bl.context == :image }
|
194
|
+
expect(b).to_not be_nil
|
195
|
+
|
196
|
+
expect(b.content_model).to eq :empty
|
197
|
+
|
198
|
+
target = b.attributes['target']
|
199
|
+
expect(target).to_not be_nil
|
200
|
+
expect(target).to match(/\.svg/)
|
201
|
+
expect(File.exist?(target)).to be true
|
202
|
+
|
203
|
+
expect(b.attributes['width']).to_not be_nil
|
204
|
+
expect(b.attributes['height']).to_not be_nil
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should raise an error when when format is set to an invalid value" do
|
208
|
+
doc = <<-eos
|
209
|
+
= Hello, Erd!
|
210
|
+
Doc Writer <doc@example.com>
|
211
|
+
|
212
|
+
== First Section
|
213
|
+
|
214
|
+
[erd, format="foobar"]
|
215
|
+
----
|
216
|
+
----
|
217
|
+
eos
|
218
|
+
|
219
|
+
expect { load_asciidoc doc }.to raise_error(/support.*format/i)
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should not regenerate images when source has not changed" do
|
223
|
+
File.write('erd.txt', code)
|
224
|
+
|
225
|
+
doc = <<-eos
|
226
|
+
= Hello, Erd!
|
227
|
+
Doc Writer <doc@example.com>
|
228
|
+
|
229
|
+
== First Section
|
230
|
+
|
231
|
+
erd::erd.txt
|
232
|
+
|
233
|
+
[erd, format="png"]
|
234
|
+
----
|
235
|
+
#{code}
|
236
|
+
----
|
237
|
+
eos
|
238
|
+
|
239
|
+
d = load_asciidoc doc
|
240
|
+
b = d.find { |bl| bl.context == :image }
|
241
|
+
expect(b).to_not be_nil
|
242
|
+
target = b.attributes['target']
|
243
|
+
mtime1 = File.mtime(target)
|
244
|
+
|
245
|
+
sleep 1
|
246
|
+
|
247
|
+
d = load_asciidoc doc
|
248
|
+
|
249
|
+
mtime2 = File.mtime(target)
|
250
|
+
|
251
|
+
expect(mtime2).to eq mtime1
|
252
|
+
end
|
253
|
+
|
254
|
+
it "should handle two block macros with the same source" do
|
255
|
+
File.write('erd.txt', code)
|
256
|
+
|
257
|
+
doc = <<-eos
|
258
|
+
= Hello, Erd!
|
259
|
+
Doc Writer <doc@example.com>
|
260
|
+
|
261
|
+
== First Section
|
262
|
+
|
263
|
+
erd::erd.txt[]
|
264
|
+
erd::erd.txt[]
|
265
|
+
eos
|
266
|
+
|
267
|
+
load_asciidoc doc
|
268
|
+
expect(File.exist?('erd.png')).to be true
|
269
|
+
end
|
270
|
+
|
271
|
+
it "should respect target attribute in block macros" do
|
272
|
+
File.write('erd.txt', code)
|
273
|
+
|
274
|
+
doc = <<-eos
|
275
|
+
= Hello, Erd!
|
276
|
+
Doc Writer <doc@example.com>
|
277
|
+
|
278
|
+
== First Section
|
279
|
+
|
280
|
+
erd::erd.txt["foobar"]
|
281
|
+
erd::erd.txt["foobaz"]
|
282
|
+
eos
|
283
|
+
|
284
|
+
load_asciidoc doc
|
285
|
+
expect(File.exist?('foobar.png')).to be true
|
286
|
+
expect(File.exist?('foobaz.png')).to be true
|
287
|
+
expect(File.exist?('erd.png')).to be false
|
288
|
+
end
|
289
|
+
end
|