asciidoctor-diagram 1.5.13 → 1.5.14

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
- SHA1:
3
- metadata.gz: ffc1f6fe55704de14ad37b6d54292decde729e9b
4
- data.tar.gz: e8e81c21b5918ba8337ff5340382cbe9a311ca37
2
+ SHA256:
3
+ metadata.gz: 5962614a723e062d532b327981f996fc78935fc0e0e54845c75b3e574ed60625
4
+ data.tar.gz: a7418066cac52fe651021800321d41be68bf63e27979be5891af58c2f56325ba
5
5
  SHA512:
6
- metadata.gz: a2426b51df51fa6d625c4a2c2345f3157b0c8eac5cd5683d52680f2908326a2aa385483bdda8780321af7ee96276ae1dcdfb087ca3ed8859aaa7b47df9630389
7
- data.tar.gz: 772a8642bda51b9abfba2044fa9d27d5296e5e13dd6d8e4ed7b9298dc4ee93f53e7eb18c94c04e295a407736e97b89465dcccfeaf8428d8884201150f1d414ef
6
+ metadata.gz: 7f10827a1a1c917bb5f19de7dab893ada70ad7e946b155a6172a3300ad740a538343a7327c95d9fb4ef3001eebb389c66f30fdef02cbca71c31c1f61f4c718e7
7
+ data.tar.gz: a7d1e19e061cfeac793fde2ba33a8b47a54dd9f15957472f223705e1093c01bf42384a38653b1611d08c4f872c3c9fc9caf498c4e995966e29ecbf949374a26b
@@ -1,5 +1,12 @@
1
1
  = Asciidoctor-diagram Changelog
2
2
 
3
+ == 1.5.14
4
+
5
+ Enhancements::
6
+ * Add support for Nomnoml (@Mogztter)
7
+ * Use system HTTP(S) proxies in java subprocess (@hakandilek)
8
+ * Issue #214: Improve extension loading performance
9
+
3
10
  == 1.5.13
4
11
 
5
12
  Bug Fixes::
@@ -26,6 +26,7 @@ ifndef::env-site[:status:]
26
26
  :uri-java: http://java.sun.com
27
27
  :uri-mermaid: https://github.com/mermaidjs/mermaid.cli
28
28
  :uri-mscgen: http://www.mcternan.me.uk/mscgen/
29
+ :uri-nomnoml: http://nomnoml.com
29
30
  :uri-nwdiag: http://blockdiag.com/en/nwdiag/index.html
30
31
  :uri-packetdiag: http://blockdiag.com/en/nwdiag/index.html
31
32
  :uri-phantomjs: http://phantomjs.org
@@ -45,7 +46,7 @@ ifndef::env-site[:status:]
45
46
 
46
47
  Asciidoctor Diagram is a set of Asciidoctor extensions that enable you to add diagrams, which you describe using plain text, to your AsciiDoc document.
47
48
 
48
- The extensions supports the {uri-a2s}[AsciiToSVG], BlockDiag ({uri-blockdiag}[BlockDiag], {uri-seqdiag}[SeqDiag], {uri-actdiag}[ActDiag], {uri-nwdiag}[NwDiag]), {uri-ditaa}[Ditaa], {uri-erd}[Erd], {uri-dot}[GraphViz], {uri-mermaid}[Mermaid], {uri-mscgen}[Msc], {uri-plantuml}[PlantUML], {uri-shaape}[Shaape], {uri-svgbob}[SvgBob], {uri-syntrax}[Syntrax], {uri-umlet}[UMLet], {uri-vega}[Vega], {uri-vegalite}[Vega-Lite] and {uri-wavedrom}[WaveDrom] syntax.
49
+ The extensions supports the {uri-a2s}[AsciiToSVG], BlockDiag ({uri-blockdiag}[BlockDiag], {uri-seqdiag}[SeqDiag], {uri-actdiag}[ActDiag], {uri-nwdiag}[NwDiag]), {uri-ditaa}[Ditaa], {uri-erd}[Erd], {uri-dot}[GraphViz], {uri-mermaid}[Mermaid], {uri-mscgen}[Msc], {uri-nomnoml}[Nomnoml], {uri-plantuml}[PlantUML], {uri-shaape}[Shaape], {uri-svgbob}[SvgBob], {uri-syntrax}[Syntrax], {uri-umlet}[UMLet], {uri-vega}[Vega], {uri-vegalite}[Vega-Lite] and {uri-wavedrom}[WaveDrom] syntax.
49
50
 
