asciidoctor-diagram 1.0.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.adoc +75 -0
- data/Rakefile +13 -0
- data/asciidoctor-diagram.gemspec +30 -0
- data/ditaamini-license.txt +165 -0
- data/lib/asciidoctor-diagram.rb +2 -0
- data/lib/asciidoctor-diagram/binaryio.rb +26 -0
- data/lib/asciidoctor-diagram/diagram.rb +111 -0
- data/lib/asciidoctor-diagram/ditaa.rb +7 -0
- data/lib/asciidoctor-diagram/ditaa/extension.rb +65 -0
- data/lib/asciidoctor-diagram/java.rb +5 -0
- data/lib/asciidoctor-diagram/java_jruby.rb +36 -0
- data/lib/asciidoctor-diagram/java_rjb.rb +82 -0
- data/lib/asciidoctor-diagram/plantuml.rb +7 -0
- data/lib/asciidoctor-diagram/plantuml/extension.rb +88 -0
- data/lib/asciidoctor-diagram/png.rb +24 -0
- data/lib/asciidoctor-diagram/svg.rb +18 -0
- data/lib/asciidoctor-diagram/version.rb +5 -0
- data/lib/ditaamini0_9.jar +0 -0
- data/lib/plantuml.jar +0 -0
- data/plantuml-license.txt +202 -0
- data/spec/ditaa_spec.rb +56 -0
- data/spec/plantuml_spec.rb +146 -0
- data/spec/test_helper.rb +48 -0
- metadata +131 -0
data/spec/ditaa_spec.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe Asciidoctor::Diagram::DitaaBlock do
|
4
|
+
it "should generate PNG images when format is set to 'png'" do
|
5
|
+
doc = <<-eos
|
6
|
+
= Hello, ditaa!
|
7
|
+
Doc Writer <doc@example.com>
|
8
|
+
|
9
|
+
== First Section
|
10
|
+
|
11
|
+
[ditaa, format="png"]
|
12
|
+
----
|
13
|
+
+--------+ +-------+ +-------+
|
14
|
+
| | --+ ditaa +--> | |
|
15
|
+
| Text | +-------+ |diagram|
|
16
|
+
|Document| |!magic!| | |
|
17
|
+
| {d}| | | | |
|
18
|
+
+---+----+ +-------+ +-------+
|
19
|
+
: ^
|
20
|
+
| Lots of work |
|
21
|
+
+-------------------------+
|
22
|
+
----
|
23
|
+
eos
|
24
|
+
|
25
|
+
d = Asciidoctor.load StringIO.new(doc)
|
26
|
+
expect(d).to_not be_nil
|
27
|
+
|
28
|
+
b = d.find { |b| b.context == :image }
|
29
|
+
expect(b).to_not be_nil
|
30
|
+
|
31
|
+
expect(b.content_model).to eq :empty
|
32
|
+
|
33
|
+
target = b.attributes['target']
|
34
|
+
expect(target).to_not be_nil
|
35
|
+
expect(target).to match /\.png$/
|
36
|
+
expect(File.exists?(target)).to be_true
|
37
|
+
|
38
|
+
expect(b.attributes['width']).to_not be_nil
|
39
|
+
expect(b.attributes['height']).to_not be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should raise an error when when format is set to an invalid value" do
|
43
|
+
doc = <<-eos
|
44
|
+
= Hello, PlantUML!
|
45
|
+
Doc Writer <doc@example.com>
|
46
|
+
|
47
|
+
== First Section
|
48
|
+
|
49
|
+
[ditaa, format="foobar"]
|
50
|
+
----
|
51
|
+
----
|
52
|
+
eos
|
53
|
+
|
54
|
+
expect { Asciidoctor.load StringIO.new(doc) }.to raise_error /support.*format/i
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe Asciidoctor::Diagram::PlantUmlBlock do
|
4
|
+
it "should generate PNG images when format is set to 'png'" do
|
5
|
+
doc = <<-eos
|
6
|
+
= Hello, PlantUML!
|
7
|
+
Doc Writer <doc@example.com>
|
8
|
+
|
9
|
+
== First Section
|
10
|
+
|
11
|
+
[plantuml, format="png"]
|
12
|
+
----
|
13
|
+
User -> (Start)
|
14
|
+
User --> (Use the application) : Label
|
15
|
+
|
16
|
+
:Main Admin: ---> (Use the application) : Another label
|
17
|
+
----
|
18
|
+
eos
|
19
|
+
|
20
|
+
d = Asciidoctor.load StringIO.new(doc)
|
21
|
+
expect(d).to_not be_nil
|
22
|
+
|
23
|
+
b = d.find { |b| b.context == :image }
|
24
|
+
expect(b).to_not be_nil
|
25
|
+
|
26
|
+
expect(b.content_model).to eq :empty
|
27
|
+
|
28
|
+
target = b.attributes['target']
|
29
|
+
expect(target).to_not be_nil
|
30
|
+
expect(target).to match /\.png$/
|
31
|
+
expect(File.exists?(target)).to be_true
|
32
|
+
|
33
|
+
expect(b.attributes['width']).to_not be_nil
|
34
|
+
expect(b.attributes['height']).to_not be_nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should generate SVG images when format is set to 'svg'" do
|
38
|
+
doc = <<-eos
|
39
|
+
= Hello, PlantUML!
|
40
|
+
Doc Writer <doc@example.com>
|
41
|
+
|
42
|
+
== First Section
|
43
|
+
|
44
|
+
[plantuml, format="svg"]
|
45
|
+
----
|
46
|
+
User -> (Start)
|
47
|
+
User --> (Use the application) : Label
|
48
|
+
|
49
|
+
:Main Admin: ---> (Use the application) : Another label
|
50
|
+
----
|
51
|
+
eos
|
52
|
+
|
53
|
+
d = Asciidoctor.load StringIO.new(doc)
|
54
|
+
expect(d).to_not be_nil
|
55
|
+
|
56
|
+
b = d.find { |b| b.context == :image }
|
57
|
+
expect(b).to_not be_nil
|
58
|
+
|
59
|
+
expect(b.content_model).to eq :empty
|
60
|
+
|
61
|
+
target = b.attributes['target']
|
62
|
+
expect(target).to_not be_nil
|
63
|
+
expect(target).to match /\.svg/
|
64
|
+
expect(File.exists?(target)).to be_true
|
65
|
+
|
66
|
+
expect(b.attributes['width']).to_not be_nil
|
67
|
+
expect(b.attributes['height']).to_not be_nil
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should generate literal blocks when format is set to 'txt'" do
|
71
|
+
doc = <<-eos
|
72
|
+
= Hello, PlantUML!
|
73
|
+
Doc Writer <doc@example.com>
|
74
|
+
|
75
|
+
== First Section
|
76
|
+
|
77
|
+
[plantuml, format="txt"]
|
78
|
+
----
|
79
|
+
User -> (Start)
|
80
|
+
User --> (Use the application) : Label
|
81
|
+
|
82
|
+
:Main Admin: ---> (Use the application) : Another label
|
83
|
+
----
|
84
|
+
eos
|
85
|
+
|
86
|
+
d = Asciidoctor.load StringIO.new(doc)
|
87
|
+
expect(d).to_not be_nil
|
88
|
+
|
89
|
+
b = d.find { |b| b.context == :literal }
|
90
|
+
expect(b).to_not be_nil
|
91
|
+
|
92
|
+
expect(b.content_model).to eq :simple
|
93
|
+
|
94
|
+
expect(b.attributes['target']).to be_nil
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should raise an error when when format is set to an invalid value" do
|
98
|
+
doc = <<-eos
|
99
|
+
= Hello, PlantUML!
|
100
|
+
Doc Writer <doc@example.com>
|
101
|
+
|
102
|
+
== First Section
|
103
|
+
|
104
|
+
[plantuml, format="foobar"]
|
105
|
+
----
|
106
|
+
----
|
107
|
+
eos
|
108
|
+
|
109
|
+
expect { Asciidoctor.load StringIO.new(doc) }.to raise_error /support.*format/i
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should use plantuml configuration when specified as a document attribute" do
|
113
|
+
doc = <<-eos
|
114
|
+
= Hello, PlantUML!
|
115
|
+
Doc Writer <doc@example.com>
|
116
|
+
:plantumlconfig: test.config
|
117
|
+
|
118
|
+
== First Section
|
119
|
+
|
120
|
+
[plantuml, format="svg"]
|
121
|
+
----
|
122
|
+
actor Foo1
|
123
|
+
boundary Foo2
|
124
|
+
Foo1 -> Foo2 : To boundary
|
125
|
+
----
|
126
|
+
eos
|
127
|
+
|
128
|
+
config = <<-eos
|
129
|
+
ArrowColor #DEADBE
|
130
|
+
eos
|
131
|
+
|
132
|
+
File.open('test.config', 'w') do |f|
|
133
|
+
f.write config
|
134
|
+
end
|
135
|
+
|
136
|
+
d = Asciidoctor.load StringIO.new(doc)
|
137
|
+
b = d.find { |b| b.context == :image }
|
138
|
+
|
139
|
+
target = b.attributes['target']
|
140
|
+
expect(target).to_not be_nil
|
141
|
+
expect(File.exists?(target)).to be_true
|
142
|
+
|
143
|
+
svg = File.read(target)
|
144
|
+
expect(svg).to match /<path.*fill="#DEADBE"/
|
145
|
+
end
|
146
|
+
end
|
data/spec/test_helper.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'asciidoctor'
|
2
|
+
require 'asciidoctor/cli/invoker'
|
3
|
+
|
4
|
+
require 'fileutils'
|
5
|
+
require 'stringio'
|
6
|
+
require 'tmpdir'
|
7
|
+
|
8
|
+
require_relative '../lib/asciidoctor-diagram'
|
9
|
+
require_relative '../lib/asciidoctor-diagram/ditaa/extension'
|
10
|
+
require_relative '../lib/asciidoctor-diagram/plantuml/extension'
|
11
|
+
|
12
|
+
module Asciidoctor
|
13
|
+
class AbstractBlock
|
14
|
+
def find(&block)
|
15
|
+
blocks.each do |b|
|
16
|
+
if block.call(b)
|
17
|
+
return b
|
18
|
+
end
|
19
|
+
|
20
|
+
if (found_block = b.find(&block))
|
21
|
+
return found_block
|
22
|
+
end
|
23
|
+
end
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
RSpec.configure do |c|
|
30
|
+
TEST_DIR = 'testing'
|
31
|
+
|
32
|
+
c.before(:all) do
|
33
|
+
#FileUtils.rm_r TEST_DIR if Dir.exists? TEST_DIR
|
34
|
+
FileUtils.mkdir_p TEST_DIR
|
35
|
+
end
|
36
|
+
|
37
|
+
c.around(:each) do |example|
|
38
|
+
test_dir = Dir.mktmpdir 'test', File.expand_path(TEST_DIR)
|
39
|
+
|
40
|
+
old_wd = Dir.pwd
|
41
|
+
Dir.chdir test_dir
|
42
|
+
begin
|
43
|
+
example.run
|
44
|
+
ensure
|
45
|
+
Dir.chdir old_wd
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: asciidoctor-diagram
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: java
|
6
|
+
authors:
|
7
|
+
- Pepijn Van Eeckhoudt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: asciidoctor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.1.4
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.1.4
|
69
|
+
description: Asciidoctor diagramming extension
|
70
|
+
email:
|
71
|
+
- pepijn@vaneeckhoudt.net
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.adoc
|
81
|
+
- Rakefile
|
82
|
+
- asciidoctor-diagram.gemspec
|
83
|
+
- ditaamini-license.txt
|
84
|
+
- lib/asciidoctor-diagram.rb
|
85
|
+
- lib/asciidoctor-diagram/binaryio.rb
|
86
|
+
- lib/asciidoctor-diagram/diagram.rb
|
87
|
+
- lib/asciidoctor-diagram/ditaa.rb
|
88
|
+
- lib/asciidoctor-diagram/ditaa/extension.rb
|
89
|
+
- lib/asciidoctor-diagram/java.rb
|
90
|
+
- lib/asciidoctor-diagram/java_jruby.rb
|
91
|
+
- lib/asciidoctor-diagram/java_rjb.rb
|
92
|
+
- lib/asciidoctor-diagram/plantuml.rb
|
93
|
+
- lib/asciidoctor-diagram/plantuml/extension.rb
|
94
|
+
- lib/asciidoctor-diagram/png.rb
|
95
|
+
- lib/asciidoctor-diagram/svg.rb
|
96
|
+
- lib/asciidoctor-diagram/version.rb
|
97
|
+
- lib/ditaamini0_9.jar
|
98
|
+
- lib/plantuml.jar
|
99
|
+
- plantuml-license.txt
|
100
|
+
- spec/ditaa_spec.rb
|
101
|
+
- spec/plantuml_spec.rb
|
102
|
+
- spec/test_helper.rb
|
103
|
+
homepage: https://github.com/asciidoctor/asciidoctor-diagram
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.2.0
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: An extension for asciidoctor that adds support for UML diagram generation
|
127
|
+
using PlantUML
|
128
|
+
test_files:
|
129
|
+
- spec/ditaa_spec.rb
|
130
|
+
- spec/plantuml_spec.rb
|
131
|
+
- spec/test_helper.rb
|