kramdown-plantuml 1.1.2 → 1.1.3
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/converter.rb +3 -3
- data/lib/kramdown-plantuml/executor.rb +2 -2
- data/lib/kramdown-plantuml/logger.rb +13 -1
- data/lib/kramdown-plantuml/plantuml_result.rb +2 -2
- data/lib/kramdown-plantuml/themer.rb +18 -6
- data/lib/kramdown-plantuml/version.rb +1 -1
- metadata +2 -3
- data/lib/kramdown-plantuml/hash.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51cbb0be0b06278afe3b3d1eb572190a9f7a04fc869454b023854d5d8012e596
|
4
|
+
data.tar.gz: 0e7cb4345aeab6972d3b0009b71ddc714f046f5b558ae1d37b334697af39575b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c18e9c35a4fef278f506106c1365839e7f58b0b45c8b352912187cd324df373b342400e56f51b9c13278ab199fd5fb6101c63cd02aa25ce9efef07722d7c517a
|
7
|
+
data.tar.gz: d822db2c31c38db0f7ce0a5b92221ebf30a55be1f5d011141199d07d94a01b5ddba99a1ba127d13b88219f6135a384d90741315b6e00b88d0e72c20fa1220d2f
|
@@ -18,7 +18,7 @@ module Kramdown
|
|
18
18
|
|
19
19
|
def convert_plantuml_to_svg(plantuml)
|
20
20
|
if plantuml.nil? || plantuml.empty?
|
21
|
-
@logger.warn 'kramdown-plantuml: PlantUML diagram is empty'
|
21
|
+
@logger.warn ' kramdown-plantuml: PlantUML diagram is empty'
|
22
22
|
return plantuml
|
23
23
|
end
|
24
24
|
|
@@ -44,8 +44,8 @@ module Kramdown
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def log(plantuml)
|
47
|
-
@logger.debug 'kramdown-plantuml: PlantUML converting diagram:'
|
48
|
-
@logger.debug_with_prefix 'kramdown-plantuml: ', plantuml
|
47
|
+
@logger.debug ' kramdown-plantuml: PlantUML converting diagram:'
|
48
|
+
@logger.debug_with_prefix ' kramdown-plantuml: ', plantuml
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -26,11 +26,11 @@ module Kramdown
|
|
26
26
|
' -nometadata'
|
27
27
|
end
|
28
28
|
|
29
|
-
@logger.debug "kramdown-plantuml: Executing '#{cmd}'."
|
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 "kramdown-plantuml: PlantUML exit code '#{status.exitstatus}'."
|
33
|
+
@logger.debug " kramdown-plantuml: PlantUML exit code '#{status.exitstatus}'."
|
34
34
|
|
35
35
|
PlantUmlResult.new(stdout, stderr, status)
|
36
36
|
end
|
@@ -4,7 +4,7 @@ require_relative 'console_logger'
|
|
4
4
|
|
5
5
|
module Kramdown
|
6
6
|
module PlantUml
|
7
|
-
#
|
7
|
+
# Logs stuff
|
8
8
|
class Logger
|
9
9
|
def initialize(logger)
|
10
10
|
raise ArgumentError, 'logger cannot be nil' if logger.nil?
|
@@ -45,6 +45,10 @@ module Kramdown
|
|
45
45
|
self.class.level == :debug
|
46
46
|
end
|
47
47
|
|
48
|
+
def level
|
49
|
+
@level ||= level_from_logger || self.class.env
|
50
|
+
end
|
51
|
+
|
48
52
|
class << self
|
49
53
|
def init
|
50
54
|
inner = nil
|
@@ -72,6 +76,14 @@ module Kramdown
|
|
72
76
|
:warn
|
73
77
|
end
|
74
78
|
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def level_from_logger
|
83
|
+
return @logger.level if @logger.respond_to? :level
|
84
|
+
|
85
|
+
nil
|
86
|
+
end
|
75
87
|
end
|
76
88
|
end
|
77
89
|
end
|
@@ -42,8 +42,8 @@ module Kramdown
|
|
42
42
|
|
43
43
|
return if @stderr.nil? || @stderr.empty?
|
44
44
|
|
45
|
-
@logger.debug 'kramdown-plantuml: PlantUML log:'
|
46
|
-
@logger.debug_with_prefix 'kramdown-plantuml: ', @stderr
|
45
|
+
@logger.debug ' kramdown-plantuml: PlantUML log:'
|
46
|
+
@logger.debug_with_prefix ' kramdown-plantuml: ', @stderr
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
require_relative 'hash'
|
4
3
|
require_relative 'logger'
|
5
4
|
|
6
5
|
module Kramdown
|
@@ -10,20 +9,18 @@ module Kramdown
|
|
10
9
|
attr_reader :theme_name, :theme_directory
|
11
10
|
|
12
11
|
def initialize(options = {})
|
13
|
-
options = options.symbolize_keys unless options.nil?
|
14
12
|
@logger = Logger.init
|
15
|
-
@logger.debug "kramdown-plantuml: Options: #{options}"
|
16
13
|
@theme_name, @theme_directory = theme_options(options)
|
17
14
|
end
|
18
15
|
|
19
16
|
def apply_theme(plantuml)
|
20
17
|
if plantuml.nil? || plantuml.empty?
|
21
|
-
@logger.debug 'kramdown-plantuml: Empty diagram.'
|
18
|
+
@logger.debug ' kramdown-plantuml: Empty diagram.'
|
22
19
|
return plantuml
|
23
20
|
end
|
24
21
|
|
25
22
|
if @theme_name.nil? || @theme_name.empty?
|
26
|
-
@logger.debug 'kramdown-plantuml: No theme to apply.'
|
23
|
+
@logger.debug ' kramdown-plantuml: No theme to apply.'
|
27
24
|
return plantuml
|
28
25
|
end
|
29
26
|
|
@@ -33,6 +30,10 @@ module Kramdown
|
|
33
30
|
private
|
34
31
|
|
35
32
|
def theme_options(options)
|
33
|
+
options = symbolize_keys(options)
|
34
|
+
|
35
|
+
@logger.debug " kramdown-plantuml: Options: #{options}"
|
36
|
+
|
36
37
|
return nil if options.nil? || !options.key?(:theme)
|
37
38
|
|
38
39
|
theme = options[:theme] || {}
|
@@ -42,6 +43,17 @@ module Kramdown
|
|
42
43
|
[theme_name, theme_directory]
|
43
44
|
end
|
44
45
|
|
46
|
+
def symbolize_keys(options)
|
47
|
+
return options if options.nil?
|
48
|
+
|
49
|
+
array = options.map do |key, value|
|
50
|
+
value = value.is_a?(Hash) ? symbolize_keys(value) : value
|
51
|
+
[key.to_sym, value]
|
52
|
+
end
|
53
|
+
|
54
|
+
array.to_h
|
55
|
+
end
|
56
|
+
|
45
57
|
def theme(plantuml)
|
46
58
|
startuml = '@startuml'
|
47
59
|
startuml_index = plantuml.index(startuml) + startuml.length
|
@@ -51,7 +63,7 @@ module Kramdown
|
|
51
63
|
theme_string = "\n!theme #{@theme_name}"
|
52
64
|
theme_string << " from #{@theme_directory}" unless @theme_directory.nil?
|
53
65
|
|
54
|
-
@logger.debug "kramdown-plantuml: Applying #{theme_string}"
|
66
|
+
@logger.debug " kramdown-plantuml: Applying #{theme_string.strip}"
|
55
67
|
|
56
68
|
/@startuml.*/.match(plantuml) do |match|
|
57
69
|
return plantuml.insert match.end(0), theme_string
|
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.3
|
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-08-
|
11
|
+
date: 2021-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -173,7 +173,6 @@ files:
|
|
173
173
|
- lib/kramdown-plantuml/console_logger.rb
|
174
174
|
- lib/kramdown-plantuml/converter.rb
|
175
175
|
- lib/kramdown-plantuml/executor.rb
|
176
|
-
- lib/kramdown-plantuml/hash.rb
|
177
176
|
- lib/kramdown-plantuml/logger.rb
|
178
177
|
- lib/kramdown-plantuml/plantuml_error.rb
|
179
178
|
- lib/kramdown-plantuml/plantuml_result.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Ruby's Hash class.
|
4
|
-
class ::Hash
|
5
|
-
# Via https://stackoverflow.com/a/25835016/2257038
|
6
|
-
def symbolize_keys
|
7
|
-
h = map do |k, v|
|
8
|
-
v_sym = v.instance_of?(Hash) ? v.symbolize_keys : v
|
9
|
-
[k.to_sym, v_sym]
|
10
|
-
end
|
11
|
-
|
12
|
-
h.to_h
|
13
|
-
end
|
14
|
-
end
|