50
51
  Each extension runs the diagram processor to generate an SVG, PNG, or TXT file from the input text.
51
52
  The generated file is then inserted into your converted document.
@@ -124,6 +125,7 @@ The following diagram types and output formats are available:
124
125
  |<<meme,meme>> |{check}| |{check}| |
125
126
  |{uri-mermaid}[mermaid] | |{check}|{check}|{check}|
126
127
  |{uri-mscgen}[msc] | | |{check}|{check}|
128
+ |{uri-nomnoml}[nomnoml] | | | |{check}|
127
129
  |{uri-nwdiag}[nwdiag] | |{check}|{check}|{check}|
128
130
  |{uri-packetdiag}[packetdiag]| |{check}|{check}|{check}|
129
131
  |{uri-plantuml}[plantuml] | | |{check}|{check}|{check}
@@ -299,6 +301,7 @@ The following table lists the tools that are required for each diagram type, the
299
301
  |meme |{uri-imagemagick}[ImageMagick] |`convert` and `identify`
300
302
  |mermaid |{uri-mermaid}[Mermaid.cli] |`mermaid`
301
303
  |msc |{uri-mscgen}[Mscgen] |`mscgen`
304
+ |nomnoml |{uri-nomnoml}[Nomnoml] |`nomnoml`
302
305
  |nwdiag |{uri-nwdiag}[NwDiag] |`nwdiag`
303
306
  |packetdiag |{uri-nwdiag}[NwDiag] |`packetdiag`
304
307
  |plantuml |{uri-java}[Java] |`java`
@@ -6,6 +6,7 @@ require_relative 'asciidoctor-diagram/graphviz'
6
6
  require_relative 'asciidoctor-diagram/meme'
7
7
  require_relative 'asciidoctor-diagram/mermaid'
8
8
  require_relative 'asciidoctor-diagram/msc'
9
+ require_relative 'asciidoctor-diagram/nomnoml'
9
10
  require_relative 'asciidoctor-diagram/plantuml'
10
11
  require_relative 'asciidoctor-diagram/salt'
11
12
  require_relative 'asciidoctor-diagram/shaape'
@@ -1,8 +1,7 @@
1
- require_relative 'extensions'
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'a2s/extension'
2
3
 
3
4
  Asciidoctor::Extensions.register do
4
- require_relative 'a2s/extension'
5
-
6
5
  block Asciidoctor::Diagram::AsciiToSvgBlockProcessor, :a2s
7
6
  block_macro Asciidoctor::Diagram::AsciiToSvgBlockMacroProcessor, :a2s
8
7
  end
@@ -1,8 +1,7 @@
1
- require_relative 'extensions'
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'blockdiag/extension'
2
3
 
3
4
  Asciidoctor::Extensions.register do
4
- require_relative 'blockdiag/extension'
5
-
6
5
  ['BlockDiag', 'SeqDiag', 'ActDiag', 'NwDiag', 'RackDiag', 'PacketDiag'].each do |tool|
7
6
  block ::Asciidoctor::Diagram.const_get("#{tool}BlockProcessor"), tool.downcase.to_sym
8
7
  block_macro ::Asciidoctor::Diagram.const_get("#{tool}BlockMacroProcessor"), tool.downcase.to_sym
@@ -1,7 +1,7 @@
1
- require_relative 'extensions'
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'ditaa/extension'
2
3
 
3
4
  Asciidoctor::Extensions.register do
4
- require_relative 'ditaa/extension'
5
5
  block Asciidoctor::Diagram::DitaaBlockProcessor, :ditaa
6
6
  block_macro Asciidoctor::Diagram::DitaaBlockMacroProcessor, :ditaa
