metanorma-plugin-plantuml 1.0.2 → 1.0.4
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.
- checksums.yaml +4 -4
- data/.github/workflows/plantuml-version-sync.yml +52 -70
- data/.github/workflows/rake.yml +4 -1
- data/Gemfile +1 -0
- data/README.adoc +561 -101
- data/Rakefile +236 -1
- data/lib/metanorma/plugin/plantuml/block_processor.rb +2 -3
- data/lib/metanorma/plugin/plantuml/image_block_macro_processor.rb +1 -1
- data/lib/metanorma/plugin/plantuml/version.rb +1 -1
- metadata +2 -2
data/Rakefile
CHANGED
@@ -14,8 +14,146 @@ def uri_open(url)
|
|
14
14
|
URI.parse(url).open
|
15
15
|
end
|
16
16
|
|
17
|
+
def github_client
|
18
|
+
require "octokit"
|
19
|
+
@github_client ||= begin
|
20
|
+
token = ENV['GITHUB_TOKEN'] || `gh auth token 2>/dev/null`.strip
|
21
|
+
token = nil if token.empty?
|
22
|
+
if token
|
23
|
+
Octokit::Client.new(access_token: token)
|
24
|
+
else
|
25
|
+
Octokit::Client.new
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def find_latest_valid_plantuml_release
|
31
|
+
puts "Searching for latest valid PlantUML release..."
|
32
|
+
|
33
|
+
client = github_client
|
34
|
+
releases = client.releases('plantuml/plantuml')
|
35
|
+
|
36
|
+
# Filter for valid JAR releases
|
37
|
+
valid_releases = releases.reject(&:prerelease).select do |release|
|
38
|
+
tag_name = release.tag_name
|
39
|
+
version = tag_name.sub(/^v/, '')
|
40
|
+
# Must match pattern v\d+\.\d{4}\.\d+ and not contain -native or other suffixes
|
41
|
+
tag_name.match?(/^v\d+\.\d{4}\.\d+$/) &&
|
42
|
+
!tag_name.include?('-native') &&
|
43
|
+
!tag_name.include?('-snapshot') &&
|
44
|
+
release.assets.any? { |asset| asset.name == "plantuml-#{version}.jar" }
|
45
|
+
end
|
46
|
+
|
47
|
+
if valid_releases.empty?
|
48
|
+
raise "No valid PlantUML JAR releases found"
|
49
|
+
end
|
50
|
+
|
51
|
+
latest = valid_releases.first
|
52
|
+
version = latest.tag_name.sub(/^v/, '')
|
53
|
+
|
54
|
+
puts "Found latest valid release: #{latest.tag_name} (#{version})"
|
55
|
+
{
|
56
|
+
version: version,
|
57
|
+
tag_name: latest.tag_name,
|
58
|
+
html_url: latest.html_url,
|
59
|
+
jar_asset: latest.assets.find { |asset| asset.name == "plantuml-#{version}.jar" }
|
60
|
+
}
|
61
|
+
rescue Octokit::Error => e
|
62
|
+
puts "GitHub API error: #{e.message}"
|
63
|
+
raise
|
64
|
+
rescue StandardError => e
|
65
|
+
puts "Error finding latest release: #{e.message}"
|
66
|
+
raise
|
67
|
+
end
|
68
|
+
|
69
|
+
def current_plantuml_version
|
70
|
+
Metanorma::Plugin::Plantuml::PLANTUML_JAR_VERSION
|
71
|
+
end
|
72
|
+
|
73
|
+
def current_gem_version
|
74
|
+
Metanorma::Plugin::Plantuml::VERSION
|
75
|
+
end
|
76
|
+
|
77
|
+
def update_version_file(new_plantuml_version, new_gem_version)
|
78
|
+
version_file = "lib/metanorma/plugin/plantuml/version.rb"
|
79
|
+
content = File.read(version_file)
|
80
|
+
|
81
|
+
# Update PlantUML version (handle .freeze suffix)
|
82
|
+
original_content = content.dup
|
83
|
+
content.gsub!(/VERSION = ["']([^"']+)["']\.freeze/, %Q(VERSION = "#{new_gem_version}".freeze))
|
84
|
+
content.gsub!(/PLANTUML_JAR_VERSION = ["']([^"']+)["']\.freeze/, %Q(PLANTUML_JAR_VERSION = "#{new_plantuml_version}".freeze))
|
85
|
+
|
86
|
+
if content == original_content
|
87
|
+
puts "⚠️ No changes made to version file. Current content:"
|
88
|
+
puts content
|
89
|
+
raise "Failed to update version file - no substitutions made"
|
90
|
+
end
|
91
|
+
|
92
|
+
File.write(version_file, content)
|
93
|
+
|
94
|
+
# Verify the file was written correctly
|
95
|
+
updated_content = File.read(version_file)
|
96
|
+
unless updated_content.include?(%Q("#{new_plantuml_version}")) && updated_content.include?(%Q("#{new_gem_version}"))
|
97
|
+
puts "❌ File content after update:"
|
98
|
+
puts updated_content
|
99
|
+
raise "Version file update verification failed"
|
100
|
+
end
|
101
|
+
|
102
|
+
puts "✅ Updated version file:"
|
103
|
+
puts " PlantUML: #{new_plantuml_version}"
|
104
|
+
puts " Gem: #{new_gem_version}"
|
105
|
+
end
|
106
|
+
|
107
|
+
def increment_gem_version(current_version)
|
108
|
+
require 'rubygems'
|
109
|
+
version = Gem::Version.new(current_version)
|
110
|
+
segments = version.segments.dup
|
111
|
+
segments[2] = (segments[2] || 0) + 1
|
112
|
+
segments.join('.')
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_plantuml_jar
|
116
|
+
jar_file = "data/plantuml.jar"
|
117
|
+
|
118
|
+
unless File.exist?(jar_file)
|
119
|
+
raise "PlantUML JAR file not found: #{jar_file}"
|
120
|
+
end
|
121
|
+
|
122
|
+
puts "Testing PlantUML JAR functionality..."
|
123
|
+
|
124
|
+
# Test version command
|
125
|
+
version_output = `java -jar #{jar_file} -version 2>&1`
|
126
|
+
unless $?.success? && version_output.include?("PlantUML")
|
127
|
+
raise "PlantUML version test failed. Output: #{version_output}"
|
128
|
+
end
|
129
|
+
puts "✅ Version test passed"
|
130
|
+
|
131
|
+
# Test diagram generation
|
132
|
+
test_diagram = "test_diagram_#{Time.now.to_i}.puml"
|
133
|
+
test_svg = test_diagram.sub('.puml', '.svg')
|
134
|
+
|
135
|
+
File.write(test_diagram, <<~PUML)
|
136
|
+
@startuml
|
137
|
+
Alice -> Bob: Hello
|
138
|
+
Bob -> Alice: Hi
|
139
|
+
@enduml
|
140
|
+
PUML
|
141
|
+
|
142
|
+
begin
|
143
|
+
generation_output = `java -jar #{jar_file} -tsvg #{test_diagram} 2>&1`
|
144
|
+
unless $?.success? && File.exist?(test_svg)
|
145
|
+
raise "PlantUML diagram generation test failed. Output: #{generation_output}"
|
146
|
+
end
|
147
|
+
puts "✅ Diagram generation test passed"
|
148
|
+
ensure
|
149
|
+
FileUtils.rm_f([test_diagram, test_svg])
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
17
153
|
file "data/plantuml.jar" do |file|
|
18
|
-
|
154
|
+
# Read version directly from file to avoid constant redefinition warnings
|
155
|
+
version_content = File.read("lib/metanorma/plugin/plantuml/version.rb")
|
156
|
+
ver = version_content.match(/PLANTUML_JAR_VERSION = ["']([^"']+)["']/)[1]
|
19
157
|
url = "https://github.com/plantuml/plantuml/releases/download/v#{ver}/plantuml-#{ver}.jar"
|
20
158
|
puts "Downloading PlantUML JAR... #{url}"
|
21
159
|
|
@@ -36,3 +174,100 @@ task :clean_jar do
|
|
36
174
|
FileUtils.rm_f("data/plantuml.jar")
|
37
175
|
puts "Removed data/plantuml.jar"
|
38
176
|
end
|
177
|
+
|
178
|
+
desc "Find latest valid PlantUML release"
|
179
|
+
task :find_latest_plantuml do
|
180
|
+
release_info = find_latest_valid_plantuml_release
|
181
|
+
puts "Latest PlantUML version: #{release_info[:version]}"
|
182
|
+
puts "Release URL: #{release_info[:html_url]}"
|
183
|
+
puts "JAR asset: #{release_info[:jar_asset].name}" if release_info[:jar_asset]
|
184
|
+
end
|
185
|
+
|
186
|
+
desc "Check current PlantUML version"
|
187
|
+
task :check_plantuml_version do
|
188
|
+
puts "Current PlantUML version: #{current_plantuml_version}"
|
189
|
+
puts "Current gem version: #{current_gem_version}"
|
190
|
+
end
|
191
|
+
|
192
|
+
desc "Test PlantUML JAR functionality"
|
193
|
+
task :test_plantuml do
|
194
|
+
test_plantuml_jar
|
195
|
+
end
|
196
|
+
|
197
|
+
desc "Update PlantUML to latest version"
|
198
|
+
task :update_plantuml do
|
199
|
+
puts "Checking for PlantUML updates..."
|
200
|
+
|
201
|
+
current_version = current_plantuml_version
|
202
|
+
current_gem = current_gem_version
|
203
|
+
|
204
|
+
begin
|
205
|
+
release_info = find_latest_valid_plantuml_release
|
206
|
+
latest_version = release_info[:version]
|
207
|
+
|
208
|
+
puts "Current version: #{current_version}"
|
209
|
+
puts "Latest version: #{latest_version}"
|
210
|
+
|
211
|
+
if current_version == latest_version
|
212
|
+
puts "✅ PlantUML is already up to date"
|
213
|
+
exit 0
|
214
|
+
end
|
215
|
+
|
216
|
+
# Check if update is actually newer
|
217
|
+
require 'rubygems'
|
218
|
+
if Gem::Version.new(latest_version) <= Gem::Version.new(current_version)
|
219
|
+
puts "⚠️ Latest version (#{latest_version}) is not newer than current (#{current_version})"
|
220
|
+
exit 0
|
221
|
+
end
|
222
|
+
|
223
|
+
puts "🔄 Updating PlantUML from #{current_version} to #{latest_version}"
|
224
|
+
|
225
|
+
# Update version files
|
226
|
+
new_gem_version = increment_gem_version(current_gem)
|
227
|
+
update_version_file(latest_version, new_gem_version)
|
228
|
+
|
229
|
+
# Clean old JAR and download new one
|
230
|
+
Rake::Task[:clean_jar].invoke
|
231
|
+
Rake::Task[:download_jar].invoke
|
232
|
+
|
233
|
+
# Test new JAR
|
234
|
+
test_plantuml_jar
|
235
|
+
|
236
|
+
puts "🎉 Successfully updated PlantUML!"
|
237
|
+
puts " PlantUML: #{current_version} → #{latest_version}"
|
238
|
+
puts " Gem: #{current_gem} → #{new_gem_version}"
|
239
|
+
puts " Release: #{release_info[:html_url]}"
|
240
|
+
|
241
|
+
exit 1 # Exit with code 1 to indicate changes were made
|
242
|
+
|
243
|
+
rescue StandardError => e
|
244
|
+
puts "❌ Failed to update PlantUML: #{e.message}"
|
245
|
+
exit 2 # Exit with code 2 to indicate error
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
desc "Update PlantUML version in version.rb (manual)"
|
250
|
+
task :update_plantuml_version, [:plantuml_version] do |t, args|
|
251
|
+
plantuml_version = args[:plantuml_version]
|
252
|
+
|
253
|
+
unless plantuml_version
|
254
|
+
puts "Usage: rake update_plantuml_version[1.2025.7]"
|
255
|
+
exit 1
|
256
|
+
end
|
257
|
+
|
258
|
+
unless plantuml_version.match?(/^\d+\.\d{4}\.\d+$/)
|
259
|
+
puts "Invalid version format. Expected: N.YYYY.NNN (e.g., 1.2025.7)"
|
260
|
+
exit 1
|
261
|
+
end
|
262
|
+
|
263
|
+
current_gem = current_gem_version
|
264
|
+
new_gem_version = increment_gem_version(current_gem)
|
265
|
+
|
266
|
+
update_version_file(plantuml_version, new_gem_version)
|
267
|
+
|
268
|
+
puts "Updated versions:"
|
269
|
+
puts " PlantUML: #{plantuml_version}"
|
270
|
+
puts " Gem: #{new_gem_version}"
|
271
|
+
puts ""
|
272
|
+
puts "Don't forget to run: rake clean_jar download_jar"
|
273
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Metanorma
|
4
4
|
module Plugin
|
5
5
|
module Plantuml
|
6
|
-
# PlantUML block processor
|
6
|
+
# PlantUML block processor
|
7
7
|
class BlockProcessor < ::Asciidoctor::Extensions::BlockProcessor
|
8
8
|
include ::Metanorma::Plugin::Plantuml::BlockProcessorBase
|
9
9
|
use_dsl
|
@@ -37,9 +37,8 @@ module Metanorma
|
|
37
37
|
options = {}
|
38
38
|
|
39
39
|
# Parse include directory
|
40
|
-
options[:includedirs] = parse_doc_includedirs(parent.document)
|
41
40
|
options[:includedirs] = add_attrs_to_includedirs(
|
42
|
-
parent.document, attrs,
|
41
|
+
parent.document, attrs, parse_doc_includedirs(parent.document)
|
43
42
|
)
|
44
43
|
|
45
44
|
options
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Metanorma
|
4
4
|
module Plugin
|
5
5
|
module Plantuml
|
6
|
-
# PlantUML block processor
|
6
|
+
# PlantUML block processor
|
7
7
|
class ImageBlockMacroProcessor < ::Asciidoctor::Extensions::BlockMacroProcessor
|
8
8
|
include ::Metanorma::Plugin::Plantuml::BlockProcessorBase
|
9
9
|
use_dsl
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-plugin-plantuml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-09-
|
11
|
+
date: 2025-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|