mn2pdf 1.35 → 1.41.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +3 -20
- data/.github/workflows/release.yml +24 -14
- data/Rakefile +1 -1
- data/bin/mn2pdf.jar +0 -0
- data/lib/mn2pdf/version.rb +2 -1
- data/lib/mn2pdf.rb +69 -14
- data/mn2pdf.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f6b75a4c0cb45a4c674233bd1375d83636d08428d0a85dfa7c4b49cd84f0a96
|
4
|
+
data.tar.gz: 26caeb9c3f8a3f7ad24c565e9515aad2701e248dc2a97efab5e139f5adb3c1a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15b8bfc72495756a092fe272037a1bbe988054fcde62e7398694e0c04d664f6c949416274496f7970b199ebdc4c047d8c443f635d4ccbdb26a92385373283082
|
7
|
+
data.tar.gz: 95073bc9550325ac5435e71c21249a992ffdcb74118f87631c81c84086809c08a481484e3089405439cf85403c0b4455d8d82c95ffcbba6a15d060b3738e7572
|
data/.github/workflows/rake.yml
CHANGED
@@ -10,23 +10,6 @@ on:
|
|
10
10
|
|
11
11
|
jobs:
|
12
12
|
rake:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
strategy:
|
17
|
-
fail-fast: false
|
18
|
-
matrix:
|
19
|
-
ruby: [ '3.0', '2.7', '2.6', '2.5' ]
|
20
|
-
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
21
|
-
experimental: [ false ]
|
22
|
-
steps:
|
23
|
-
- uses: actions/checkout@v2
|
24
|
-
with:
|
25
|
-
submodules: true
|
26
|
-
|
27
|
-
- uses: ruby/setup-ruby@v1
|
28
|
-
with:
|
29
|
-
ruby-version: ${{ matrix.ruby }}
|
30
|
-
bundler-cache: true
|
31
|
-
|
32
|
-
- run: bundle exec rake
|
13
|
+
uses: metanorma/metanorma-build-scripts/.github/workflows/generic-rake.yml@main
|
14
|
+
secrets:
|
15
|
+
pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
|
@@ -4,28 +4,38 @@ on:
|
|
4
4
|
push:
|
5
5
|
tags:
|
6
6
|
- '*'
|
7
|
+
workflow_dispatch:
|
8
|
+
inputs:
|
9
|
+
next_version:
|
10
|
+
description: |
|
11
|
+
Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
|
12
|
+
required: true
|
13
|
+
default: 'skip'
|
7
14
|
|
8
15
|
jobs:
|
9
16
|
release:
|
10
17
|
runs-on: ubuntu-18.04
|
11
18
|
steps:
|
12
19
|
- uses: actions/checkout@v1
|
13
|
-
|
14
|
-
|
20
|
+
|
21
|
+
- uses: ruby/setup-ruby@v1
|
15
22
|
with:
|
16
23
|
ruby-version: '2.6'
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
bundler-cache: true
|
25
|
+
|
26
|
+
- run: rm -f bin/mn2pdf.jar && bundle exec rake bin/mn2pdf.jar
|
27
|
+
|
28
|
+
- run: bundle exec rake
|
29
|
+
|
30
|
+
- run: gem install gem-release
|
31
|
+
|
32
|
+
- run: |
|
33
|
+
git config user.name github-actions
|
34
|
+
git config user.email github-actions@github.com
|
35
|
+
|
36
|
+
- if: github.event_name == 'workflow_dispatch' && github.event.inputs.next_version != 'skip'
|
37
|
+
run: gem bump --version ${{ github.event.inputs.next_version }} --tag --push
|
38
|
+
|
29
39
|
- name: Publish to rubygems.org
|
30
40
|
env:
|
31
41
|
RUBYGEMS_API_KEY: ${{secrets.METANORMA_CI_RUBYGEMS_API_KEY}}
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ task :default => :spec
|
|
9
9
|
require 'open-uri'
|
10
10
|
|
11
11
|
file 'bin/mn2pdf.jar' do |file|
|
12
|
-
ver = Mn2pdf::
|
12
|
+
ver = Mn2pdf::MN2PDF_JAR_VERSION
|
13
13
|
url = "https://github.com/metanorma/mn2pdf/releases/download/v#{ver}/mn2pdf-#{ver}.jar"
|
14
14
|
File.open(file.name, 'wb') do |file|
|
15
15
|
file.write open(url).read
|
data/bin/mn2pdf.jar
CHANGED
Binary file
|
data/lib/mn2pdf/version.rb
CHANGED
data/lib/mn2pdf.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
require "open3"
|
2
2
|
require "rbconfig"
|
3
|
-
require "
|
3
|
+
require "tempfile"
|
4
|
+
require "yaml"
|
4
5
|
|
5
6
|
module Mn2pdf
|
6
7
|
MN2PDF_JAR_PATH = File.join(File.dirname(__FILE__), "../bin/mn2pdf.jar")
|
8
|
+
DEFAULT_JAVA_OPTS = ["-Xss5m", "-Xmx2048m"].freeze
|
9
|
+
FONTS_MANIFEST = :font_manifest
|
7
10
|
|
8
11
|
def self.jvm_options
|
9
|
-
options =
|
12
|
+
options = DEFAULT_JAVA_OPTS.dup
|
10
13
|
|
11
14
|
if RbConfig::CONFIG["host_os"].match?(/darwin|mac os/)
|
12
15
|
options << "-Dapple.awt.UIElement=true"
|
@@ -17,8 +20,9 @@ module Mn2pdf
|
|
17
20
|
|
18
21
|
def self.help
|
19
22
|
cmd = ["java", *jvm_options, "-jar", MN2PDF_JAR_PATH].join(" ")
|
20
|
-
message
|
21
|
-
|
23
|
+
# help message goes to STDERR (from mn2pdf v1.36)
|
24
|
+
_, help_message, = Open3.capture3(cmd)
|
25
|
+
help_message
|
22
26
|
end
|
23
27
|
|
24
28
|
def self.version
|
@@ -27,22 +31,73 @@ module Mn2pdf
|
|
27
31
|
message.strip
|
28
32
|
end
|
29
33
|
|
30
|
-
def self.convert(url_path, output_path, xsl_stylesheet, options =
|
31
|
-
|
34
|
+
def self.convert(url_path, output_path, xsl_stylesheet, options = {})
|
35
|
+
cmd = build_cmd(url_path, output_path, xsl_stylesheet)
|
36
|
+
|
37
|
+
return unless cmd
|
38
|
+
|
39
|
+
case options
|
40
|
+
when String
|
41
|
+
cmd << options
|
42
|
+
|
43
|
+
mn2pdf(cmd)
|
44
|
+
when Hash
|
45
|
+
manifest = options.delete(FONTS_MANIFEST)
|
46
|
+
|
47
|
+
options.each do |k, v|
|
48
|
+
sep = k.to_s.end_with?("=") ? "" : " "
|
49
|
+
cmd << "#{k}#{sep}#{quote(v)}"
|
50
|
+
end
|
51
|
+
if manifest
|
52
|
+
dump_fontist_manifest_locations(manifest) do |manifest_path|
|
53
|
+
cmd << "--font-manifest" << quote(manifest_path)
|
54
|
+
mn2pdf(cmd)
|
55
|
+
end
|
56
|
+
else
|
57
|
+
mn2pdf(cmd)
|
58
|
+
end
|
59
|
+
else
|
60
|
+
warn "Unsupported options type #{options.class}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.build_cmd(url, output, xslt)
|
65
|
+
return if url.nil? || output.nil? || xslt.nil?
|
32
66
|
|
33
|
-
|
34
|
-
|
35
|
-
|
67
|
+
["java", *jvm_options,
|
68
|
+
"-jar", MN2PDF_JAR_PATH,
|
69
|
+
"--xml-file", quote(url),
|
70
|
+
"--xsl-file", quote(xslt),
|
71
|
+
"--pdf-file", quote(output)]
|
72
|
+
end
|
36
73
|
|
74
|
+
def self.mn2pdf(cmd)
|
75
|
+
cmd = cmd.join(" ")
|
37
76
|
puts cmd
|
38
|
-
|
77
|
+
out, err, status = Open3.capture3(cmd)
|
39
78
|
|
40
|
-
raise prepare_error_msg(
|
79
|
+
raise prepare_error_msg(out, err) unless status.success?
|
41
80
|
end
|
42
81
|
|
43
|
-
def self.prepare_error_msg(
|
82
|
+
def self.prepare_error_msg(stdout, stderr)
|
44
83
|
# Strip default mn2pdf message
|
45
|
-
|
46
|
-
["[mn2pdf] Fatal:",
|
84
|
+
stdout = stdout.gsub("Preparing...", "").strip
|
85
|
+
["[mn2pdf] Fatal:", stdout, stderr].join(" ").strip
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.quote(str)
|
89
|
+
return "" if str.nil? || str.empty?
|
90
|
+
return str if /^'.*'$/.match(str) || /^".*"$/.match(str)
|
91
|
+
|
92
|
+
%("#{str}")
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.dump_fontist_manifest_locations(manifest)
|
96
|
+
Tempfile.create(["fontist_locations", ".yml"]) do |f|
|
97
|
+
f.write manifest.to_yaml
|
98
|
+
f.flush
|
99
|
+
|
100
|
+
yield f.path
|
101
|
+
end
|
47
102
|
end
|
48
103
|
end
|
data/mn2pdf.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
spec.files = `git ls-files`.split("\n")
|
22
22
|
spec.test_files = `git ls-files -- {spec}/*`.split("\n")
|
23
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
23
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
24
24
|
|
25
25
|
# Specify which files should be added to the gem when it is released.
|
26
26
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mn2pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.41.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
mn2pdf converts Metanorma XML into PDF.
|
@@ -49,7 +49,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
49
49
|
requirements:
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 2.
|
52
|
+
version: 2.5.0
|
53
53
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - ">="
|