7
7
  end
@@ -1,12 +1,29 @@
1
1
  require 'set'
2
2
 
3
3
  require_relative '../extensions'
4
- require_relative 'converter'
4
+ require_relative '../util/java'
5
5
 
6
6
  module Asciidoctor
7
7
  module Diagram
8
+ # @private
8
9
  module Ditaa
9
- OPTION_KEYS = DitaaConverter::OPTIONS.keys
10
+ OPTIONS = {
11
+ 'scale' => lambda { |o, v| o << '--scale' << v if v },
12
+ 'tabs' => lambda { |o, v| o << '--tabs' << v if v },
13
+ 'background' => lambda { |o, v| o << '--background' << v if v },
14
+ 'antialias' => lambda { |o, v| o << '--no-antialias' if v == 'false' },
15
+ 'separation' => lambda { |o, v| o << '--no-separation' if v == 'false'},
16
+ 'round-corners' => lambda { |o, v| o << '--round-corners' if v == 'true'},
17
+ 'shadows' => lambda { |o, v| o << '--no-shadows' if v == 'false'},
18
+ 'debug' => lambda { |o, v| o << '--debug' if v == 'true'},
19
+ 'fixed-slope' => lambda { |o, v| o << '--fixed-slope' if v == 'true'},
20
+ 'transparent' => lambda { |o, v| o << '--transparent' if v == 'true'}
21
+ }
22
+
23
+ JARS = ['ditaa-1.3.13.jar', 'ditaamini-0.11.jar'].map do |jar|
24
+ File.expand_path File.join('../..', jar), File.dirname(__FILE__)
25
+ end
26
+ Java.classpath.concat JARS
10
27
 
11
28
  def self.included(mod)
12
29
  mod.register_format(:png, :image) do |parent, source|
@@ -19,14 +36,35 @@ module Asciidoctor
19
36
  end
20
37
 
21
38
  def ditaa(parent, source, mime_type)
39
+ Java.load
40
+
22
41
  global_attributes = parent.document.attributes
23
- opts = {}
24
- opts['mime_type'] = mime_type
25
- OPTION_KEYS.each do |key|
42
+
43
+ options = []
44
+
45
+ OPTIONS.keys.each do |key|
26
46
  value = source.attributes.delete(key) || global_attributes["ditaa-option-#{key}"]
27
- opts[key] = value if value
47
+ OPTIONS[key].call(options, value)
28
48
  end
29
- DitaaConverter.convert(source.to_s, opts)
49
+
50
+ options_string = options.join(' ')
51
+
52
+ headers = {
53
+ 'Accept' => mime_type,
54
+ 'X-Options' => options_string
55
+ }
56
+
57
+ response = Java.send_request(
58
+ :url => '/ditaa',
59
+ :body => source.to_s,
60
+ :headers => headers
61
+ )
62
+
63
+ unless response[:code] == 200
64
+ raise Java.create_error("Ditaa image generation failed", response)
65
+ end
66
+
67
+ response[:body]
30
68
  end
31
69
  end
32
70
 
@@ -1,7 +1,7 @@
1
- require_relative 'extensions'
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'erd/extension'
2
3
 
3
4
  Asciidoctor::Extensions.register do
4
- require_relative 'erd/extension'
5
5
  block Asciidoctor::Diagram::ErdBlockProcessor, :erd
6
6
  block_macro Asciidoctor::Diagram::ErdBlockMacroProcessor, :erd
7
7
  end
@@ -192,7 +192,7 @@ module Asciidoctor
192
192
  File.open(metadata_file, 'w') { |f| JSON.dump(metadata, f) }
193
193
  end
194
194
 
195
- image_attributes['target'] = parent.attr('data-uri') ? image_file : image_name
195
+ image_attributes['target'] = parent.attr('data-uri', nil, true) ? image_file : image_name
196
196
 
197
197
  scale = image_attributes['scale']
198
198
  if scalematch = /(\d+(?:\.\d+))/.match(scale)
