kramdown-plantuml 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kramdown-plantuml/bool_env.rb +2 -2
- data/lib/kramdown-plantuml/console_logger.rb +1 -1
- data/lib/kramdown-plantuml/converter.rb +11 -1
- data/lib/kramdown-plantuml/executor.rb +2 -2
- data/lib/kramdown-plantuml/logger.rb +15 -6
- data/lib/kramdown-plantuml/plantuml_result.rb +2 -1
- data/lib/kramdown-plantuml/themer.rb +29 -15
- data/lib/kramdown-plantuml/version.rb +1 -1
- 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: 494e1d003f565fb2e076daa61be11c187248776f6ab76145d7c4f6963d771355
|
4
|
+
data.tar.gz: 2acbb2c1e2142dbfb1e732013a63f70a9a70d65a6e77c4107970b151a25736b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed8130982476ebe4b9bda233ef2f9bef82bcc9519d5ad9bc463b5d4f2bc858b9357d2a190567261616f7fbf2b485554e4e6895235a104d0159a25a42abe87af1
|
7
|
+
data.tar.gz: 2423d0759e06ff233f11904c94aaccb5d61d37aa3f2748352b6df3990d7ed49d683c7e5b4456e34ac32db7592bb3a65a3e668f549a08b4e768c0800a0fe281a2
|
@@ -9,8 +9,8 @@ module Kramdown
|
|
9
9
|
|
10
10
|
def initialize(name)
|
11
11
|
@name = name
|
12
|
-
|
13
|
-
@value =
|
12
|
+
value = ENV.fetch(name, nil)
|
13
|
+
@value = value.to_s.downcase unless value.nil?
|
14
14
|
end
|
15
15
|
|
16
16
|
def true?
|
@@ -17,9 +17,14 @@ module Kramdown
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def convert_plantuml_to_svg(plantuml)
|
20
|
+
if plantuml.nil? || plantuml.empty?
|
21
|
+
@logger.warn 'kramdown-plantuml: PlantUML diagram is empty'
|
22
|
+
return plantuml
|
23
|
+
end
|
24
|
+
|
20
25
|
plantuml = @themer.apply_theme(plantuml)
|
21
26
|
plantuml = plantuml.strip
|
22
|
-
|
27
|
+
log(plantuml)
|
23
28
|
result = @executor.execute(plantuml)
|
24
29
|
result.validate(plantuml)
|
25
30
|
svg = result.without_xml_prologue
|
@@ -37,6 +42,11 @@ module Kramdown
|
|
37
42
|
|
38
43
|
"#{wrapper_element_start}#{svg}#{wrapper_element_end}"
|
39
44
|
end
|
45
|
+
|
46
|
+
def log(plantuml)
|
47
|
+
@logger.debug 'kramdown-plantuml: PlantUML converting diagram:'
|
48
|
+
@logger.debug_with_prefix 'kramdown-plantuml: ', plantuml
|
49
|
+
end
|
40
50
|
end
|
41
51
|
end
|
42
52
|
end
|
@@ -26,11 +26,11 @@ module Kramdown
|
|
26
26
|
' -nometadata'
|
27
27
|
end
|
28
28
|
|
29
|
-
@logger.debug "
|
29
|
+
@logger.debug "kramdown-plantuml: Executing '#{cmd}'."
|
30
30
|
|
31
31
|
stdout, stderr, status = Open3.capture3 cmd, stdin_data: stdin
|
32
32
|
|
33
|
-
@logger.debug "PlantUML exit code
|
33
|
+
@logger.debug "kramdown-plantuml: PlantUML exit code '#{status.exitstatus}'."
|
34
34
|
|
35
35
|
PlantUmlResult.new(stdout, stderr, status)
|
36
36
|
end
|
@@ -17,19 +17,28 @@ module Kramdown
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def debug(message)
|
20
|
-
@logger.debug
|
20
|
+
@logger.debug message
|
21
|
+
end
|
22
|
+
|
23
|
+
def debug_with_prefix(prefix, string)
|
24
|
+
return if string.nil? || string.empty?
|
25
|
+
|
26
|
+
lines = string.lines
|
27
|
+
lines.each do |line|
|
28
|
+
@logger.debug "#{prefix}#{line.rstrip}"
|
29
|
+
end
|
21
30
|
end
|
22
31
|
|
23
32
|
def info(message)
|
24
|
-
@logger.info
|
33
|
+
@logger.info message
|
25
34
|
end
|
26
35
|
|
27
36
|
def warn(message)
|
28
|
-
@logger.warn
|
37
|
+
@logger.warn message
|
29
38
|
end
|
30
39
|
|
31
40
|
def error(message)
|
32
|
-
@logger.error
|
41
|
+
@logger.error message
|
33
42
|
end
|
34
43
|
|
35
44
|
def debug?
|
@@ -44,10 +53,10 @@ module Kramdown
|
|
44
53
|
require 'jekyll'
|
45
54
|
inner = Jekyll.logger
|
46
55
|
rescue LoadError
|
47
|
-
inner = ConsoleLogger.new
|
56
|
+
inner = ConsoleLogger.new level
|
48
57
|
end
|
49
58
|
|
50
|
-
Logger.new
|
59
|
+
Logger.new inner
|
51
60
|
end
|
52
61
|
|
53
62
|
def level
|
@@ -10,34 +10,30 @@ module Kramdown
|
|
10
10
|
attr_reader :theme_name, :theme_directory
|
11
11
|
|
12
12
|
def initialize(options = {})
|
13
|
-
options = options.symbolize_keys
|
13
|
+
options = options.symbolize_keys unless options.nil?
|
14
14
|
@logger = Logger.init
|
15
|
-
@logger.debug
|
15
|
+
@logger.debug "kramdown-plantuml: Options: #{options}"
|
16
16
|
@theme_name, @theme_directory = theme_options(options)
|
17
17
|
end
|
18
18
|
|
19
19
|
def apply_theme(plantuml)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
return plantuml if startuml_index.nil?
|
26
|
-
|
27
|
-
/@startuml.*/.match(plantuml) do |match|
|
28
|
-
theme_string = "\n!theme #{@theme_name}"
|
29
|
-
theme_string << " from #{@theme_directory}" unless @theme_directory.nil?
|
20
|
+
if plantuml.nil? || plantuml.empty?
|
21
|
+
@logger.debug 'kramdown-plantuml: Empty diagram.'
|
22
|
+
return plantuml
|
23
|
+
end
|
30
24
|
|
31
|
-
|
25
|
+
if @theme_name.nil? || @theme_name.empty?
|
26
|
+
@logger.debug 'kramdown-plantuml: No theme to apply.'
|
27
|
+
return plantuml
|
32
28
|
end
|
33
29
|
|
34
|
-
plantuml
|
30
|
+
theme(plantuml)
|
35
31
|
end
|
36
32
|
|
37
33
|
private
|
38
34
|
|
39
35
|
def theme_options(options)
|
40
|
-
return nil
|
36
|
+
return nil if options.nil? || !options.key?(:theme)
|
41
37
|
|
42
38
|
theme = options[:theme] || {}
|
43
39
|
theme_name = theme.key?(:name) ? theme[:name] : nil
|
@@ -45,6 +41,24 @@ module Kramdown
|
|
45
41
|
|
46
42
|
[theme_name, theme_directory]
|
47
43
|
end
|
44
|
+
|
45
|
+
def theme(plantuml)
|
46
|
+
startuml = '@startuml'
|
47
|
+
startuml_index = plantuml.index(startuml) + startuml.length
|
48
|
+
|
49
|
+
return plantuml if startuml_index.nil?
|
50
|
+
|
51
|
+
theme_string = "\n!theme #{@theme_name}"
|
52
|
+
theme_string << " from #{@theme_directory}" unless @theme_directory.nil?
|
53
|
+
|
54
|
+
@logger.debug "kramdown-plantuml: Applying #{theme_string}"
|
55
|
+
|
56
|
+
/@startuml.*/.match(plantuml) do |match|
|
57
|
+
return plantuml.insert match.end(0), theme_string
|
58
|
+
end
|
59
|
+
|
60
|
+
plantuml
|
61
|
+
end
|
48
62
|
end
|
49
63
|
end
|
50
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kramdown-plantuml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Swedbank Pay
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|