kramdown-plantuml 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -4,13 +4,14 @@
4
4
  ![Build][build-badge]
5
5
  ![No Java][no-java-build-badge]
6
6
  ![No PlantUML][no-plantuml-badge]
7
- [![MIT License][license-badge]][license]
7
+ [![License][license-badge]][license]
8
+ [![Dependabot Status][dependabot-badge]][dependabot]
8
9
  [![CLA assistant][cla-badge]][cla]
9
10
  [![Contributor Covenant][coc-badge]][coc]
10
11
 
11
12
  `kramdown-plantuml` allows you to use [PlantUML][plantuml] syntax within [fenced
12
- code blocks][fenced] in [Jekyll] with its default [Kramdown][kramdown] Markdown
13
- parser:
13
+ code blocks][fenced] in [Kramdown][kramdown] ([Jekyll][jekyll]'s default
14
+ Markdown parser):
14
15
 
15
16
  ````md
16
17
  ```plantuml
@@ -87,34 +88,33 @@ git commits and tags, and push the `.gem` file to [rubygems.org][gems].
87
88
 
88
89
  Bug reports and pull requests are welcome on [GitHub][github]. This project is
89
90
  intended to be a safe, welcoming space for collaboration, and contributors are
90
- expected to adhere to the [code of conduct][coc] and sign the [contributor's
91
- license agreement][cla].
91
+ expected to adhere to the [code of conduct][coc] and sign the
92
+ [contributor's license agreement][cla].
92
93
 
93
94
  ## License
94
95
 
95
- The gem is available as open source under the terms of the [MIT
96
- License][license].
97
-
98
- ## Code of Conduct
99
-
100
- Everyone interacting in the Kramdown::PlantUml project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct][coc].
101
-
102
- [plantuml]: https://plantuml.com/
103
- [jekyll]: https://jekyllrb.com/
104
- [kramdown]: https://kramdown.gettalong.org/
105
- [gems]: https://rubygems.org
106
- [github]: https://github.com/SwedbankPay/kramdown-plantuml/
107
- [coc]: ./CODE_OF_CONDUCT.md
108
- [coc-badge]: https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg
109
- [cla]: https://cla-assistant.io/SwedbankPay/kramdown-plantuml
110
- [cla-badge]: https://cla-assistant.io/readme/badge/SwedbankPay/design.swedbankpay.com
111
- [license]: https://opensource.org/licenses/MIT
112
- [license-badge]: https://img.shields.io/github/license/SwedbankPay/kramdown-plantuml
113
- [fenced]: https://www.markdownguide.org/extended-syntax/#syntax-highlighting
114
- [svg]: https://developer.mozilla.org/en-US/docs/Web/SVG
115
- [diagram-svg]: spec/diagram.svg
116
- [gem-badge]: https://badge.fury.io/rb/kramdown-plantuml.svg
117
- [gem-url]: https://rubygems.org/gems/kramdown-plantuml
118
- [build-badge]: https://github.com/SwedbankPay/kramdown-plantuml/workflows/Ruby%20Gem/badge.svg?branch=master
119
- [no-java-build-badge]: https://github.com/SwedbankPay/kramdown-plantuml/workflows/No%20Java/badge.svg?branch=master
120
- [no-plantuml-badge]: https://github.com/SwedbankPay/kramdown-plantuml/workflows/No%20PlantUML/badge.svg?branch=master
96
+ The code within this repository is available as open source under the terms of
97
+ the [Apache 2.0 License][license] and the [contributor's license
98
+ agreement][cla].
99
+
100
+ [build-badge]: https://github.com/SwedbankPay/kramdown-plantuml/workflows/Ruby%20Gem/badge.svg?branch=master
101
+ [cla-badge]: https://cla-assistant.io/readme/badge/SwedbankPay/kramdown-plantuml
102
+ [cla]: https://cla-assistant.io/SwedbankPay/kramdown-plantuml
103
+ [coc-badge]: https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg
104
+ [coc]: ./CODE_OF_CONDUCT.md
105
+ [dependabot-badge]: https://api.dependabot.com/badges/status?host=github&repo=SwedbankPay/kramdown-plantuml
106
+ [dependabot]: https://dependabot.com
107
+ [diagram-svg]: ./spec/diagram.svg
108
+ [fenced]: https://www.markdownguide.org/extended-syntax/#syntax-highlighting
109
+ [gem-badge]: https://badge.fury.io/rb/kramdown-plantuml.svg
110
+ [gem-url]: https://rubygems.org/gems/kramdown-plantuml
111
+ [gems]: https://rubygems.org
112
+ [github]: https://github.com/SwedbankPay/kramdown-plantuml/
113
+ [jekyll]: https://jekyllrb.com/
114
+ [kramdown]: https://kramdown.gettalong.org/
115
+ [license-badge]: https://img.shields.io/github/license/SwedbankPay/kramdown-plantuml
116
+ [license]: https://opensource.org/licenses/Apache-2.0
117
+ [no-java-build-badge]: https://github.com/SwedbankPay/kramdown-plantuml/workflows/No%20Java/badge.svg?branch=master
118
+ [no-plantuml-badge]: https://github.com/SwedbankPay/kramdown-plantuml/workflows/No%20PlantUML/badge.svg?branch=master
119
+ [plantuml]: https://plantuml.com/
120
+ [svg]: https://developer.mozilla.org/en-US/docs/Web/SVG
data/Rakefile CHANGED
@@ -1,10 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake'
2
4
  require 'bundler/gem_tasks'
3
5
  require 'rspec/core/rake_task'
4
6
 
5
7
  RSpec::Core::RakeTask.new(:spec) do |t|
6
- t.pattern = Dir.glob('spec/**/*_spec.rb')
7
- t.rspec_opts = '--format documentation --tag ~no_plantuml --tag ~no_java'
8
+ t.pattern = Dir.glob('spec/**/*_spec.rb')
9
+ t.rspec_opts = '--format documentation --tag ~no_plantuml --tag ~no_java'
10
+ end
11
+
12
+ namespace :codecov do
13
+ desc 'Uploads the latest SimpleCov result set to codecov.io'
14
+ task :upload do
15
+ require 'simplecov'
16
+ require 'codecov'
17
+
18
+ formatter = SimpleCov::Formatter::Codecov.new
19
+ formatter.format(SimpleCov::ResultMerger.merged_result)
20
+ end
8
21
  end
9
22
 
10
- task :default => :spec
23
+ task default: :spec
@@ -1,33 +1,41 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'lib/which'
2
4
  require_relative 'lib/kramdown-plantuml/version'
3
5
 
4
6
  Gem::Specification.new do |spec|
5
- spec.name = "kramdown-plantuml"
7
+ spec.name = 'kramdown-plantuml'
6
8
  spec.version = Kramdown::PlantUml::VERSION
7
- spec.authors = ["Asbjørn Ulsberg"]
8
- spec.email = ["asbjorn@ulsberg.no"]
9
+ spec.authors = ['Swedbank Pay']
10
+ spec.email = ['opensource@swedbankpay.com']
9
11
 
10
- spec.summary = "Short summary"
11
- spec.homepage = "https://github.com/SwedbankPay/kramdown-plantuml"
12
- spec.license = "MIT"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
12
+ spec.summary = "kramdown-plantuml allows you to use PlantUML syntax within fenced code blocks with Kramdown (Jekyll's default Markdown parser)"
13
+ spec.homepage = 'https://github.com/SwedbankPay/kramdown-plantuml'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
14
16
 
15
- spec.metadata["homepage_uri"] = spec.homepage
16
- spec.metadata["source_code_uri"] = "https://github.com/SwedbankPay/kramdown-plantuml"
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://github.com/SwedbankPay/kramdown-plantuml'
17
19
 
18
20
  # Specify which files should be added to the gem when it is released.
19
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
- if Which::which('git')
22
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into Git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ if Which.which('git')
24
+ files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ # Explicitly add plantuml.jar to the list of files as it is not committed to Git.
26
+ files.append(Dir['bin/**/plantuml*.jar'].first)
23
27
  else
24
28
  puts "Git not found, no files added to #{spec.name}."
25
29
  end
26
30
  end
27
- spec.bindir = "exe"
31
+ spec.bindir = 'exe'
28
32
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
- spec.require_paths = ["lib"]
33
+ spec.require_paths = ['lib']
34
+
35
+ spec.add_dependency 'kramdown', '~> 2.3'
36
+ spec.add_dependency 'open3', '~> 0.1'
30
37
 
31
- spec.add_development_dependency "rake", "~> 13.0"
32
- spec.add_development_dependency "rspec", "~> 3.2"
38
+ spec.add_development_dependency 'rake', '~> 13.0'
39
+ spec.add_development_dependency 'rspec', '~> 3.2'
40
+ spec.add_development_dependency 'rubocop', '~> 0.92'
33
41
  end
@@ -1,7 +1,11 @@
1
- require 'kramdown-plantuml/version'
2
- require 'kramdown-plantuml/converter'
3
- require 'kramdown_html'
1
+ # frozen_string_literal: true
4
2
 
5
- module Kramdown::PlantUml
3
+ require_relative 'kramdown-plantuml/version'
4
+ require_relative 'kramdown-plantuml/converter'
5
+ require_relative 'kramdown_html'
6
+
7
+ module Kramdown
8
+ module PlantUml
6
9
  class Error < StandardError; end
10
+ end
7
11
  end
@@ -1,45 +1,44 @@
1
- require 'which'
1
+ # frozen_string_literal: true
2
+
2
3
  require 'open3'
4
+ require_relative '../which'
3
5
  require_relative 'version'
4
6
 
5
- module Kramdown::PlantUml
6
- class Converter
7
- def initialize
8
- dir = File.dirname __dir__
9
- bin = File.join dir, "../bin"
10
- bin = File.expand_path bin
11
- @plant_uml_jar_file = File.join bin, "plantuml.1.2020.5.jar"
12
-
13
- if not File.exists? @plant_uml_jar_file
14
- raise IOError.new("'#{@plant_uml_jar_file}' does not exist")
7
+ module Kramdown
8
+ module PlantUml
9
+ # Converts PlantUML markup to SVG
10
+ class Converter
11
+ def initialize
12
+ dir = File.dirname __dir__
13
+ jar_glob = File.join dir, '../bin/**/plantuml*.jar'
14
+ @plant_uml_jar_file = Dir[jar_glob].first
15
+
16
+ raise IOError, 'Java can not be found' unless Which.which('java')
17
+ raise IOError, "No 'plantuml.jar' file could be found" if @plant_uml_jar_file.nil?
18
+ raise IOError, "'#{@plant_uml_jar_file}' does not exist" unless File.exist? @plant_uml_jar_file
15
19
  end
16
20
 
17
- unless Which::which("java")
18
- raise IOError.new("Java can not be found")
19
- end
20
- end
21
+ def convert_plantuml_to_svg(content)
22
+ cmd = "java -jar #{@plant_uml_jar_file} -tsvg -pipe"
21
23
 
22
- def convert_plantuml_to_svg(content)
23
- cmd = "java -jar #{@plant_uml_jar_file} -tsvg -pipe"
24
+ stdout, stderr, = Open3.capture3(cmd, stdin_data: content)
24
25
 
25
- stdout, stderr, _ = Open3.capture3(cmd, :stdin_data => content)
26
+ # Circumvention of https://bugs.openjdk.java.net/browse/JDK-8244621
27
+ raise stderr unless stderr.empty? || stderr.include?('CoreText note:')
26
28
 
27
- unless stderr.empty?
28
- raise stderr
29
- end
30
-
31
- xml_prologue_start = "<?xml"
32
- xml_prologue_end = "?>"
29
+ xml_prologue_start = '<?xml'
30
+ xml_prologue_end = '?>'
33
31
 
34
- start_index = stdout.index(xml_prologue_start)
35
- end_index = stdout.index(xml_prologue_end, xml_prologue_start.length) + xml_prologue_end.length
32
+ start_index = stdout.index(xml_prologue_start)
33
+ end_index = stdout.index(xml_prologue_end, xml_prologue_start.length) + xml_prologue_end.length
36
34
 
37
- stdout.slice! start_index, end_index
35
+ stdout.slice! start_index, end_index
38
36
 
39
- wrapper_element_start = "<div class=\"plantuml\">"
40
- wrapper_element_end = "</div>"
37
+ wrapper_element_start = '<div class="plantuml">'
38
+ wrapper_element_end = '</div>'
41
39
 
42
- return "#{wrapper_element_start}#{stdout}#{wrapper_element_end}"
40
+ "#{wrapper_element_start}#{stdout}#{wrapper_element_end}"
41
+ end
43
42
  end
44
43
  end
45
44
  end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kramdown
2
4
  module PlantUml
3
- @version = ENV['GEM_VERSION'] || '0.0.1-INVALID'
4
- VERSION = @version
5
+ VERSION = '1.0.5'
5
6
  end
6
7
  end
@@ -1,15 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'kramdown'
2
- require "kramdown-plantuml/converter"
4
+ require_relative 'kramdown-plantuml/converter'
5
+
6
+ PlantUmlConverter = Kramdown::PlantUml::Converter
3
7
 
4
- class Kramdown::Converter::Html
5
- alias_method :super_convert_codeblock, :convert_codeblock
8
+ module Kramdown
9
+ module Converter
10
+ # Plugs into Kramdown::Converter::Html to provide conversion of PlantUML markup
11
+ # into beautiful SVG.
12
+ class Html
13
+ alias super_convert_codeblock convert_codeblock
6
14
 
7
- def convert_codeblock(element, indent)
8
- if element.attr["class"] != "language-plantuml"
9
- return super_convert_codeblock(element, indent)
10
- end
15
+ def convert_codeblock(element, indent)
16
+ return super_convert_codeblock(element, indent) if element.attr['class'] != 'language-plantuml'
11
17
 
12
- converter = Kramdown::PlantUml::Converter.new
13
- return converter.convert_plantuml_to_svg(element.value)
18
+ converter = PlantUmlConverter.new
19
+ converter.convert_plantuml_to_svg(element.value)
20
+ end
14
21
  end
22
+ end
15
23
  end
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Wraps the `which` Unix utility
1
4
  class Which
2
5
  def self.which(cmd)
3
6
  exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
data/pom.xml ADDED
@@ -0,0 +1,16 @@
1
+ <project xmlns="http://maven.apache.org/POM/4.0.0"
2
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
3
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
+ <modelVersion>4.0.0</modelVersion>
5
+ <groupId>com.swedbankpay</groupId>
6
+ <artifactId>kramdown-plantuml</artifactId>
7
+ <version>INVALID</version>
8
+ <name>Kramdown::PlantUml</name>
9
+ <dependencies>
10
+ <dependency>
11
+ <groupId>net.sourceforge.plantuml</groupId>
12
+ <artifactId>plantuml</artifactId>
13
+ <version>1.2020.18</version>
14
+ </dependency>
15
+ </dependencies>
16
+ </project>
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kramdown-plantuml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
- - Asbjørn Ulsberg
7
+ - Swedbank Pay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-28 00:00:00.000000000 Z
11
+ date: 2020-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: kramdown
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: open3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: rake
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -38,32 +66,53 @@ dependencies:
38
66
  - - "~>"
39
67
  - !ruby/object:Gem::Version
40
68
  version: '3.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.92'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.92'
41
83
  description:
42
84
  email:
43
- - asbjorn@ulsberg.no
85
+ - opensource@swedbankpay.com
44
86
  executables: []
45
87
  extensions: []
46
88
  extra_rdoc_files: []
47
89
  files:
90
+ - ".github/scripts/build-gem.sh"
91
+ - ".github/scripts/bundle-install.sh"
92
+ - ".github/scripts/inspect-gem.sh"
93
+ - ".github/scripts/publish-gem.sh"
94
+ - ".github/scripts/test-gem.sh"
95
+ - ".github/scripts/variables.sh"
48
96
  - ".github/workflows/no-java.yml"
49
97
  - ".github/workflows/no-plantuml.yml"
50
98
  - ".github/workflows/ruby.yml"
99
+ - ".github/workflows/shell.yml"
51
100
  - ".gitignore"
52
101
  - ".rspec"
102
+ - ".rubocop.yml"
53
103
  - CODE_OF_CONDUCT.md
54
104
  - Gemfile
55
105
  - LICENSE
56
106
  - README.md
57
107
  - Rakefile
58
- - bin/console
59
- - bin/plantuml.1.2020.5.jar
60
- - bin/setup
108
+ - bin/net/sourceforge/plantuml/plantuml/1.2020.18/plantuml-1.2020.18.jar
61
109
  - kramdown-plantuml.gemspec
62
110
  - lib/kramdown-plantuml.rb
63
111
  - lib/kramdown-plantuml/converter.rb
64
112
  - lib/kramdown-plantuml/version.rb
65
113
  - lib/kramdown_html.rb
66
114
  - lib/which.rb
115
+ - pom.xml
67
116
  homepage: https://github.com/SwedbankPay/kramdown-plantuml
68
117
  licenses:
69
118
  - MIT
@@ -85,8 +134,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
134
  - !ruby/object:Gem::Version
86
135
  version: '0'
87
136
  requirements: []
88
- rubygems_version: 3.0.3
137
+ rubygems_version: 3.1.2
89
138
  signing_key:
90
139
  specification_version: 4
91
- summary: Short summary
140
+ summary: kramdown-plantuml allows you to use PlantUML syntax within fenced code blocks
141
+ with Kramdown (Jekyll's default Markdown parser)
92
142
  test_files: []
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "kramdown-plantuml"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)