@@ -245,13 +245,13 @@ module Asciidoctor
245
245
  def image_output_dir(parent)
246
246
  document = parent.document
247
247
 
248
- images_dir = parent.attr('imagesoutdir')
248
+ images_dir = parent.attr('imagesoutdir', nil, true)
249
249
 
250
250
  if images_dir
251
251
  base_dir = nil
252
252
  else
253
- base_dir = parent.attr('outdir') || doc_option(document, :to_dir)
254
- images_dir = parent.attr('imagesdir')
253
+ base_dir = parent.attr('outdir', nil, true) || doc_option(document, :to_dir)
254
+ images_dir = parent.attr('imagesdir', nil, true)
255
255
  end
256
256
 
257
257
  parent.normalize_system_path(images_dir, base_dir)
@@ -260,7 +260,7 @@ module Asciidoctor
260
260
  def cache_dir(parent)
261
261
  document = parent.document
262
262
  cache_dir = '.asciidoctor/diagram'
263
- base_dir = parent.attr('outdir') || doc_option(document, :to_dir)
263
+ base_dir = parent.attr('outdir', nil, true) || doc_option(document, :to_dir)
264
264
  parent.normalize_system_path(cache_dir, base_dir)
265
265
  end
266
266
 
@@ -1,7 +1,7 @@
1
- require_relative 'extensions'
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'graphviz/extension'
2
3
 
3
4
  Asciidoctor::Extensions.register do
4
- require_relative 'graphviz/extension'
5
5
  block Asciidoctor::Diagram::GraphvizBlockProcessor, :graphviz
6
6
  block_macro Asciidoctor::Diagram::GraphvizBlockMacroProcessor, :graphviz
7
7
  end
@@ -1,7 +1,6 @@
1
- require_relative 'extensions'
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'meme/extension'
2
3
 
3
4
  Asciidoctor::Extensions.register do
4
- require_relative 'meme/extension'
5
-
6
5
  block_macro Asciidoctor::Diagram::MemeBlockMacroProcessor, :meme
7
6
  end
@@ -1,8 +1,7 @@
1
- require_relative 'extensions'
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'mermaid/extension'
2
3
 
3
4
  Asciidoctor::Extensions.register do
4
- require_relative 'mermaid/extension'
5
-
6
5
  block Asciidoctor::Diagram::MermaidBlockProcessor, :mermaid
7
6
  block_macro Asciidoctor::Diagram::MermaidBlockMacroProcessor, :mermaid
8
7
  end
@@ -1,8 +1,7 @@
1
- require_relative 'extensions'
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'msc/extension'
2
3
 
3
4
  Asciidoctor::Extensions.register do
4
- require_relative 'msc/extension'
5
-
6
5
  block Asciidoctor::Diagram::MscBlockProcessor, :msc
7
6
  block_macro Asciidoctor::Diagram::MscBlockMacroProcessor, :msc
8
7
  end
@@ -0,0 +1,7 @@
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'nomnoml/extension'
3
+
4
+ Asciidoctor::Extensions.register do
5
+ block Asciidoctor::Diagram::NomnomlBlockProcessor, :nomnoml
6
+ block_macro Asciidoctor::Diagram::NomnomlBlockMacroProcessor, :nomnoml
7
+ end
@@ -0,0 +1,36 @@
1
+ require_relative '../extensions'
2
+ require_relative '../util/cli_generator'
3
+ require_relative '../util/platform'
4
+ require_relative '../util/which'
5
+
6
+ module Asciidoctor
7
+ module Diagram
8
+ # @private
9
+ module Nomnoml
10
+ include CliGenerator
11
+ include Which
12
+
13
+ def self.included(mod)
14
+ [:svg].each do |f|
15
+ mod.register_format(f, :image) do |parent, source|
16
+ nomnoml(parent, source, f)
17
+ end
18
+ end
19
+ end
20
+
21
+ def nomnoml(parent, source, format)
22
+ generate_file(which(parent, 'nomnoml'), 'nomnoml', format.to_s, source.to_s) do |tool_path, input_path, output_path|
23
+ [tool_path, Platform.native_path(input_path), Platform.native_path(output_path)]
24
+ end
25
+ end
26
+ end
27
+
28
+ class NomnomlBlockProcessor < Extensions::DiagramBlockProcessor
29
+ include Nomnoml
30
+ end
31
+
32
+ class NomnomlBlockMacroProcessor < Extensions::DiagramBlockMacroProcessor
33
+ include Nomnoml
34
+ end
35
+ end
36
+ end
@@ -1,8 +1,7 @@
1
- require_relative 'extensions'
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'plantuml/extension'
2
3
 
