jekyll-remote-plantuml 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/lib/plantuml-config.rb +30 -2
- data/lib/plantuml-encode64.rb +7 -4
- data/lib/plantuml-loader.rb +1 -2
- data/test/test_plantuml-encode64.rb +14 -0
- data/test/test_plantuml-loader.rb +66 -0
- metadata +12 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6e930414f1210fd0acb997f2f5c6b0a6de64104
|
4
|
+
data.tar.gz: 4a5d12faeccfbd0c6a9dc40baf85f9771fd26314
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d406c74e495242ea55581293a9659342aca4c646780cad8b78f9314245e6b23113398df99777eabb3f92b8918df2334c4b0750848851c5108cae60936fc63b3
|
7
|
+
data.tar.gz: 1e7907f9f2174897048c693238cbb10218a65de9e457c03b660d2a74946ca87a56eeb02eea6a6ca89d86f1044cde8782b6287659368a8b2e81806be5bd1f257a
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# jekyll-remote-plantuml
|
2
2
|
|
3
|
+
[![security](https://hakiri.io/github/Patouche/jekyll-remote-plantuml/master.svg)](https://hakiri.io/github/Patouche/jekyll-remote-plantuml/master) [![Build Status](https://travis-ci.org/Patouche/jekyll-remote-plantuml.svg)](https://travis-ci.org/Patouche/jekyll-remote-plantuml)
|
4
|
+
|
5
|
+
|
3
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.
|
4
7
|
|
5
8
|
## Installation
|
@@ -13,9 +16,9 @@ To use the jekyll-remote-plantuml plugin, you just have to wrap you text between
|
|
13
16
|
For example, to create a basic shema between Bob and Alice, you can write the following code :
|
14
17
|
|
15
18
|
``` text
|
16
|
-
{%
|
19
|
+
{% uml %}
|
17
20
|
Bob -> Alice : Hello
|
18
|
-
{%
|
21
|
+
{% enduml %}
|
19
22
|
```
|
20
23
|
|
21
24
|
This will retrieve the binary from a remote provider and add it into the folder defined in your configuration.
|
data/lib/plantuml-config.rb
CHANGED
@@ -1,12 +1,40 @@
|
|
1
|
-
#
|
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.
|
2
21
|
|
3
22
|
require 'singleton';
|
4
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.
|
5
30
|
class PlantUmlConfig
|
6
31
|
include Singleton
|
7
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
|
8
36
|
DEFAULT = {
|
9
|
-
:assets
|
37
|
+
:assets => 'assets/images/plantuml/',
|
10
38
|
:type => 'png',
|
11
39
|
:encode => 'encode64',
|
12
40
|
:url => 'http://www.plantuml.com/plantuml/{type}/{code}'
|
data/lib/plantuml-encode64.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Copyright (c) 2015 Patrick Allain
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
6
|
# this software and associated documentation files (the "Software"), to deal in
|
7
7
|
# the Software without restriction, including without limitation the rights to
|
8
8
|
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
9
|
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
10
|
# subject to the following conditions:
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# The above copyright notice and this permission notice shall be included in all
|
13
13
|
# copies or substantial portions of the Software.
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
16
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
17
|
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
@@ -19,6 +19,9 @@
|
|
19
19
|
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
20
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
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
|
22
25
|
class PlantUmlEncode64
|
23
26
|
|
24
27
|
def initialize(input)
|
data/lib/plantuml-loader.rb
CHANGED
@@ -111,8 +111,7 @@ class RemoteLoader
|
|
111
111
|
# Returns the content of the remote
|
112
112
|
def loadText(params)
|
113
113
|
d = savedRemoteBinary(params);
|
114
|
-
content = File.read(d[:path]);
|
115
|
-
tc = CONTENT_CALLBACKS[params[:type].downcase];
|
114
|
+
content, tc = File.read(d[:path]), CONTENT_CALLBACKS[params[:type].downcase];
|
116
115
|
if tc then
|
117
116
|
content = content.gsub(tc[:matcher], tc[:replacement]);
|
118
117
|
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 = "assets/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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-remote-plantuml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patouche
|
@@ -14,16 +14,16 @@ dependencies:
|
|
14
14
|
name: jekyll
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '2.5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '2.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '5.4'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '5.4'
|
55
55
|
description: Jekyll to use plantuml with remote provider without any local plantuml.jar
|
56
56
|
installation
|
57
57
|
email: patralla@gmail.com
|
@@ -65,6 +65,8 @@ files:
|
|
65
65
|
- lib/plantuml-config.rb
|
66
66
|
- lib/plantuml-encode64.rb
|
67
67
|
- lib/plantuml-loader.rb
|
68
|
+
- test/test_plantuml-encode64.rb
|
69
|
+
- test/test_plantuml-loader.rb
|
68
70
|
homepage: http://github.com/Patouche/jekyll-remote-plantuml
|
69
71
|
licenses:
|
70
72
|
- MIT
|
@@ -89,4 +91,6 @@ rubygems_version: 2.2.2
|
|
89
91
|
signing_key:
|
90
92
|
specification_version: 4
|
91
93
|
summary: Jekyll remote plantuml
|
92
|
-
test_files:
|
94
|
+
test_files:
|
95
|
+
- test/test_plantuml-loader.rb
|
96
|
+
- test/test_plantuml-encode64.rb
|