asciidoctor-diagram 1.1.6 → 1.2.0.preview.1

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.
@@ -31,10 +31,6 @@ module Asciidoctor
31
31
  load
32
32
  ::Java.send(meth)
33
33
  end
34
-
35
- def self.new_object(java_class, signature = nil, *args)
36
- java_class.new(*args)
37
- end
38
34
  end
39
35
  end
40
36
  end
@@ -77,14 +77,6 @@ module Asciidoctor
77
77
  @root_package ||= Package.send(:create_package, nil)
78
78
  @root_package.send(meth, *args)
79
79
  end
80
-
81
- def self.new_object(java_class, signature = nil, *args)
82
- if signature
83
- java_class.new_with_sig(signature, *args)
84
- else
85
- java_class.new(*args)
86
- end
87
- end
88
80
  end
89
81
  end
90
82
  end
@@ -4,30 +4,34 @@ module Asciidoctor
4
4
  module Diagram
5
5
  module SVG
6
6
  def self.get_image_size(data)
7
- if m = START_TAG_REGEX.match(data)
8
- start_tag = m[0]
9
- if (w = WIDTH_REGEX.match(start_tag)) && (h = HEIGHT_REGEX.match(start_tag))
10
- width = w[:value].to_i * to_px_factor(w[:unit])
11
- height = h[:value].to_i * to_px_factor(h[:unit])
12
- return [width.to_i, height.to_i]
13
- end
7
+ get_from_style(data) || get_from_viewport(data)
8
+ end
14
9
 
15
- if v = VIEWBOX_REGEX.match(start_tag)
16
- width = v[:width]
17
- height = v[:height]
18
- return [width.to_i, height.to_i]
19
- end
20
- end
10
+ private
11
+
12
+ SVG_STYLE_REGEX = /style\s*=\s*"width:(?<width>\d+)px;height:(?<height>\d+)px/
21
13
 
22
- nil
14
+ def self.get_from_style(data)
15
+ match_data = SVG_STYLE_REGEX.match(data)
16
+ if match_data
17
+ [match_data[:width].to_i, match_data[:height].to_i]
18
+ else
19
+ nil
20
+ end
23
21
  end
24
22
 
25
- private
23
+ SVG_VIEWPORT_REGEX = /<svg width="(?<width>\d+)(?<width_unit>[a-zA-Z]+)" height="(?<height>\d+)(?<height_unit>[a-zA-Z]+)"/
26
24
 
27
- START_TAG_REGEX = /<svg[^>]*>/
28
- WIDTH_REGEX = /width="(?<value>\d+)(?<unit>[a-zA-Z]+)"/
29
- HEIGHT_REGEX = /height="(?<value>\d+)(?<unit>[a-zA-Z]+)"/
30
- VIEWBOX_REGEX = /viewBox="\d+ \d+ (?<width>\d+) (?<height>\d+)"/
25
+ def self.get_from_viewport(data)
26
+ match_data = SVG_VIEWPORT_REGEX.match(data)
27
+ if match_data
28
+ width = match_data[:width].to_i * to_px_factor(match_data[:width_unit])
29
+ height = match_data[:height].to_i * to_px_factor(match_data[:height_unit])
30
+ [width.to_i, height.to_i]
31
+ else
32
+ nil
33
+ end
34
+ end
31
35
 
32
36
  def self.to_px_factor(unit)
33
37
  case unit
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Diagram
3
- VERSION = "1.1.6"
3
+ VERSION = "1.2.0.preview.1"
4
4
  end
5
5
  end
data/lib/plantuml.jar CHANGED
Binary file
data/spec/ditaa_spec.rb CHANGED
@@ -36,7 +36,7 @@ ditaa::ditaa.txt[format="png"]
36
36
  target = b.attributes['target']
37
37
  expect(target).to_not be_nil
38
38
  expect(target).to match /\.png$/