3
4
  Asciidoctor::Extensions.register do
4
- require_relative 'plantuml/extension'
5
-
6
5
  block Asciidoctor::Diagram::PlantUmlBlockProcessor, :plantuml
7
6
  block_macro Asciidoctor::Diagram::PlantUmlBlockMacroProcessor, :plantuml
8
7
  end
@@ -1,8 +1,7 @@
1
- require_relative 'extensions'
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'plantuml/extension'
2
3
 
3
4
  Asciidoctor::Extensions.register do
4
- require_relative 'plantuml/extension'
5
-
6
5
  block Asciidoctor::Diagram::SaltBlockProcessor, :salt
7
6
  block_macro Asciidoctor::Diagram::SaltBlockMacroProcessor, :salt
8
7
  end
@@ -1,8 +1,7 @@
1
- require_relative 'extensions'
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'shaape/extension'
2
3
 
3
4
  Asciidoctor::Extensions.register do
4
- require_relative 'shaape/extension'
5
-
6
5
  block Asciidoctor::Diagram::ShaapeBlockProcessor, :shaape
7
6
  block_macro Asciidoctor::Diagram::ShaapeBlockMacroProcessor, :shaape
8
7
  end
@@ -1,8 +1,7 @@
1
- require_relative 'extensions'
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'svgbob/extension'
2
3
 
3
4
  Asciidoctor::Extensions.register do
4
- require_relative 'svgbob/extension'
5
-
6
5
  block Asciidoctor::Diagram::SvgBobBlockProcessor, :svgbob
7
6
  block_macro Asciidoctor::Diagram::SvgBobBlockMacroProcessor, :svgbob
8
7
  end
@@ -1,8 +1,7 @@
1
- require_relative 'extensions'
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'syntrax/extension'
2
3
 
3
4
  Asciidoctor::Extensions.register do
4
- require_relative 'syntrax/extension'
5
-
6
5
  block Asciidoctor::Diagram::SyntraxBlockProcessor, :syntrax
7
6
  block_macro Asciidoctor::Diagram::SyntraxBlockMacroProcessor, :syntrax
8
7
  end
@@ -1,7 +1,7 @@
1
- require_relative 'extensions'
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'tikz/extension'
2
3
 
3
4
  Asciidoctor::Extensions.register do
4
- require_relative 'tikz/extension'
5
5
  block Asciidoctor::Diagram::TikZBlockProcessor, :tikz
6
6
  block_macro Asciidoctor::Diagram::TikZBlockMacroProcessor, :tikz
7
7
  end
@@ -1,8 +1,7 @@
1
- require_relative 'extensions'
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'umlet/extension'
2
3
 
3
4
  Asciidoctor::Extensions.register do
4
- require_relative 'umlet/extension'
5
-
6
5
  block Asciidoctor::Diagram::UmletBlockProcessor, :umlet
7
6
  block_macro Asciidoctor::Diagram::UmletBlockMacroProcessor, :umlet
8
7
  end
@@ -14,6 +14,7 @@ module Asciidoctor
14
14
  def initialize(java, classpath)
15
15
  args = []
16
16
  args << '-Djava.awt.headless=true'
17
+ args << '-Djava.net.useSystemProxies=true'
17
18
  args << '-cp'
18
19
  args << classpath.flatten.map { |jar| ::Asciidoctor::Diagram::Platform.host_os_path(jar).strip }.join(::Asciidoctor::Diagram::Platform.host_os_path_separator)
19
20
  args << 'org.asciidoctor.diagram.CommandServer'
