kramdown-plantuml 1.0.4 → 1.1.3

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.github/codecov.yml +2 -0
  3. data/.github/dependabot.yml +23 -0
  4. data/.github/mergify.yml +22 -0
  5. data/.github/scripts/amend.sh +176 -0
  6. data/.github/scripts/build-gem.sh +6 -0
  7. data/.github/scripts/inspect-gem.sh +72 -0
  8. data/.github/scripts/publish-gem.sh +121 -0
  9. data/.github/scripts/test-gem.sh +170 -0
  10. data/.github/scripts/variables.sh +72 -0
  11. data/.github/workflows/amend.yml +19 -0
  12. data/.github/workflows/no-java.yml +3 -6
  13. data/.github/workflows/no-plantuml.yml +6 -9
  14. data/.github/workflows/ruby.yml +135 -81
  15. data/.github/workflows/shell.yml +11 -0
  16. data/.gitignore +9 -0
  17. data/.rubocop.yml +18 -0
  18. data/Gemfile +4 -8
  19. data/GitVersion.yml +5 -0
  20. data/LICENSE +201 -21
  21. data/README.md +130 -42
  22. data/Rakefile +33 -3
  23. data/bin/{plantuml.1.2020.5.jar → net/sourceforge/plantuml/plantuml/1.2021.8/plantuml-1.2021.8.jar} +0 -0
  24. data/kramdown-plantuml.gemspec +32 -17
  25. data/lib/kramdown-plantuml.rb +4 -6
  26. data/lib/kramdown-plantuml/bool_env.rb +24 -0
  27. data/lib/kramdown-plantuml/console_logger.rb +56 -0
  28. data/lib/kramdown-plantuml/converter.rb +40 -33
  29. data/lib/kramdown-plantuml/executor.rb +48 -0
  30. data/lib/kramdown-plantuml/logger.rb +89 -0
  31. data/lib/kramdown-plantuml/plantuml_error.rb +33 -0
  32. data/lib/kramdown-plantuml/plantuml_result.rb +50 -0
  33. data/lib/kramdown-plantuml/themer.rb +76 -0
  34. data/lib/kramdown-plantuml/version.rb +3 -2
  35. data/lib/kramdown_html.rb +21 -9
  36. data/lib/which.rb +3 -0
  37. data/pom.xml +16 -0
  38. metadata +128 -10
  39. data/bin/console +0 -14
  40. data/bin/setup +0 -8