39
- expect(File.exists?(target)).to be true
39
+ expect(File.exists?(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
@@ -76,7 +76,7 @@ Doc Writer <doc@example.com>
76
76
  target = b.attributes['target']
77
77
  expect(target).to_not be_nil
78
78
  expect(target).to match /\.png$/
79
- expect(File.exists?(target)).to be true
79
+ expect(File.exists?(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
@@ -116,6 +116,6 @@ Doc Writer <doc@example.com>
116
116
  expect(b).to_not be_nil
117
117
  target = b.attributes['target']
118
118
  expect(target).to match /\.png$/
119
- expect(File.exists?(target)).to be true
119
+ expect(File.exists?(target)).to be_true
120
120
  end
121
121
  end
@@ -35,7 +35,7 @@ graphviz::graphviz.txt[format="png"]
35
35
  target = b.attributes['target']
36
36
  expect(target).to_not be_nil
37
37
  expect(target).to match /\.png$/
38
- expect(File.exists?(target)).to be true
38
+ expect(File.exists?(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
@@ -74,7 +74,7 @@ digraph foo {
74
74
  target = b.attributes['target']
75
75
  expect(target).to_not be_nil
76
76
  expect(target).to match /\.png$/
77
- expect(File.exists?(target)).to be true
77
+ expect(File.exists?(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
@@ -111,7 +111,7 @@ digraph foo {
111
111
  target = b.attributes['target']
112
112
  expect(target).to_not be_nil
113
113
  expect(target).to match /\.svg$/
114
- expect(File.exists?(target)).to be true
114
+ expect(File.exists?(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
@@ -131,29 +131,4 @@ Doc Writer <doc@example.com>
131
131
 
132
132
  expect { Asciidoctor.load StringIO.new(doc) }.to raise_error /support.*format/i
133
133
  end
134
-
135
- it "should support single line digraphs" do
136
- doc = <<-eos
137
- = Hello, graphviz!
138
- Doc Writer <doc@example.com>
139
-
140
- == First Section
141
-
142
- [graphviz]
143
- ----
144
- digraph g { rankdir=LR; Text->Graphviz->Image }
145
- ----
146
- eos
147
-
148
- d = Asciidoctor.load StringIO.new(doc)
149
- expect(d).to_not be_nil
150
-
151
- b = d.find { |b| b.context == :image }
152
- expect(b).to_not be_nil
153
-
154
- expect(b.content_model).to eq :empty
155
-
156
- target = b.attributes['target']
157
- expect(File.exists?(target)).to be true
158
- end
159
134
  end
@@ -31,7 +31,7 @@ plantuml::plantuml.txt[format="png"]
31
31
  target = b.attributes['target']
32
32
  expect(target).to_not be_nil
33
33
  expect(target).to match /\.png$/
34
- expect(File.exists?(target)).to be true
34
+ expect(File.exists?(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
@@ -66,7 +66,7 @@ User --> (Use the application) : Label
66
66
  target = b.attributes['target']
67
67
  expect(target).to_not be_nil
68
68
  expect(target).to match /\.png$/
69
- expect(File.exists?(target)).to be true
69
+ expect(File.exists?(target)).to be_true
70
70
 
71
71
  expect(b.attributes['width']).to_not be_nil
72
72
  expect(b.attributes['height']).to_not be_nil
@@ -99,7 +99,7 @@ User --> (Use the application) : Label
99
99
  target = b.attributes['target']
100
100
  expect(target).to_not be_nil
101
101
  expect(target).to match /\.svg/
102
- expect(File.exists?(target)).to be true
102
+ expect(File.exists?(target)).to be_true
103
103
 
104
104
  expect(b.attributes['width']).to_not be_nil
105
105
  expect(b.attributes['height']).to_not be_nil
@@ -127,7 +127,7 @@ User --> (Use the application) : Label
127
127
  b = d.find { |b| b.context == :literal }
128
128
  expect(b).to_not be_nil
129
129
 
130
- expect(b.content_model).to eq :simple
130
+ expect(b.content_model).to eq :verbatim
131
131
 
132
132
  expect(b.attributes['target']).to be_nil
133
133
  end
@@ -176,150 +176,9 @@ ArrowColor #DEADBE
176
176
 
177
177
  target = b.attributes['target']
178
178
  expect(target).to_not be_nil
179
- expect(File.exists?(target)).to be true
179
+ expect(File.exists?(target)).to be_true
180
180
 
181
181
  svg = File.read(target)
182
182
  expect(svg).to match /<path.*fill="#DEADBE"/
183
183
  end
184
-
185
- it "should not regenerate images when source has not changed" do
186
- code = <<-eos
187
- User -> (Start)
188
- User --> (Use the application) : Label
189
-
190
- :Main Admin: ---> (Use the application) : Another label
191
- eos
192
-
193
- File.write('plantuml.txt', code)
194
-
195
- doc = <<-eos
196
- = Hello, PlantUML!
197
- Doc Writer <doc@example.com>
198
-
199
- == First Section
200
-
201
- plantuml::plantuml.txt
202
-
203
- [plantuml, format="png"]
204
- ----
205
- actor Foo1
206
- boundary Foo2
207
- Foo1 -> Foo2 : To boundary
208
- ----
209
- eos
210
-
211
- d = Asciidoctor.load StringIO.new(doc)
212
- b = d.find { |b| b.context == :image }
213
- target = b.attributes['target']
214
- mtime1 = File.mtime(target)
215
-
216
- sleep 1
217
-
218
- d = Asciidoctor.load StringIO.new(doc)
219
-
220
- mtime2 = File.mtime(target)
221
-
222
- expect(mtime2).to eq mtime1
223
- end
224
-
225
- it "should handle two block macros with the same source" do
226
- code = <<-eos
227
- User -> (Start)
228
- User --> (Use the application) : Label
229
-
230
- :Main Admin: ---> (Use the application) : Another label
231
- eos
232
-
233
- File.write('plantuml.txt', code)
234
-
235
- doc = <<-eos
236
- = Hello, PlantUML!
237
- Doc Writer <doc@example.com>
238
-
239
- == First Section
240
-
241
- plantuml::plantuml.txt[]
242
- plantuml::plantuml.txt[]
243
- eos
244
-
245
- Asciidoctor.load StringIO.new(doc)
246
- expect(File.exists?('plantuml.png')).to be true
247
- end
248
-
249
- it "should respect target attribute in block macros" do
250
- code = <<-eos
251
- User -> (Start)
252
- User --> (Use the application) : Label
253
-
254
- :Main Admin: ---> (Use the application) : Another label
255
- eos
256
-
257
- File.write('plantuml.txt', code)
258
-
259
- doc = <<-eos
260
- = Hello, PlantUML!
261
- Doc Writer <doc@example.com>
262
-
263
- == First Section
264
-
265
- plantuml::plantuml.txt["foobar"]
266
- plantuml::plantuml.txt["foobaz"]
267
- eos
268
-
269
- Asciidoctor.load StringIO.new(doc)
270
- expect(File.exists?('foobar.png')).to be true
271
- expect(File.exists?('foobaz.png')).to be true
272
- expect(File.exists?('plantuml.png')).to be false
273
- end
274
-
275
-
276
- it "should write files to outdir if set" do
277
- doc = <<-eos
278
- = Hello, PlantUML!
279
- Doc Writer <doc@example.com>
280
-
281
- == First Section
282
-
283
- [plantuml, format="svg"]
284
- ----
285
- actor Foo1
286
- boundary Foo2
287
- Foo1 -> Foo2 : To boundary
288
- ----
289
- eos
290
-
291
- d = Asciidoctor.load StringIO.new(doc), {:attributes => {'outdir' => 'foo'}}
292
- b = d.find { |b| b.context == :image }
293
-
294
- target = b.attributes['target']
295
- expect(target).to_not be_nil
296
- expect(File.exists?(target)).to be false
297
- expect(File.exists?(File.expand_path(target, 'foo'))).to be true
298
- end
299
-
300
- it "should omit width/height attributes when generating docbook" do
301
- doc = <<-eos
302
- = Hello, PlantUML!
303
- Doc Writer <doc@example.com>
304
-
305
- == First Section
306
-
307
- [plantuml, format="png"]
308
- ----
309
- User -> (Start)
310
- ----
311
- eos
312
-
313
- d = Asciidoctor.load StringIO.new(doc), :attributes => {'backend' => 'docbook5' }
314
- expect(d).to_not be_nil
315
-
316
- b = d.find { |b| b.context == :image }
317
- expect(b).to_not be_nil
318
-
319
- target = b.attributes['target']
320
- expect(File.exists?(target)).to be true
321
-
322
- expect(b.attributes['width']).to be_nil
323
- expect(b.attributes['height']).to be_nil
324
- end
325
- end
184
+ end
data/spec/test_helper.rb CHANGED
@@ -6,11 +6,9 @@ require 'stringio'
6
6
  require 'tmpdir'
7
7
 
8
8
  require_relative '../lib/asciidoctor-diagram'
9
- require_relative '../lib/asciidoctor-diagram/blockdiag/extension'
10
9
  require_relative '../lib/asciidoctor-diagram/ditaa/extension'
11
10
  require_relative '../lib/asciidoctor-diagram/graphviz/extension'
12
11
  require_relative '../lib/asciidoctor-diagram/plantuml/extension'
13
- require_relative '../lib/asciidoctor-diagram/shaape/extension'
14
12
 
15
13
  module Asciidoctor
16
14
  class AbstractBlock
@@ -32,18 +30,13 @@ end
32
30
  RSpec.configure do |c|
33
31
  TEST_DIR = 'testing'
34
32
 
35
- c.before(:suite) do
36
- FileUtils.rm_r TEST_DIR if Dir.exists? TEST_DIR
33
+ c.before(:all) do
34
+ #FileUtils.rm_r TEST_DIR if Dir.exists? TEST_DIR
37
35
  FileUtils.mkdir_p TEST_DIR
38
36
  end
39
37
 
40
38
  c.around(:each) do |example|
41
- metadata = example.metadata
42
- group_dir = File.expand_path(metadata[:example_group][:full_description].gsub(/[^\w]+/, '_'), TEST_DIR)
43
- Dir.mkdir(group_dir) unless Dir.exists?(group_dir)
44
-
45
- test_dir = File.expand_path(metadata[:description].gsub(/[^\w]+/, '_'), group_dir)
46
- Dir.mkdir(test_dir)
39
+ test_dir = Dir.mktmpdir 'test', File.expand_path(TEST_DIR)
47
40
 
48
41
  old_wd = Dir.pwd
49
42
  Dir.chdir test_dir
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-diagram
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.2.0.preview.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pepijn Van Eeckhoudt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-14 00:00:00.000000000 Z
11
+ date: 2014-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
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
40
  version: '0'
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
47
  version: '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
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: asciidoctor
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.4
61
+ version: 1.5.0.preview.2
62
62
  type: :runtime
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.1.4
68
+ version: 1.5.0.preview.2
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rjb
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.4.8
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.4.8
83
83
  description: Asciidoctor diagramming extension
@@ -93,38 +93,30 @@ files:
93
93
  - Rakefile
94
94
  - examples/Gemfile
95
95
  - examples/README.adoc
96
- - examples/build_example.rb
97
96
  - examples/design.adoc
98
97
  - examples/features.adoc
99
98
  - lib/asciidoctor-diagram.rb
100
- - lib/asciidoctor-diagram/blockdiag.rb
101
- - lib/asciidoctor-diagram/blockdiag/extension.rb
102
99
  - lib/asciidoctor-diagram/ditaa.rb
103
100
  - lib/asciidoctor-diagram/ditaa/extension.rb
101
+ - lib/asciidoctor-diagram/ditaa/generator.rb
104
102
  - lib/asciidoctor-diagram/graphviz.rb
105
103
  - lib/asciidoctor-diagram/graphviz/extension.rb
106
104
  - lib/asciidoctor-diagram/plantuml.rb
107
105
  - lib/asciidoctor-diagram/plantuml/extension.rb
108
106
  - lib/asciidoctor-diagram/plantuml/generator.rb
109
- - lib/asciidoctor-diagram/shaape.rb
110
- - lib/asciidoctor-diagram/shaape/extension.rb
111
107
  - lib/asciidoctor-diagram/util/binaryio.rb
112
- - lib/asciidoctor-diagram/util/cli_generator.rb
113
108
  - lib/asciidoctor-diagram/util/diagram.rb
114
109
  - lib/asciidoctor-diagram/util/java.rb
115
110
  - lib/asciidoctor-diagram/util/java_jruby.rb
116
111
  - lib/asciidoctor-diagram/util/java_rjb.rb
117
112
  - lib/asciidoctor-diagram/util/png.rb
118
113
  - lib/asciidoctor-diagram/util/svg.rb
119
- - lib/asciidoctor-diagram/util/which.rb
120
114
  - lib/asciidoctor-diagram/version.rb
121
115
  - lib/ditaamini0_9.jar
122
116
  - lib/plantuml.jar
123
- - spec/blockdiag_spec.rb
124
117
  - spec/ditaa_spec.rb
125
118
  - spec/graphviz_spec.rb
126
119
  - spec/plantuml_spec.rb
127
- - spec/shaape_spec.rb
128
120
  - spec/test_helper.rb
129
121
  homepage: https://github.com/asciidoctor/asciidoctor-diagram
130
122
  licenses:
@@ -136,25 +128,23 @@ require_paths:
136
128
  - lib
137
129
  required_ruby_version: !ruby/object:Gem::Requirement
138
130
  requirements:
139
- - - '>='
131
+ - - ">="
140
132
  - !ruby/object:Gem::Version
141
133
  version: '0'
142
134
  required_rubygems_version: !ruby/object:Gem::Requirement
143
135
  requirements:
144
- - - '>='
136
+ - - ">"
145
137
  - !ruby/object:Gem::Version
146
- version: '0'
138
+ version: 1.3.1
147
139
  requirements: []
148
140
  rubyforge_project:
149
- rubygems_version: 2.0.14
141
+ rubygems_version: 2.2.0
150
142
  signing_key:
151
143
  specification_version: 4
152
144
  summary: An extension for asciidoctor that adds support for UML diagram generation
153
145
  using PlantUML
154
146
  test_files:
155
- - spec/blockdiag_spec.rb
156
147
  - spec/ditaa_spec.rb
157
148
  - spec/graphviz_spec.rb
158
149
  - spec/plantuml_spec.rb
159
- - spec/shaape_spec.rb
160
150
  - spec/test_helper.rb