@@ -1,8 +1,7 @@
1
- require_relative 'extensions'
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'vega/extension'
2
3
 
3
4
  Asciidoctor::Extensions.register do
4
- require_relative 'vega/extension'
5
-
6
5
  block Asciidoctor::Diagram::VegaBlockProcessor, :vega
7
6
  block_macro Asciidoctor::Diagram::VegaBlockMacroProcessor, :vega
8
7
 
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Diagram
3
- VERSION = "1.5.13"
3
+ VERSION = "1.5.14"
4
4
  end
5
5
  end
@@ -1,8 +1,7 @@
1
- require_relative 'extensions'
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'wavedrom/extension'
2
3
 
3
4
  Asciidoctor::Extensions.register do
4
- require_relative 'wavedrom/extension'
5
-
6
5
  block Asciidoctor::Diagram::WavedromBlockProcessor, :wavedrom
7
6
  block_macro Asciidoctor::Diagram::WavedromBlockMacroProcessor, :wavedrom
8
7
  end
@@ -0,0 +1,170 @@
1
+ require_relative 'test_helper'
2
+
3
+ code = <<-eos
4
+ [Pirate|eyeCount: Int|raid();pillage()|
5
+ [beard]--[parrot]
6
+ [beard]-:>[foul mouth]
7
+ ]
8
+
9
+ [<abstract>Marauder]<:--[Pirate]
10
+ [Pirate]- 0..7[mischief]
11
+ [jollyness]->[Pirate]
12
+ [jollyness]->[rum]
13
+ [jollyness]->[singing]
14
+ [Pirate]-> *[rum|tastiness: Int|swig()]
15
+ [Pirate]->[singing]
16
+ [singing]<->[rum]
17
+
18
+ [<start>st]->[<state>plunder]
19
+ [plunder]->[<choice>more loot]
20
+ [more loot]->[st]
21
+ [more loot] no ->[<end>e]
22
+
23
+ [<actor>Sailor] - [<usecase>shiver me;timbers]
24
+ eos
25
+
26
+ describe Asciidoctor::Diagram::NomnomlBlockMacroProcessor do
27
+ it "should generate SVG images when format is set to 'svg'" do
28
+ File.write('nomnoml.txt', code)
29
+
30
+ doc = <<-eos
31
+ = Hello, Nomnoml!
32
+ Doc Writer <doc@example.com>
33
+
34
+ == First Section
35
+
36
+ nomnoml::nomnoml.txt[format="svg"]
37
+ eos
38
+
39
+ d = load_asciidoc doc
40
+ expect(d).to_not be_nil
41
+
42
+ b = d.find { |bl| bl.context == :image }
43
+ expect(b).to_not be_nil
44
+
45
+ expect(b.content_model).to eq :empty
46
+
47
+ target = b.attributes['target']
48
+ expect(target).to_not be_nil
49
+ expect(target).to match(/\.svg/)
50
+ expect(File.exist?(target)).to be true
51
+
52
+ expect(b.attributes['width']).to_not be_nil
53
+ expect(b.attributes['height']).to_not be_nil
54
+ end
55
+ end
56
+
57
+ describe Asciidoctor::Diagram::NomnomlBlockProcessor, :broken_on_windows do
58
+ it "should generate SVG images when format is set to 'svg'" do
59
+ doc = <<-eos
60
+ = Hello, Nomnoml!
61
+ Doc Writer <doc@example.com>
62
+
63
+ == First Section
64
+
65
+ [nomnoml, format="svg"]
66
+ ----
67
+ #{code}
68
+ ----
69
+ eos
70
+
71
+ d = load_asciidoc doc
72
+ expect(d).to_not be_nil
73
+
74
+ b = d.find { |bl| bl.context == :image }
75
+ expect(b).to_not be_nil
76
+
77
+ expect(b.content_model).to eq :empty
78
+
79
+ target = b.attributes['target']
80
+ expect(target).to_not be_nil
81
+ expect(target).to match(/\.svg/)
82
+ expect(File.exist?(target)).to be true
83
+
84
+ expect(b.attributes['width']).to_not be_nil
85
+ expect(b.attributes['height']).to_not be_nil
86
+ end
87
+
88
+ it "should raise an error when when format is set to an invalid value" do
89
+ doc = <<-eos
90
+ = Hello, Nomnoml!
91
+ Doc Writer <doc@example.com>
92
+
93
+ == First Section
94
+
95
+ [nomnoml, format="foobar"]
96
+ ----
97
+ ----
98
+ eos
99
+
100
+ expect { load_asciidoc doc }.to raise_error(/support.*format/i)
101
+ end
102
+
103
+ it "should not regenerate images when source has not changed" do
104
+ File.write('nomnoml.txt', code)
105
+
106
+ doc = <<-eos
107
+ = Hello, Nomnoml!
108
+ Doc Writer <doc@example.com>
109
+
110
+ == First Section
111
+
112
+ nomnoml::nomnoml.txt
113
+
114
+ [nomnoml, format="svg"]
115
+ ----
116
+ #{code}
117
+ ----
118
+ eos
119
+
120
+ d = load_asciidoc doc
121
+ b = d.find { |bl| bl.context == :image }
122
+ expect(b).to_not be_nil
123
+ target = b.attributes['target']
124
+ mtime1 = File.mtime(target)
125
+
126
+ sleep 1
127
+
128
+ d = load_asciidoc doc
129
+
130
+ mtime2 = File.mtime(target)
131
+
132
+ expect(mtime2).to eq mtime1
133
+ end
134
+
135
+ it "should handle two block macros with the same source" do
136
+ File.write('nomnoml.txt', code)
137
+
138
+ doc = <<-eos
139
+ = Hello, Nomnoml!
140
+ Doc Writer <doc@example.com>
141
+
142
+ == First Section
143
+
144
+ nomnoml::nomnoml.txt[]
145
+ nomnoml::nomnoml.txt[]
146
+ eos
147
+
148
+ load_asciidoc doc
149
+ expect(File.exist?('nomnoml.svg')).to be true
150
+ end
151
+
152
+ it "should respect target attribute in block macros" do
153
+ File.write('nomnoml.txt', code)
154
+
155
+ doc = <<-eos
156
+ = Hello, Nomnoml!
157
+ Doc Writer <doc@example.com>
158
+
159
+ == First Section
160
+
161
+ nomnoml::nomnoml.txt["foobar"]
162
+ nomnoml::nomnoml.txt["foobaz"]
163
+ eos
164
+
165
+ load_asciidoc doc
166
+ expect(File.exist?('foobar.svg')).to be true
167
+ expect(File.exist?('foobaz.svg')).to be true
168
+ expect(File.exist?('nomnoml.svg')).to be false
169
+ end
170
+ end
@@ -14,6 +14,7 @@ require_relative '../lib/asciidoctor-diagram/graphviz/extension'
14
14
  require_relative '../lib/asciidoctor-diagram/meme/extension'
