asciidoctor-plantuml 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asciidoctor_plantuml/plantuml.rb +19 -1
- data/lib/asciidoctor_plantuml/version.rb +1 -1
- data/test/test_plantuml.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0eec1ab5b66560c09d54f1c5a44f4ca764b41fd8112a2c1ba791de3936ff4d8
|
4
|
+
data.tar.gz: a806b6892710155ae5d36aee9e3fe0830f30d4606ec8c6b27b3533187f389f80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4924630cd2c797eed3741a6f1b70c2f8eba15b781884a7b76934d090869570615712dd637be42d472610acbf4ea13894c07319c059a213aa9a3c2559e4ac305
|
7
|
+
data.tar.gz: 4243885ff01513113b5e34412532196b708250cba696c0c094b7a77cb96c656b2302a60aabd37589a6ee398df401506b76cb929ed3ac5631efa54928af580dce
|
@@ -12,14 +12,16 @@ module Asciidoctor
|
|
12
12
|
# PlantUML Configuration
|
13
13
|
class Configuration
|
14
14
|
DEFAULT_URL = ENV['PLANTUML_URL'] || ''
|
15
|
+
DEFAULT_ENCODING = ENV['PLANTUML_ENCODING'] || 'legacy'
|
15
16
|
|
16
|
-
attr_accessor :url, :txt_enable, :svg_enable, :png_enable
|
17
|
+
attr_accessor :url, :txt_enable, :svg_enable, :png_enable, :encoding
|
17
18
|
|
18
19
|
def initialize
|
19
20
|
@url = DEFAULT_URL
|
20
21
|
@txt_enable = true
|
21
22
|
@svg_enable = true
|
22
23
|
@png_enable = true
|
24
|
+
@encoding = DEFAULT_ENCODING
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
@@ -39,6 +41,13 @@ module Asciidoctor
|
|
39
41
|
class Processor
|
40
42
|
FORMATS = %w[png svg txt].freeze
|
41
43
|
DEFAULT_FORMAT = FORMATS[0]
|
44
|
+
|
45
|
+
ENCODINGS = %w[legacy deflate].freeze
|
46
|
+
DEFAULT_ENCODING = ENCODINGS[0]
|
47
|
+
|
48
|
+
ENCODINGS_MAGIC_STRINGS_MAP = Hash.new('')
|
49
|
+
ENCODINGS_MAGIC_STRINGS_MAP['deflate'] = '~1'
|
50
|
+
|
42
51
|
URI_SCHEMES_REGEXP = ::URI::DEFAULT_PARSER.make_regexp(%w[http https])
|
43
52
|
|
44
53
|
class << self
|
@@ -46,6 +55,10 @@ module Asciidoctor
|
|
46
55
|
FORMATS.include?(format)
|
47
56
|
end
|
48
57
|
|
58
|
+
def valid_encoding?(encoding)
|
59
|
+
ENCODINGS.include?(encoding)
|
60
|
+
end
|
61
|
+
|
49
62
|
def server_url
|
50
63
|
PlantUml.configuration.url
|
51
64
|
end
|
@@ -92,6 +105,7 @@ module Asciidoctor
|
|
92
105
|
# the transcoder class in the PlantUML java code.
|
93
106
|
def gen_url(text, format)
|
94
107
|
result = ''
|
108
|
+
result += encoding_magic_prefix
|
95
109
|
compressed_data = Zlib::Deflate.deflate(text)
|
96
110
|
compressed_data.chars.each_slice(3) do |bytes|
|
97
111
|
# print bytes[0], ' ' , bytes[1] , ' ' , bytes[2]
|
@@ -204,6 +218,10 @@ module Asciidoctor
|
|
204
218
|
encode6bit(c4 & 0x3F).chr
|
205
219
|
end
|
206
220
|
|
221
|
+
def encoding_magic_prefix
|
222
|
+
ENCODINGS_MAGIC_STRINGS_MAP[PlantUml.configuration.encoding]
|
223
|
+
end
|
224
|
+
|
207
225
|
# Make a call to the PlantUML server with the simplest diagram possible
|
208
226
|
# to check if the server is available or not.
|
209
227
|
def check_server(check_url)
|
data/test/test_plantuml.rb
CHANGED
@@ -118,6 +118,7 @@ ENDOFSTRING
|
|
118
118
|
class PlantUmlTest < Test::Unit::TestCase
|
119
119
|
GENURL = 'http://localhost:8080/plantuml/png/U9npA2v9B2efpStX2YrEBLBGjLFG20Q9Q4Bv804WIw4a8rKXiQ0W9pCviIGpFqzJmKh19p4fDOVB8JKl1QWT05kd5wq0'
|
120
120
|
GENURL2 = 'http://localhost:8080/plantuml/png/U9npA2v9B2efpStXYdRszmqmZ8NGHh4mleAkdGAAa15G22Pc7Clba9gN0jGE00W75Cm0'
|
121
|
+
GENURL_ENCODING = 'http://localhost:8080/plantuml/png/~1U9npA2v9B2efpStX2YrEBLBGjLFG20Q9Q4Bv804WIw4a8rKXiQ0W9pCviIGpFqzJmKh19p4fDOVB8JKl1QWT05kd5wq0'
|
121
122
|
|
122
123
|
def setup
|
123
124
|
Asciidoctor::PlantUml.configure do |c|
|
@@ -165,6 +166,23 @@ class PlantUmlTest < Test::Unit::TestCase
|
|
165
166
|
assert_equal GENURL2, element['src']
|
166
167
|
end
|
167
168
|
|
169
|
+
def test_plantuml_block_processor_encoding
|
170
|
+
Asciidoctor::PlantUml.configure do |c|
|
171
|
+
c.encoding = 'deflate'
|
172
|
+
end
|
173
|
+
|
174
|
+
html = ::Asciidoctor.convert(StringIO.new(DOC_BASIC), backend: 'html5')
|
175
|
+
page = Nokogiri::HTML(html)
|
176
|
+
|
177
|
+
elements = page.css('img.plantuml')
|
178
|
+
|
179
|
+
assert_equal elements.size, 1
|
180
|
+
|
181
|
+
element = elements.first
|
182
|
+
|
183
|
+
assert_equal GENURL_ENCODING, element['src']
|
184
|
+
end
|
185
|
+
|
168
186
|
def test_plantuml_id_attribute
|
169
187
|
html = ::Asciidoctor.convert(StringIO.new(DOC_ID), backend: 'html5')
|
170
188
|
page = Nokogiri::HTML(html)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-plantuml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Horacio Sanson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|