asciidoctor-diagram 1.3.0.preview.4 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/{asciidoctor-diagram-java-1.3.2.jar → asciidoctor-diagram-java-1.3.4.jar} +0 -0
- data/lib/asciidoctor-diagram/ditaa/extension.rb +40 -7
- data/lib/asciidoctor-diagram/extensions.rb +17 -15
- data/lib/asciidoctor-diagram/util/java.rb +1 -1
- data/lib/asciidoctor-diagram/version.rb +1 -1
- data/lib/ditaamini-0.10.jar +0 -0
- data/lib/plantuml.jar +0 -0
- data/spec/ditaa_spec.rb +6 -4
- data/spec/plantuml_spec.rb +1 -1
- metadata +7 -7
- data/lib/ditaamini0_9.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a2f204cc0c29acb26136512bd4a8d50b94eb19d
|
4
|
+
data.tar.gz: 0115d195b3546f4ab1a1967a45891769b4d28fb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bedbbef25acb0ea9d0617b67521f8b92f57a66a730f58b35090e221936cc3ee3a1ff76af260f78f7ccec6e88467188744b048e9997701c46d667e37f2f142f6
|
7
|
+
data.tar.gz: fc0668cb0299126c80f392efccba75c8eda819a835e69b3c27c99fd57c50d1d4b312271bba3cbae7cbebf34a23dbd56a7adfd470a7a48fe8079fb3b4ae210345
|
Binary file
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
1
3
|
require_relative '../extensions'
|
2
4
|
require_relative '../util/java'
|
3
5
|
|
@@ -5,19 +7,19 @@ module Asciidoctor
|
|
5
7
|
module Diagram
|
6
8
|
# @private
|
7
9
|
module Ditaa
|
8
|
-
JARS = ['
|
10
|
+
JARS = ['ditaamini-0.10.jar'].map do |jar|
|
9
11
|
File.expand_path File.join('../..', jar), File.dirname(__FILE__)
|
10
12
|
end
|
11
13
|
Java.classpath.concat JARS
|
12
14
|
|
13
|
-
def ditaa(code,
|
15
|
+
def ditaa(code, source)
|
14
16
|
Java.load
|
15
17
|
|
16
18
|
response = Java.send_request(
|
17
19
|
:url => '/ditaa',
|
18
20
|
:body => code,
|
19
21
|
:headers => {
|
20
|
-
'X-Options' =>
|
22
|
+
'X-Options' => source.options
|
21
23
|
}
|
22
24
|
)
|
23
25
|
|
@@ -29,25 +31,56 @@ module Asciidoctor
|
|
29
31
|
end
|
30
32
|
|
31
33
|
def self.included(mod)
|
32
|
-
mod.register_format(:png, :image) do |c, _,
|
33
|
-
ditaa(c.to_s,
|
34
|
+
mod.register_format(:png, :image) do |c, _, source|
|
35
|
+
ditaa(c.to_s, source)
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
37
39
|
def create_source(parent, reader, attributes)
|
38
40
|
source = super(parent, reader, attributes)
|
39
41
|
source.extend DitaaSource
|
42
|
+
|
43
|
+
source.init_ditaa_options(parent, attributes)
|
44
|
+
|
40
45
|
source
|
41
46
|
end
|
42
47
|
|
43
48
|
module DitaaSource
|
49
|
+
attr_reader :options
|
50
|
+
|
51
|
+
OPTIONS = {
|
52
|
+
'scale' => lambda { |o, v| o << '--scale' << v if v },
|
53
|
+
'tabs' => lambda { |o, v| o << '--tabs' << v if v },
|
54
|
+
'background' => lambda { |o, v| o << '--background' << v if v },
|
55
|
+
'antialias' => lambda { |o, v| o << '--no-antialias' if v == 'false' },
|
56
|
+
'separation' => lambda { |o, v| o << '--no-separation' if v == 'false'},
|
57
|
+
'round-corners' => lambda { |o, v| o << '--round-corners' if v == 'true'},
|
58
|
+
'shadows' => lambda { |o, v| o << '--no-shadows' if v == 'false'},
|
59
|
+
'debug' => lambda { |o, v| o << '--debug' if v == 'true'},
|
60
|
+
'fixed-slope' => lambda { |o, v| o << '--fixed-slope' if v == 'true'},
|
61
|
+
'transparent' => lambda { |o, v| o << '--transparent' if v == 'true'}
|
62
|
+
}
|
63
|
+
|
64
|
+
def init_ditaa_options(parent, attributes)
|
65
|
+
global_attributes = parent.document.attributes
|
66
|
+
|
67
|
+
options = []
|
68
|
+
|
69
|
+
OPTIONS.keys.each do |key|
|
70
|
+
value = attributes.delete(key) || global_attributes["ditaa-option-#{key}"]
|
71
|
+
OPTIONS[key].call(options, value)
|
72
|
+
end
|
73
|
+
|
74
|
+
@options = options.join(' ')
|
75
|
+
end
|
76
|
+
|
44
77
|
def should_process?(image_file, image_metadata)
|
45
|
-
super(image_file, image_metadata) || image_metadata['options'] !=
|
78
|
+
super(image_file, image_metadata) || image_metadata['options'] != @options
|
46
79
|
end
|
47
80
|
|
48
81
|
def create_image_metadata
|
49
82
|
metadata = super
|
50
|
-
metadata['options'] =
|
83
|
+
metadata['options'] = @options
|
51
84
|
metadata
|
52
85
|
end
|
53
86
|
end
|
@@ -84,9 +84,9 @@ module Asciidoctor
|
|
84
84
|
# @param attributes [Hash] the attributes of the block or block macro
|
85
85
|
# @return [Asciidoctor::AbstractBlock] a new block that replaces the original block or block macro
|
86
86
|
def process(parent, reader_or_target, attributes)
|
87
|
-
source = create_source(parent, reader_or_target, attributes)
|
87
|
+
source = create_source(parent, reader_or_target, attributes.dup)
|
88
88
|
|
89
|
-
format = attributes.delete('format') || self.class.default_format
|
89
|
+
format = source.attributes.delete('format') || self.class.default_format
|
90
90
|
format = format.to_sym if format.respond_to?(:to_sym)
|
91
91
|
|
92
92
|
raise "Format undefined" unless format
|
@@ -98,9 +98,9 @@ module Asciidoctor
|
|
98
98
|
begin
|
99
99
|
case generator_info[:type]
|
100
100
|
when :literal
|
101
|
-
create_literal_block(parent, source,
|
101
|
+
create_literal_block(parent, source, generator_info)
|
102
102
|
else
|
103
|
-
create_image_block(parent, source,
|
103
|
+
create_image_block(parent, source, format, generator_info)
|
104
104
|
end
|
105
105
|
rescue => e
|
106
106
|
text = "Failed to generate image: #{e.message}"
|
@@ -129,7 +129,7 @@ module Asciidoctor
|
|
129
129
|
end
|
130
130
|
|
131
131
|
private
|
132
|
-
def create_image_block(parent, source,
|
132
|
+
def create_image_block(parent, source, format, generator_info)
|
133
133
|
image_name = "#{source.image_name}.#{format}"
|
134
134
|
image_dir = image_output_dir(parent)
|
135
135
|
image_file = parent.normalize_system_path image_name, image_dir
|
@@ -141,12 +141,12 @@ module Asciidoctor
|
|
141
141
|
metadata = {}
|
142
142
|
end
|
143
143
|
|
144
|
-
image_attributes = attributes
|
144
|
+
image_attributes = source.attributes
|
145
145
|
|
146
146
|
if !File.exists?(image_file) || source.should_process?(image_file, metadata)
|
147
147
|
params = IMAGE_PARAMS[format]
|
148
148
|
|
149
|
-
result = instance_exec(source, parent,
|
149
|
+
result = instance_exec(source, parent, source, &generator_info[:generator])
|
150
150
|
|
151
151
|
result.force_encoding(params[:encoding])
|
152
152
|
|
@@ -161,8 +161,8 @@ module Asciidoctor
|
|
161
161
|
image_attributes['target'] = image_name
|
162
162
|
|
163
163
|
scale = image_attributes['scale']
|
164
|
-
if scalematch = /(\d+)
|
165
|
-
scale_factor = scalematch[1].
|
164
|
+
if scalematch = /(\d+(?:\.\d+))/.match(scale)
|
165
|
+
scale_factor = scalematch[1].to_f
|
166
166
|
else
|
167
167
|
scale_factor = 1.0
|
168
168
|
end
|
@@ -177,9 +177,9 @@ module Asciidoctor
|
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
180
|
-
image_attributes['alt'] ||= if title_text =
|
180
|
+
image_attributes['alt'] ||= if title_text = image_attributes['title']
|
181
181
|
title_text
|
182
|
-
elsif target =
|
182
|
+
elsif target = image_attributes['target']
|
183
183
|
(File.basename(target, File.extname(target)) || '').tr '_-', ' '
|
184
184
|
else
|
185
185
|
'Diagram'
|
@@ -213,8 +213,8 @@ module Asciidoctor
|
|
213
213
|
parent.normalize_system_path(images_dir, base_dir)
|
214
214
|
end
|
215
215
|
|
216
|
-
def create_literal_block(parent, source,
|
217
|
-
literal_attributes = attributes
|
216
|
+
def create_literal_block(parent, source, generator_info)
|
217
|
+
literal_attributes = source.attributes
|
218
218
|
literal_attributes.delete('target')
|
219
219
|
|
220
220
|
result = instance_exec(source, parent, &generator_info[:generator])
|
@@ -254,7 +254,7 @@ module Asciidoctor
|
|
254
254
|
#
|
255
255
|
# @return [FileSource] a FileSource
|
256
256
|
def create_source(parent, target, attributes)
|
257
|
-
FileSource.new(File.expand_path(target, parent.document.
|
257
|
+
FileSource.new(File.expand_path(target, parent.document.base_dir), attributes)
|
258
258
|
end
|
259
259
|
end
|
260
260
|
|
@@ -366,7 +366,9 @@ module Asciidoctor
|
|
366
366
|
end
|
367
367
|
|
368
368
|
def code
|
369
|
-
|
369
|
+
lines = File.readlines(@file_name)
|
370
|
+
lines = ::Asciidoctor::Helpers.normalize_lines(lines)
|
371
|
+
@code ||= lines.join("\n")
|
370
372
|
end
|
371
373
|
end
|
372
374
|
end
|
@@ -4,7 +4,7 @@ module Asciidoctor
|
|
4
4
|
module Java
|
5
5
|
def self.classpath
|
6
6
|
@classpath ||= [
|
7
|
-
File.expand_path(File.join('../..', 'asciidoctor-diagram-java-1.3.
|
7
|
+
File.expand_path(File.join('../..', 'asciidoctor-diagram-java-1.3.4.jar'), File.dirname(__FILE__))
|
8
8
|
]
|
9
9
|
end
|
10
10
|
|
Binary file
|
data/lib/plantuml.jar
CHANGED
Binary file
|
data/spec/ditaa_spec.rb
CHANGED
@@ -121,12 +121,14 @@ Doc Writer <doc@example.com>
|
|
121
121
|
|
122
122
|
it "should support ditaa options as attributes" do
|
123
123
|
doc = <<-eos
|
124
|
+
:ditaa-option-antialias: false
|
125
|
+
:ditaa-option-round-corners: true
|
124
126
|
= Hello, PlantUML!
|
125
127
|
Doc Writer <doc@example.com>
|
126
128
|
|
127
129
|
== First Section
|
128
130
|
|
129
|
-
[ditaa,
|
131
|
+
[ditaa, shadows=false, separation=false, round-corners=false, scale=2.3]
|
130
132
|
----
|
131
133
|
+--------+ +-------+ +-------+
|
132
134
|
| | --+ ditaa +--> | |
|
@@ -157,7 +159,7 @@ Doc Writer <doc@example.com>
|
|
157
159
|
|
158
160
|
== First Section
|
159
161
|
|
160
|
-
[ditaa,
|
162
|
+
[ditaa, {opts}]
|
161
163
|
----
|
162
164
|
+--------+ +-------+ +-------+
|
163
165
|
| | --+ ditaa +--> | |
|
@@ -171,14 +173,14 @@ Doc Writer <doc@example.com>
|
|
171
173
|
----
|
172
174
|
eos
|
173
175
|
|
174
|
-
d = Asciidoctor.load StringIO.new(doc.sub('{opts}', '
|
176
|
+
d = Asciidoctor.load StringIO.new(doc.sub('{opts}', 'shadow=false'))
|
175
177
|
b = d.find { |b| b.context == :image }
|
176
178
|
target = b.attributes['target']
|
177
179
|
mtime1 = File.mtime(target)
|
178
180
|
|
179
181
|
sleep 1
|
180
182
|
|
181
|
-
d = Asciidoctor.load StringIO.new(doc.sub('{opts}', 'round-corners'))
|
183
|
+
d = Asciidoctor.load StringIO.new(doc.sub('{opts}', 'round-corners=true'))
|
182
184
|
|
183
185
|
mtime2 = File.mtime(target)
|
184
186
|
|
data/spec/plantuml_spec.rb
CHANGED
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.3.0
|
4
|
+
version: 1.3.0
|
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: 2015-
|
11
|
+
date: 2015-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,7 +81,7 @@ files:
|
|
81
81
|
- examples/README.adoc
|
82
82
|
- examples/design.adoc
|
83
83
|
- examples/features.adoc
|
84
|
-
- lib/asciidoctor-diagram-java-1.3.
|
84
|
+
- lib/asciidoctor-diagram-java-1.3.4.jar
|
85
85
|
- lib/asciidoctor-diagram.rb
|
86
86
|
- lib/asciidoctor-diagram/blockdiag.rb
|
87
87
|
- lib/asciidoctor-diagram/blockdiag/extension.rb
|
@@ -104,7 +104,7 @@ files:
|
|
104
104
|
- lib/asciidoctor-diagram/util/svg.rb
|
105
105
|
- lib/asciidoctor-diagram/util/which.rb
|
106
106
|
- lib/asciidoctor-diagram/version.rb
|
107
|
-
- lib/
|
107
|
+
- lib/ditaamini-0.10.jar
|
108
108
|
- lib/plantuml.jar
|
109
109
|
- spec/blockdiag_spec.rb
|
110
110
|
- spec/ditaa_spec.rb
|
@@ -127,12 +127,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- - "
|
130
|
+
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
132
|
+
version: '0'
|
133
133
|
requirements: []
|
134
134
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.4.
|
135
|
+
rubygems_version: 2.4.7
|
136
136
|
signing_key:
|
137
137
|
specification_version: 4
|
138
138
|
summary: An extension for asciidoctor that adds support for UML diagram generation
|
data/lib/ditaamini0_9.jar
DELETED
Binary file
|