@@ -0,0 +1,72 @@
1
+ #!/bin/bash
2
+ set -o errexit # Abort if any command fails
3
+ me=$(basename "$0")
4
+
5
+ help_message="\
6
+ Usage: echo $me <version>
7
+ Generates variables based on the provided environment variable GITHUB_CONTEXT
8
+ and <version> argument.
9
+ GITHUB_CONTEXT: An environment variable containing a JSON string of the GitHub
10
+ context object. Typically generated with \${{ toJson(github) }}.
11
+ <version>: The version number corresponding to the current Git commit."
12
+
13
+ initialize() {
14
+ github_context_json="$GITHUB_CONTEXT"
15
+ version="$1"
16
+
17
+ if [[ -z "$github_context_json" ]]; then
18
+ echo "Missing or empty GITHUB_CONTEXT environment variable." >&2
19
+ echo "$help_message"
20
+ exit 1
21
+ fi
22
+
23
+ if [[ -z "$version" ]]; then
24
+ echo "No version specified." >&2
25
+ echo "$help_message"
26
+ exit 1
27
+ fi
28
+
29
+ sha=$(echo "$github_context_json" | jq --raw-output .sha)
30
+ ref=$(echo "$github_context_json" | jq --raw-output .ref)
31
+
32
+ if [[ -z "$sha" ]]; then
33
+ echo "No 'sha' found in the GitHub context." >&2
34
+ echo "$help_message"
35
+ exit 1
36
+ fi
37
+
38
+ if [[ -z "$ref" ]]; then
39
+ echo "No 'ref' found in the GitHub context." >&2
40
+ echo "$help_message"
41
+ exit 1
42
+ fi
43
+ }
44
+
45
+ generate_variables() {
46
+ # Replace '+'' in the version number with '.'.
47
+ version="${version//+/.}"
48
+ # Replace '-' in the version number with '.'.
49
+ version="${version//-/.}"
50
+
51
+ if [[ "$ref" == refs/tags/* ]]; then
52
+ # Override GitVersion's version on tags, just to be sure.
53
+ version="${ref#refs/tags/}"
54
+ fi
55
+
56
+ # Convert the version number to all-lowercase because GPR only supports lowercase version numbers.
57
+ version=$(echo "$version" | tr '[:upper:]' '[:lower:]')
58
+
59
+ echo "Ref: $ref"
60
+ echo "Sha: $sha"
61
+ echo "Version: $version"
62
+ echo "::set-output name=ref::$ref"
63
+ echo "::set-output name=sha::$sha"
64
+ echo "::set-output name=version::$version"
65
+ }
66
+
67
+ main() {
68
+ initialize "$@"
69
+ generate_variables
70
+ }
71
+
72
+ main "$@"
@@ -0,0 +1,19 @@
1
+ name: amend
2
+
3
+ on:
4
+ issue_comment:
5
+ types: [created]
6
+
7
+ jobs:
8
+ amend:
9
+ if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/amend')
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ with:
14
+ persist-credentials: false
15
+ - name: amend
16
+ env:
17
+ GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_TOKEN }}
18
+ GITHUB_CONTEXT: ${{ toJSON(github) }}
19
+ run: .github/scripts/amend.sh --user payex-dev --verbose
@@ -8,18 +8,15 @@ on:
8
8
 
9
9
  jobs:
10
10
  test:
11
- name: No Java
12
11
  runs-on: ubuntu-latest
13
12
  container:
14
- image: ruby:2.7.0-alpine3.11
13
+ image: ruby:2.7.2
15
14
 
16
15
  steps:
17
16
  - uses: actions/checkout@v2
18
17
 
19
18
  - name: Bundle install
20
- run: |
21
- find .
22
- bundle install --jobs 4 --retry 3
19
+ run: bundle install --jobs 4 --retry 3
23
20
 
24
- - name: Test with Rake
21
+ - name: RSpec
25
22
  run: bundle exec rspec --tag no_java
@@ -8,19 +8,16 @@ on:
8
8
 
9
9
  jobs:
10
10
  test:
11
- name: No PlantUML
12
11
  runs-on: ubuntu-latest
13
- container:
14
- image: ruby:2.7.0-alpine3.11
15
12
 
16
13
  steps:
17
14
  - uses: actions/checkout@v2
18
15
 
19
- - name: Bundle install
20
- run: bundle install --jobs 4 --retry 3
16
+ - name: Set up Ruby 2.7
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: 2.7
20
+ bundler-cache: true
21
21
 
22
- - name: Remove plantuml.1.2020.5.jar
23
- run: rm bin/plantuml.1.2020.5.jar
24
-
25
- - name: Test with Rake
22
+ - name: RSpec
26
23
  run: bundle exec rspec --tag no_plantuml
@@ -1,122 +1,176 @@
1
1
  name: Ruby Gem
2
2
 
3
- on:
4
- push:
5
- branches:
6
- - '*'
7
- tags:
8
- - '*'
9
- pull_request:
3
+ on: [push, pull_request, pull_request_target]
10
4
 
11
5
  jobs:
12
- build:
13
- name: Build, Test and Publish Ruby Gem
6
+ version:
14
7
  runs-on: ubuntu-latest
15
8
 
9
+ outputs:
10
+ version: ${{ steps.variables.outputs.version }}
11
+
16
12
  steps:
17
13
  - uses: actions/checkout@v2
18
14
  with:
19
15
  fetch-depth: 0
20
16
 
21
- - name: Fetch all history for all tags and branches
22
- run: |
23
- git fetch --prune --tags
24
- echo "REF: ${{ github.ref }}"
25
-
26
- - name: Install GitVersion
27
- uses: gittools/actions/gitversion/setup@v0.9.2
28
- if: startsWith(github.ref, 'refs/tags/') != true # Only use GitVersion for unstable builds
17
+ - name: Setup GitVersion
18
+ uses: gittools/actions/gitversion/setup@v0.9.10
29
19
  with:
30
- versionSpec: '5.2.x'
20
+ versionSpec: '5.x.x'
31
21
 
32
22
  - name: Execute GitVersion
33
23
  id: gitversion
34
- if: startsWith(github.ref, 'refs/tags/') != true
35
- uses: gittools/actions/gitversion/execute@v0.9.2
24
+ uses: gittools/actions/gitversion/execute@v0.9.10
25
+
26
+ - name: Create variables
27
+ id: variables
28
+ env:
29
+ GITHUB_CONTEXT: ${{ toJson(github) }}
30
+ run: ./.github/scripts/variables.sh ${{ steps.gitversion.outputs.fullSemVer }}
36
31
 
37
- - name: Create gem version number
38
- id: gemversion
39
- uses: actions/github-script@0.9.0
32
+ plantuml:
33
+ needs: version
34
+ runs-on: ubuntu-latest
35
+
36
+ steps:
37
+ - uses: actions/checkout@v2
38
+
39
+ - name: Setup Java
40
+ uses: actions/setup-java@v2
40
41
  with:
41
- github-token: ${{ secrets.GITHUB_TOKEN }}
42
- script: |
43
- const gemVersion = (function() {
44
- const ref = '${{ github.ref }}';
45
- const tagPrefix = 'refs/tags/';
42
+ distribution: adopt
43
+ java-version: 14
46
44
 
47
- if (ref.startsWith(tagPrefix)) {
48
- // If a tag ref is being built, just return the tag verbatim
49
- return ref.substring(tagPrefix.length);
50
- }
45
+ - name: Cache Maven dependencies
46
+ uses: actions/cache@v2.1.6
47
+ with:
48
+ path: ~/.m2/repository
49
+ key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
50
+ restore-keys: ${{ runner.os }}-maven-
51
51
 
52
- return '${{ steps.gitversion.outputs.legacySemVerPadded }}';
53
- })();
52
+ - name: Version stamp
53
+ run: mvn versions:set -DnewVersion=${{ needs.version.outputs.version }}
54
54
 
55
- core.setOutput('version', gemVersion);
55
+ - name: Maven install
56
+ run: mvn install
56
57
 
57
- - name: Set up Ruby 2.6
58
- uses: actions/setup-ruby@v1
58
+ - name: Upload plantuml.jar artifact
59
+ uses: actions/upload-artifact@v2
59
60
  with:
60
- ruby-version: 2.6.x
61
+ name: plantuml.jar
62
+ path: ~/.m2/repository/**/plantuml*.jar
61
63
 
62
- - name: Setup Graphviz
63
- uses: kamiazya/setup-graphviz@v1
64
+ gem:
65
+ needs: [version, plantuml]
66
+ runs-on: ubuntu-latest
67
+
68
+ outputs:
69
+ name: ${{ steps.gem.outputs.name }}
64
70
 
65
- - name: Cache dependencies
66
- uses: actions/cache@v1
71
+ steps:
72
+ - uses: actions/checkout@v2
73
+
74
+ - uses: actions/download-artifact@v2
67
75
  with:
68
- path: vendor/bundle
69
- key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
70
- restore-keys: ${{ runner.os }}-gems-
76
+ name: plantuml.jar
77
+ path: bin/
78
+
79
+ - name: Version stamp
80
+ run: sed -i -e 's/0.0.1.dev/${{ needs.version.outputs.version }}/g' ${{ github.workspace }}/lib/kramdown-plantuml/version.rb
81
+
82
+ - name: Setup Ruby 2.7
83
+ uses: ruby/setup-ruby@v1
84
+ with:
85
+ ruby-version: 2.7
86
+ bundler-cache: true
87
+
88
+ - name: Setup Graphviz
89
+ uses: kamiazya/setup-graphviz@v1
71
90
 
72
- - name: Bundle install
73
- run: |
74
- gem install bundler
75
- bundle config path vendor/bundle
76
- bundle install --jobs 4 --retry 3
91
+ - name: rubocop
92
+ run: bundle exec rubocop --fail-level warning --display-only-fail-level-offenses
77
93
 
78
94
  - name: Test with Rake
79
- env:
80
- GEM_VERSION: ${{ steps.gemversion.outputs.version }}
81
95
  run: bundle exec rake
82
96
 
97
+ - name: RSPec (debug)
98
+ env:
99
+ DEBUG: 1
100
+ run: bundle exec rspec --tag debug
101
+
102
+ - name: Codecov upload
103
+ run: bundle exec rake codecov:upload || echo 'Codecov upload failed'
104
+
83
105
  - name: Build gem
84
106
  id: gem
85
- env:
86
- GEM_VERSION: ${{ steps.gemversion.outputs.version }}
87
- run: |
88
- GEM_BUILD_NAME=$(gem build kramdown-plantuml.gemspec | awk '/File/ {print $2}')
89
- echo "Gem filename: '${GEM_BUILD_NAME}'"
90
- echo "::set-output name=name::${GEM_BUILD_NAME}"
107
+ run: .github/scripts/build-gem.sh
91
108
 
92
- - name: Upload artifact
109
+ - name: Upload gem
93
110
  uses: actions/upload-artifact@v2-preview
94
111
  with:
95
112
  name: ${{ steps.gem.outputs.name }}
96
113
  path: ${{ steps.gem.outputs.name }}
97
114
 
115
+ - name: Inspect gem
116
+ run: .github/scripts/inspect-gem.sh --gem "${{ github.workspace }}/${{ steps.gem.outputs.name }}" --verbose
117
+
118
+ - name: Test gem
119
+ run: .github/scripts/test-gem.sh --workdir "${{ github.workspace }}/spec/fixture" --gemdir "${{ github.workspace }}" --verbose
120
+
121
+ publish-dev:
122
+ needs: [version, gem]
123
+ runs-on: ubuntu-latest
124
+ if: |
125
+ (github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') ||
126
+ (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]')
127
+
128
+ steps:
129
+ - uses: actions/checkout@v2
130
+ if: ${{ github.event_name != 'pull_request_target' }}
131
+
132
+ - uses: actions/checkout@v2
133
+ if: ${{ github.event_name == 'pull_request_target' }}
134
+ with:
135
+ ref: ${{ github.event.pull_request.head.sha }}
136
+
137
+ - uses: actions/download-artifact@v2
138
+ with:
139
+ name: ${{ needs.gem.outputs.name }}
140
+
141
+ - name: Set up Ruby 2.7
142
+ uses: ruby/setup-ruby@v1
143
+ with:
144
+ ruby-version: 2.7
145
+ bundler-cache: true
146
+
147
+ - name: Setup Graphviz
148
+ uses: kamiazya/setup-graphviz@v1
149
+
98
150
  - name: Publish to GPR
99
- env:
100
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101
- OWNER: SwedbankPay
102
- run: |
103
- mkdir -p $HOME/.gem
104
- touch $HOME/.gem/credentials
105
- chmod 0600 $HOME/.gem/credentials
106
- printf -- "---\n:github: Bearer ${GITHUB_TOKEN}\n" > $HOME/.gem/credentials
107
- set -e
108
- gem push --KEY github \
109
- --host https://rubygems.pkg.github.com/${OWNER} \
110
- ${{ steps.gem.outputs.name }} \
111
- || echo "push failed ($?) probably due to version '${{ steps.gemversion.outputs.version }}' already existing in GPR."
151
+ run: .github/scripts/publish-gem.sh --gem ${{ needs.gem.outputs.name }} --token "${{ secrets.GPR_TOKEN }}" --owner SwedbankPay --verbose
152
+
153
+ - name: Test gem
154
+ run: .github/scripts/test-gem.sh --workdir "${{ github.workspace }}/spec/fixture" --version ${{ needs.version.outputs.version }} --token "${{ secrets.GPR_TOKEN }}" --verbose
155
+
156
+ - name: Upload Jekyll site
157
+ uses: actions/upload-artifact@v2-preview
158
+ if: always()
159
+ with:
160
+ name: site
161
+ path: ${{ github.workspace }}/spec/fixture/_site
162
+
163
+ publish-prod:
164
+ needs: [version, gem]
165
+ runs-on: ubuntu-latest
166
+ if: startsWith(github.ref, 'refs/tags/') # Only publish tagged commits
167
+
168
+ steps:
169
+ - uses: actions/checkout@v2
170
+
171
+ - uses: actions/download-artifact@v2
172
+ with:
173
+ name: ${{ needs.gem.outputs.name }}
112
174
 
113
175
  - name: Publish to RubyGems
114
- if: startsWith(github.ref, 'refs/tags/') # Only publish tagged commits
115
- env:
116
- RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
117
- run: |
118
- mkdir -p $HOME/.gem
119
- touch $HOME/.gem/credentials
120
- chmod 0600 $HOME/.gem/credentials
121
- printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials
122
- gem push ${{ steps.gem.outputs.name }}
176
+ run: .github/scripts/publish-gem.sh --gem ${{ needs.gem.outputs.name }} --token ${{ secrets.RUBYGEMS_API_KEY }} --verbose
@@ -0,0 +1,11 @@
1
+ name: Shell
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ shellcheck:
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - name: ShellCheck
11
+ uses: bewuethr/shellcheck-action@v2
data/.gitignore CHANGED
@@ -8,3 +8,12 @@
8
8
  /tmp/
9
9
  *.gem
10
10
  Gemfile.lock
11
+ /target/
12
+ *.jar
13
+ /bin/
14
+ .jekyll-cache
15
+ _site
16
+ .classpath
17
+ .project
18
+ .settings
19
+ .vscode
data/.rubocop.yml ADDED
@@ -0,0 +1,18 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+ NewCops: enable
4
+ Exclude:
5
+ - "Rakefile"
6
+ - "_site/**/*.rb"
7
+ - "spec/**/*.rb"
8
+ - "vendor/**/.*"
9
+ - "vendor/**/*"
10
+ Layout:
11
+ LineLength: 100
12
+ IndentationStyle:
13
+ IndentationWidth: 2
14
+ Metrics/MethodLength:
15
+ Max: 20
16
+ Naming/FileName:
17
+ Exclude:
18
+ - 'lib/kramdown-plantuml.rb'