15
15
  require_relative '../lib/asciidoctor-diagram/mermaid/extension'
16
16
  require_relative '../lib/asciidoctor-diagram/msc/extension'
17
+ require_relative '../lib/asciidoctor-diagram/nomnoml/extension'
17
18
  require_relative '../lib/asciidoctor-diagram/plantuml/extension'
18
19
  require_relative '../lib/asciidoctor-diagram/shaape/extension'
19
20
  require_relative '../lib/asciidoctor-diagram/svgbob/extension'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-diagram
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.13
4
+ version: 1.5.14
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: 2019-01-30 00:00:00.000000000 Z
11
+ date: 2019-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -90,7 +90,6 @@ files:
90
90
  - lib/asciidoctor-diagram/blockdiag.rb
91
91
  - lib/asciidoctor-diagram/blockdiag/extension.rb
92
92
  - lib/asciidoctor-diagram/ditaa.rb
93
- - lib/asciidoctor-diagram/ditaa/converter.rb
94
93
  - lib/asciidoctor-diagram/ditaa/extension.rb
95
94
  - lib/asciidoctor-diagram/erd.rb
96
95
  - lib/asciidoctor-diagram/erd/extension.rb
@@ -103,6 +102,8 @@ files:
103
102
  - lib/asciidoctor-diagram/mermaid/extension.rb
