jekyll-plantuml-proxy 0.1.5
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.
- checksums.yaml +7 -0
- data/LICENSE.txt +20 -0
- data/README.md +54 -0
- data/lib/jekyll-remote-plantuml.rb +58 -0
- data/lib/plantuml-config.rb +43 -0
- data/lib/plantuml-encode64.rb +90 -0
- data/lib/plantuml-loader.rb +122 -0
- data/test/test_plantuml-encode64.rb +14 -0
- data/test/test_plantuml-loader.rb +66 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 53c625ed38a68ba3facaae5d73322e568bdb2698448ccb902f3bdf2cf02847a7
|
4
|
+
data.tar.gz: d6bd56f3ec06daf291d9ebffd314046fc890998b138b5a58882a41c90e4f8261
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 55d2f3dd72b80d29547ce22e1bac61d78d43863ce140d38199816a3b971667ab809e23eeed6662cefe6d79f91927e79a421efe4573fb6b14c00720caa4bf561d
|
7
|
+
data.tar.gz: 1a1888610f0d0dca070e7ec728fec7eac7ee30d56d9bcc65e503ec41bd34e035daa40fb5c18c1ca39c875c34b771ed54bcd4fd2ff50a7074dc97cdea0e29d2c3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Patrick Allain
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# jekyll-plantuml-proxy
|
2
|
+
|
3
|
+
[](https://hakiri.io/github/Patouche/jekyll-plantuml-proxy/master) [](https://travis-ci.org/Patouche/jekyll-plantuml-proxy)
|
4
|
+
|
5
|
+
|
6
|
+
A plugin for jekyll to use plantuml diagram inside your [Jekyll](http://jekyllrb.com/) for you website. This will use external resource to build plantuml diagram. Once created, the diagram is store on the filesystem to prevent any unnecessary diagram generation. So, using this plugin, provide a simple way to integrate plantuml diagramm without the [Graphiz](http://www.graphviz.org/) software or the using the [plantuml](http://sourceforge.net/projects/plantuml/files/plantuml.jar/download) jar file.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
To install this plugin on Jekyll, you just have to follow the guideline of Jekyll [documentation](http://jekyllrb.com/docs/plugins/)
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
To use the jekyll-plantuml-proxy plugin, you just have to wrap you text between `{% uml %}` and `{% enduml %}` tags.
|
15
|
+
|
16
|
+
For example, to create a basic shema between Bob and Alice, you can write the following code :
|
17
|
+
|
18
|
+
``` text
|
19
|
+
{% uml %}
|
20
|
+
Bob -> Alice : Hello
|
21
|
+
{% enduml %}
|
22
|
+
```
|
23
|
+
|
24
|
+
This will retrieve the binary from a remote provider and add it into the folder defined in your configuration.
|
25
|
+
|
26
|
+

|
27
|
+
|
28
|
+
The generated html will have be something like :
|
29
|
+
|
30
|
+
``` html
|
31
|
+
<img src="/assets/images/plantuml/765f88ab868d9706e797ff2c90c67a549a144c52adf0bf2e247d355cf981b9aa.png" />
|
32
|
+
```
|
33
|
+
|
34
|
+
Any update of the uml will regenerated the image file using the remote. If the uml is not modified, no request will be made on the remote provider.
|
35
|
+
|
36
|
+
## Configuration
|
37
|
+
|
38
|
+
For now, the configuration is really poor. You can just change the remote provider and the location where are store the binary files.
|
39
|
+
|
40
|
+
``` yaml
|
41
|
+
plantuml:
|
42
|
+
url: 'http://www.plantuml.com/plantuml/png/{code}'
|
43
|
+
assets: '_images/plantuml/'
|
44
|
+
```
|
45
|
+
|
46
|
+
### Notes
|
47
|
+
|
48
|
+
I'm sorry if it's sad code for a ruby developper which I'm not. I tried to do my best and to share it with the community. So please be lenient.
|
49
|
+
|
50
|
+
If you have any request, please leave a message and don't hesitate for any pull request.
|
51
|
+
|
52
|
+
## License
|
53
|
+
|
54
|
+
This plugin is under the MIT license. See [LICENSE.txt](./LICENSE.txt) file for more details.
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2015 Patrick Allain
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'jekyll'
|
23
|
+
require 'plantuml-config'
|
24
|
+
require 'plantuml-encode64'
|
25
|
+
require 'plantuml-loader'
|
26
|
+
|
27
|
+
#
|
28
|
+
|
29
|
+
# Jekyll plugin for plantuml generation
|
30
|
+
#
|
31
|
+
# Any generation is store localy to prevent any further call
|
32
|
+
# on a remote provider.
|
33
|
+
module Jekyll
|
34
|
+
|
35
|
+
class PlantUmlBlock < Liquid::Block
|
36
|
+
|
37
|
+
# Plugin initilializer
|
38
|
+
def initialize(tag_name, markup, tokens)
|
39
|
+
super
|
40
|
+
@markup = markup;
|
41
|
+
end
|
42
|
+
|
43
|
+
# Render
|
44
|
+
def render(context)
|
45
|
+
output = super(context);
|
46
|
+
code, pconf, baseurl = PlantUmlEncode64.new(output).encode(), PlantUmlConfig::DEFAULT, Jekyll.configuration({})['baseurl'];
|
47
|
+
p = {:url => pconf[:url], :type => pconf[:type], :code => code }
|
48
|
+
Jekyll.logger.debug "Generate html with input params :", p;
|
49
|
+
d = RemoteLoader.instance.savedRemoteBinary(p);
|
50
|
+
return "<img src=\"%{baseurl}%{uri}\" />" % d.merge({ :baseurl => baseurl });
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
Liquid::Template.register_tag('uml', Jekyll::PlantUmlBlock);
|
58
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2015 Patrick Allain
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'singleton';
|
23
|
+
|
24
|
+
#
|
25
|
+
|
26
|
+
# Jelyll plugin configuration for plantuml plugin.
|
27
|
+
# This will define default value for any missing value in configuration
|
28
|
+
#
|
29
|
+
# @todo : for now, all of this value are not use.
|
30
|
+
class PlantUmlConfig
|
31
|
+
include Singleton
|
32
|
+
|
33
|
+
# Default configuration as a constant hash
|
34
|
+
# If a definition cannot be found in the jekyll configuration, this configuration
|
35
|
+
# will be use
|
36
|
+
DEFAULT = {
|
37
|
+
:assets => '_images/plantuml/',
|
38
|
+
:type => 'png',
|
39
|
+
:encode => 'encode64',
|
40
|
+
:url => 'http://www.plantuml.com/plantuml/{type}/{code}'
|
41
|
+
}
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2015 Patrick Allain
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
# Encode the uml code into a string to provide for building the image with a remote provider.
|
23
|
+
#
|
24
|
+
# This code is inspired by the page of plantuml website http://plantuml.sourceforge.net/codephp.html
|
25
|
+
class PlantUmlEncode64
|
26
|
+
|
27
|
+
def initialize(input)
|
28
|
+
@input = input;
|
29
|
+
end
|
30
|
+
|
31
|
+
# Public : proceed to the encoding for plantuml servlet
|
32
|
+
#
|
33
|
+
# Returns the encoded uml to send to the servlet
|
34
|
+
def encode()
|
35
|
+
require 'zlib';
|
36
|
+
o = @input.force_encoding("utf-8");
|
37
|
+
o = Zlib::Deflate.new(nil, -Zlib::MAX_WBITS).deflate(o, Zlib::FINISH)
|
38
|
+
return PlantUmlEncode64.encode64(o);
|
39
|
+
end
|
40
|
+
|
41
|
+
# Internal : Encode is some special base 64.
|
42
|
+
#
|
43
|
+
# @param a deflate string
|
44
|
+
# Returns a encoded string
|
45
|
+
def self.encode64(input)
|
46
|
+
len, i, out = input.length, 0, "";
|
47
|
+
while i < len do
|
48
|
+
i1 = (i+1 < len) ? input[i+1].ord : 0;
|
49
|
+
i2 = (i+2 < len) ? input[i+2].ord : 0;
|
50
|
+
out += append3bytes(input[i].ord, i1, i2);
|
51
|
+
i += 3;
|
52
|
+
end
|
53
|
+
return out
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.encode6bit(b)
|
57
|
+
if b < 10 then
|
58
|
+
return (48 + b).chr;
|
59
|
+
end
|
60
|
+
|
61
|
+
b -= 10;
|
62
|
+
if b < 26 then
|
63
|
+
return (65 + b).chr;
|
64
|
+
end
|
65
|
+
|
66
|
+
b -= 26;
|
67
|
+
if b < 26 then
|
68
|
+
return (97 + b).chr;
|
69
|
+
end
|
70
|
+
|
71
|
+
b -= 26;
|
72
|
+
if b == 0 then
|
73
|
+
return '-';
|
74
|
+
end
|
75
|
+
|
76
|
+
return (b == 1) ? '_' : '?';
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.append3bytes(b1, b2, b3)
|
80
|
+
c1 = (b1 >> 2)
|
81
|
+
c2 = ((b1 & 0x3) << 4) | (b2 >> 4)
|
82
|
+
c3 = ((b2 & 0xF) << 2) | (b3 >> 6)
|
83
|
+
c4 = b3 & 0x3F;
|
84
|
+
r = encode6bit(c1 & 0x3F)
|
85
|
+
r += encode6bit(c2 & 0x3F);
|
86
|
+
r += encode6bit(c3 & 0x3F);
|
87
|
+
return r + encode6bit(c4 & 0x3F);
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2015 Patrick Allain
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
# Remote loader to retrieve binary or text file from remote url
|
23
|
+
# depending of the parameters provide and the method use
|
24
|
+
#
|
25
|
+
|
26
|
+
require 'digest'
|
27
|
+
require 'fileutils'
|
28
|
+
require 'jekyll';
|
29
|
+
|
30
|
+
require 'singleton'
|
31
|
+
require 'open-uri'
|
32
|
+
require 'plantuml-config'
|
33
|
+
|
34
|
+
# Load data from a remote url.
|
35
|
+
|
36
|
+
#
|
37
|
+
# data is loaded once time. If we can found data in cache, just use
|
38
|
+
# the cache instead of making lot of remote call.
|
39
|
+
class RemoteLoader
|
40
|
+
include Singleton
|
41
|
+
|
42
|
+
# Callback for plain text content
|
43
|
+
CONTENT_CALLBACKS = {
|
44
|
+
'svg' => { :matcher => /\<\?xml.*?\>/, :replacement => '' }
|
45
|
+
}
|
46
|
+
|
47
|
+
# Initialization of the loaded dir
|
48
|
+
#
|
49
|
+
# Define the constant for the prefix url for binary file
|
50
|
+
# and the directory where all file will be saved
|
51
|
+
def initialize()
|
52
|
+
conf = Jekyll.configuration({});
|
53
|
+
initConf = conf['plantuml'] || {};
|
54
|
+
pconf = PlantUmlConfig::DEFAULT.merge(initConf);
|
55
|
+
dirname = conf['source'] + File::SEPARATOR + pconf[:assets].gsub(/\//, File::SEPARATOR).sub(/\/*$/, '').sub(/^\/*/, '');
|
56
|
+
Jekyll.logger.info "Directory for storage remote data : %s" % [dirname],
|
57
|
+
unless File.directory?(dirname) then
|
58
|
+
Jekyll.logger.info "Create directory %s because this seems to be missing" % [dirname]
|
59
|
+
FileUtils.mkdir_p(dirname)
|
60
|
+
end
|
61
|
+
@prefixUrl = pconf[:assets];
|
62
|
+
@dirname = dirname;
|
63
|
+
end
|
64
|
+
|
65
|
+
# Internal : get the url from a config
|
66
|
+
#
|
67
|
+
# @param a hash with {:url, :code, :type } inside it
|
68
|
+
# Returns the url for remote to retrieve
|
69
|
+
def createRemoteUri(params)
|
70
|
+
uri = params[:url];
|
71
|
+
uri = uri.gsub(/\{code\}/, params[:code])
|
72
|
+
uri = uri.gsub(/\{type\}/, params[:type])
|
73
|
+
return uri;
|
74
|
+
end
|
75
|
+
|
76
|
+
# Internal : get the data for the remote connection
|
77
|
+
#
|
78
|
+
# @param a hash with {:url, :code, :type } inside it
|
79
|
+
# Returns the data as a hash
|
80
|
+
def getData(params)
|
81
|
+
ruri = createRemoteUri(params);
|
82
|
+
fn = Digest::SHA256.hexdigest(ruri) + "." + params[:type]
|
83
|
+
return { :remoteUri => ruri, :uri => @prefixUrl + fn, :path => @dirname + File::SEPARATOR + fn }
|
84
|
+
end
|
85
|
+
|
86
|
+
# Public : get and saved the remote uri from a parameters hash
|
87
|
+
# if the same content has already been downloaded previously,
|
88
|
+
# just retrieve return the file information.
|
89
|
+
#
|
90
|
+
# @param a hash with {:url, :code, :type } inside it
|
91
|
+
# Returns a hash with { :remoteUri, :uri, :path }
|
92
|
+
def savedRemoteBinary(params)
|
93
|
+
Jekyll.logger.debug "Plantuml remote loader params :", params;
|
94
|
+
data = getData(params);
|
95
|
+
unless File.exist?(data[:path]) then
|
96
|
+
Jekyll.logger.info "Starting download content at %{remoteUri} done into file %{path}." % data;
|
97
|
+
open(data[:path], 'wb') do |file|
|
98
|
+
file << open(data[:remoteUri]).read
|
99
|
+
Jekyll.logger.info "End download content at %{remoteUri} done into file %{path}." % data;
|
100
|
+
end
|
101
|
+
else
|
102
|
+
Jekyll.logger.info "File %{path} has been found. Not download at %{remoteUri} will be made." % data;
|
103
|
+
end
|
104
|
+
return data;
|
105
|
+
end
|
106
|
+
|
107
|
+
# Public : get and saved the remote uri from a parameters hash
|
108
|
+
# if the same content has already been downloaded previously,
|
109
|
+
# just return the file content.
|
110
|
+
#
|
111
|
+
# @param a hash with {:url, :code, :type } inside it
|
112
|
+
# Returns the content of the remote
|
113
|
+
def loadText(params)
|
114
|
+
d = savedRemoteBinary(params);
|
115
|
+
content, tc = File.read(d[:path]), CONTENT_CALLBACKS[params[:type].downcase];
|
116
|
+
if tc then
|
117
|
+
content = content.gsub(tc[:matcher], tc[:replacement]);
|
118
|
+
end
|
119
|
+
return content;
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'plantuml-encode64'
|
3
|
+
|
4
|
+
class PlantUmlEncode64Test < Minitest::Test
|
5
|
+
|
6
|
+
def setup
|
7
|
+
Jekyll.logger.log_level = :debug
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_encode_one
|
11
|
+
assert_equal "SyfFqhLppCbCJbMmKiX8pSd91m00", PlantUmlEncode64.new("Bob->Alice : hello").encode()
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'plantuml-loader'
|
3
|
+
require 'plantuml-config'
|
4
|
+
require 'jekyll'
|
5
|
+
|
6
|
+
class RemoteLoaderTest < Minitest::Test
|
7
|
+
|
8
|
+
GENERATION_FOLDER = PlantUmlConfig::DEFAULT[:assets].sub(/^\/*/, '');
|
9
|
+
|
10
|
+
ROOT_FOLDER = GENERATION_FOLDER.sub(/^([^\/]+).*$/, '\1');
|
11
|
+
|
12
|
+
GENERATED = "_images/plantuml/1fc2071adfcf94c83cb527ea98c29cae1656a085ff72acb12db7518fe93f1869.png";
|
13
|
+
|
14
|
+
def setup
|
15
|
+
Jekyll.logger.log_level = :debug
|
16
|
+
d = d = Jekyll.configuration({})['source'] + File::SEPARATOR + GENERATION_FOLDER;
|
17
|
+
if !File.exist?(d) then
|
18
|
+
FileUtils.mkdir_p(d);
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def teardown
|
23
|
+
d = Jekyll.configuration({})['source'] + File::SEPARATOR + ROOT_FOLDER;
|
24
|
+
if File.exist?(d) then
|
25
|
+
FileUtils.remove_dir(d);
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_createUri
|
30
|
+
params = { :url => "http://someurl.com/{type}/{code}", :type => "inputType", :code => "inputCode" };
|
31
|
+
assert_equal "http://someurl.com/inputType/inputCode", RemoteLoader.instance.createRemoteUri(params), "uri generation";
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_savedRemoteBinary_checkDownload
|
35
|
+
#skip('Remote connection made')
|
36
|
+
params = { :url => "http://www.plantuml.com/plantuml/{type}/{code}", :type => "png", :code => "SyfFKj2rKt3CoKnELR1Io4ZDoSa70000" };
|
37
|
+
|
38
|
+
obj = RemoteLoader.instance.savedRemoteBinary(params);
|
39
|
+
assert_equal GENERATED, obj[:uri], "file created with defined hash";
|
40
|
+
assert File.exist?(obj[:path]), "file exist";
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_savedRemoteBinary_downloadOnlyOnce
|
44
|
+
#skip('Remote connection made')
|
45
|
+
params = { :url => "http://www.plantuml.com/plantuml/{type}/{code}", :type => "png", :code => "SyfFKj2rKt3CoKnELR1Io4ZDoSa70000" };
|
46
|
+
|
47
|
+
obj = RemoteLoader.instance.savedRemoteBinary(params);
|
48
|
+
assert_equal GENERATED, obj[:uri], "file created with defined hash";;
|
49
|
+
assert File.exist?(obj[:path]), "file exist";;
|
50
|
+
mtime = File.mtime(obj[:path]);
|
51
|
+
|
52
|
+
obj2 = RemoteLoader.instance.savedRemoteBinary(params);
|
53
|
+
assert_equal mtime, File.mtime(obj2[:path]), "file not modified";;
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_loadText
|
57
|
+
#skip('Remote connection made')
|
58
|
+
params = { :url => "http://www.plantuml.com/plantuml/{type}/{code}", :type => "svg", :code => "SyfFKj2rKt3CoKnELR1Io4ZDoSa70000" };
|
59
|
+
|
60
|
+
content = RemoteLoader.instance.loadText(params);
|
61
|
+
refute_nil content, "retrieve content must not be null";
|
62
|
+
assert_match /^\<svg/, content, "start with svg tag";
|
63
|
+
assert_match /<\/svg>$/, content, "end with svg tag";
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-plantuml-proxy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- László Hegedűs
|
8
|
+
- Patouche
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-05-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.5'
|
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: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.4'
|
55
|
+
description: Jekyll to use plantuml with remote provider without any local plantuml.jar
|
56
|
+
installation
|
57
|
+
email: laszlo.hegedus@cherubits.hu
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- LICENSE.txt
|
63
|
+
- README.md
|
64
|
+
- lib/jekyll-remote-plantuml.rb
|
65
|
+
- lib/plantuml-config.rb
|
66
|
+
- lib/plantuml-encode64.rb
|
67
|
+
- lib/plantuml-loader.rb
|
68
|
+
- test/test_plantuml-encode64.rb
|
69
|
+
- test/test_plantuml-loader.rb
|
70
|
+
homepage: http://github.com/lordoftheflies/jekyll-plantuml-proxy
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubygems_version: 3.6.7
|
89
|
+
specification_version: 4
|
90
|
+
summary: Jekyll remote plantuml
|
91
|
+
test_files:
|
92
|
+
- test/test_plantuml-encode64.rb
|
93
|
+
- test/test_plantuml-loader.rb
|