104
103
  - lib/asciidoctor-diagram/msc.rb
105
104
  - lib/asciidoctor-diagram/msc/extension.rb
105
+ - lib/asciidoctor-diagram/nomnoml.rb
106
+ - lib/asciidoctor-diagram/nomnoml/extension.rb
106
107
  - lib/asciidoctor-diagram/plantuml.rb
107
108
  - lib/asciidoctor-diagram/plantuml/extension.rb
108
109
  - lib/asciidoctor-diagram/salt.rb
@@ -149,6 +150,7 @@ files:
149
150
  - spec/meme_spec.rb
150
151
  - spec/mermaid_spec.rb
151
152
  - spec/msc_spec.rb
153
+ - spec/nomnoml_spec.rb
152
154
  - spec/plantuml_spec.rb
153
155
  - spec/shaape_spec.rb
154
156
  - spec/svgbob_spec.rb
@@ -178,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
180
  version: '0'
179
181
  requirements: []
180
182
  rubyforge_project:
181
- rubygems_version: 2.5.1
183
+ rubygems_version: 2.7.6
182
184
  signing_key:
183
185
  specification_version: 4
184
186
  summary: An extension for asciidoctor that adds support for UML diagram generation
@@ -193,6 +195,7 @@ test_files:
193
195
  - spec/meme_spec.rb
194
196
  - spec/mermaid_spec.rb
195
197
  - spec/msc_spec.rb
198
+ - spec/nomnoml_spec.rb
196
199
  - spec/plantuml_spec.rb
197
200
  - spec/shaape_spec.rb
198
201
  - spec/svgbob_spec.rb
@@ -1,55 +0,0 @@
1
- require_relative '../util/java'
2
-
3
- module Asciidoctor
4
- module Diagram
5
- module DitaaConverter
6
- OPTIONS = {
7
- 'scale' => ->(o, v) { o << '--scale' << v if v },
8
- 'tabs' => ->(o, v) { o << '--tabs' << v if v },
9
- 'background' => ->(o, v) { o << '--background' << v if v },
10
- 'antialias' => ->(o, v) { o << '--no-antialias' if v == 'false' },
11
- 'separation' => ->(o, v) { o << '--no-separation' if v == 'false' },
12
- 'round-corners' => ->(o, v) { o << '--round-corners' if v == 'true' },
13
- 'shadows' => ->(o, v) { o << '--no-shadows' if v == 'false' },
14
- 'debug' => ->(o, v) {o << '--debug' if v == 'true' },
15
- 'fixed-slope' => ->(o, v) { o << '--fixed-slope' if v == 'true' },
16
- 'transparent' => ->(o, v) { o << '--transparent' if v == 'true' }
17
- }.freeze
18
-
19
- JARS = %w[ditaa-1.3.13.jar ditaamini-0.11.jar].map do |jar|
20
- File.expand_path File.join('../..', jar), File.dirname(__FILE__)
21
- end
22
- Java.classpath.concat JARS
23
-
24
- def self.convert(source, opts)
25
- Java.load
26
- headers = {
27
- Accept: opts['mime_type'],
28
- 'X-Options' => to_header_options(opts)
29
- }
30
- send_request(source, headers)
31
- end
32
-
33
- def self.to_header_options opts
34
- options = []
35
- OPTIONS.keys.each do |key|
36
- value = opts[key]
37
- OPTIONS[key].call(options, value)
38
- end
39
- options.join(' ')
40
- end
41
-
42
- def self.send_request(body, headers, url = '/ditaa')
43
- response = Java.send_request(
44
- url: url,
45
- body: body,
46
- headers: headers
47
- )
48
- unless response[:code] == 200
49
- raise Java.create_error("Ditaa image generation failed", response)
50
- end
51
- response[:body]
52
- end
53
- end
54
- end
55
- end