mnconvert 1.11.0 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release-tag.yml +22 -27
- data/.github/workflows/release.yml +1 -0
- data/.gitignore +0 -3
- data/Rakefile +25 -14
- data/bin/mnconvert.jar +0 -0
- data/lib/mnconvert/version.rb +1 -1
- data/lib/mnconvert.rb +27 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be0ea3afb67d3ce030ecde2c774ed29b2fcdbdc1881db7a9ae8910fdcf1f0e3b
|
4
|
+
data.tar.gz: fded1db54970ef59df71ffd59cc57c4b8a405a62d355774f75cf2a41218fa47e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e13a9ecd6884a3d6d90a9602f4df563f2bee48b8b06677fe36863bf41f7b717f5ae7eab36c91ea382d723807d349239026b8d791d7c5d98ef58d98e6df1411a
|
7
|
+
data.tar.gz: 83e290e00eafca8e7c8300f0fb49cb7989308df10de968791a3c7948dffbb086f8505f337921dea6de94500d90afbdb43632beb2b4a794269abbbd9014e88127
|
@@ -9,41 +9,36 @@ jobs:
|
|
9
9
|
runs-on: ubuntu-18.04
|
10
10
|
if: startsWith(github.event.client_payload.ref, 'refs/tags/v')
|
11
11
|
steps:
|
12
|
-
- uses: actions/checkout@
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
with:
|
14
|
+
token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
|
15
|
+
|
16
|
+
- run: |
|
17
|
+
git config --global user.name "metanorma-ci"
|
16
18
|
git config --global user.email "metanorma-ci@users.noreply.github.com"
|
17
|
-
|
18
|
-
|
19
|
-
- name: Parse mnconvert version
|
19
|
+
|
20
|
+
- run: echo mnconvert_VERSION=${mnconvert_TAG#*/v} >> ${GITHUB_ENV}
|
20
21
|
env:
|
21
22
|
mnconvert_TAG: ${{ github.event.client_payload.ref }}
|
22
|
-
|
23
|
-
|
24
|
-
- name: Use Ruby
|
25
|
-
uses: actions/setup-ruby@v1
|
23
|
+
|
24
|
+
- uses: ruby/setup-ruby@v1
|
26
25
|
with:
|
27
26
|
ruby-version: '2.6'
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
-
|
35
|
-
run: |
|
36
|
-
gem bump --version ${mnconvert_VERSION} --no-commit
|
37
|
-
- name: Update mnconvert.jar
|
38
|
-
run: |
|
27
|
+
bundler-cache: true
|
28
|
+
|
29
|
+
- run: gem install gem-release
|
30
|
+
|
31
|
+
- run: gem bump --version ${mnconvert_VERSION} --no-commit
|
32
|
+
|
33
|
+
- run: |
|
39
34
|
rm -f bin/mnconvert.jar
|
40
|
-
rake bin/mnconvert.jar
|
41
|
-
|
42
|
-
|
43
|
-
|
35
|
+
bundle exec rake bin/mnconvert.jar
|
36
|
+
|
37
|
+
- run: bundle exec rake
|
38
|
+
|
44
39
|
- name: Push commit and tag
|
45
40
|
run: |
|
46
41
|
git add -u bin/mnconvert.jar lib/mnconvert/version.rb
|
47
42
|
git commit -m "Bump version to ${mnconvert_VERSION}"
|
48
43
|
git tag v${mnconvert_VERSION}
|
49
|
-
git push
|
44
|
+
git push origin HEAD:${GITHUB_REF} --tags
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -1,28 +1,31 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require_relative
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require_relative "lib/mnconvert/version"
|
4
4
|
|
5
5
|
RSpec::Core::RakeTask.new(:spec)
|
6
6
|
|
7
|
-
task :
|
7
|
+
task default: [
|
8
|
+
"bin/mnconvert.jar",
|
9
|
+
"spec/fixtures/rice-en.cd.mn.xml",
|
10
|
+
"spec/fixtures/rice-en.final.sts.xml",
|
11
|
+
"spec/fixtures/rfc8650.xml",
|
12
|
+
:spec,
|
13
|
+
]
|
8
14
|
|
9
15
|
def uri_open(url)
|
10
16
|
require 'open-uri'
|
11
|
-
|
12
|
-
return open(url)
|
13
|
-
end
|
14
|
-
return URI.open(url)
|
17
|
+
URI.parse(url).open
|
15
18
|
end
|
16
19
|
|
17
|
-
file
|
20
|
+
file "bin/mnconvert.jar" do |file|
|
18
21
|
ver = MnConvert::MNCONVERT_JAR_VERSION
|
19
22
|
url = "https://github.com/metanorma/mnconvert/releases/download/v#{ver}/mnconvert-#{ver}.jar"
|
20
|
-
File.open(file.name,
|
21
|
-
|
23
|
+
File.open(file.name, "wb") do |f|
|
24
|
+
f.write uri_open(url).read
|
22
25
|
end
|
23
26
|
end
|
24
27
|
|
25
|
-
file
|
28
|
+
file "spec/fixtures/rice-en.cd.mn.xml" do |file|
|
26
29
|
uri = "https://raw.githubusercontent.com/metanorma/mn-samples-iso/gh-pages/documents/international-standard/rice-en.cd.xml"
|
27
30
|
|
28
31
|
File.open(file.name, "w") do |saved_file|
|
@@ -30,10 +33,18 @@ file 'spec/fixtures/rice-en.cd.mn.xml' do |file|
|
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
|
-
file
|
36
|
+
file "spec/fixtures/rice-en.final.sts.xml" do |file|
|
34
37
|
uri = "https://raw.githubusercontent.com/metanorma/sts2mn/master/src/test/resources/rice-en.final.sts.xml"
|
35
38
|
|
36
39
|
File.open(file.name, "w") do |saved_file|
|
37
40
|
saved_file.write(uri_open(uri).read)
|
38
41
|
end
|
39
|
-
end
|
42
|
+
end
|
43
|
+
|
44
|
+
file "spec/fixtures/rfc8650.xml" do |file|
|
45
|
+
uri = "https://raw.githubusercontent.com/metanorma/mnconvert/main/src/test/resources/rfc/rfc8650.xml"
|
46
|
+
|
47
|
+
File.open(file.name, "w") do |saved_file|
|
48
|
+
saved_file.write(uri_open(uri).read)
|
49
|
+
end
|
50
|
+
end
|
data/bin/mnconvert.jar
CHANGED
Binary file
|
data/lib/mnconvert/version.rb
CHANGED
data/lib/mnconvert.rb
CHANGED
@@ -7,7 +7,9 @@ module MnConvert
|
|
7
7
|
STS = :sts
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
MNCONVERT_JAR_NAME = "mnconvert.jar".freeze
|
11
|
+
MNCONVERT_JAR_PATH = File.join(File.dirname(__FILE__), "..", "bin",
|
12
|
+
MNCONVERT_JAR_NAME)
|
11
13
|
|
12
14
|
def self.jvm_options
|
13
15
|
options = ["-Xss5m", "-Xmx1024m"]
|
@@ -31,12 +33,10 @@ module MnConvert
|
|
31
33
|
message.strip
|
32
34
|
end
|
33
35
|
|
34
|
-
def self.convert(input_file,
|
35
|
-
validate(opts
|
36
|
+
def self.convert(input_file, opts = {})
|
37
|
+
validate(opts)
|
36
38
|
|
37
|
-
cmd = [
|
38
|
-
input_file, "--input-format", input_format,
|
39
|
-
"--output", output_file, *optional_opts(opts)].join(" ")
|
39
|
+
cmd = [*java_cmd, input_file, *optional_opts(opts)].join(" ")
|
40
40
|
|
41
41
|
puts cmd if opts[:debug]
|
42
42
|
output_str, error_str, status = Open3.capture3(cmd)
|
@@ -50,16 +50,31 @@ module MnConvert
|
|
50
50
|
class << self
|
51
51
|
private
|
52
52
|
|
53
|
-
|
53
|
+
OPTIONAL_OPTS = {
|
54
|
+
sts_type: "--type",
|
55
|
+
imagesdir: "--imagesdir",
|
56
|
+
check_type: "--check-type",
|
57
|
+
input_format: "--input-format",
|
58
|
+
output_format: "--output-format",
|
59
|
+
output_file: "--output",
|
60
|
+
xsl_file: "--xsl-file",
|
61
|
+
}.freeze
|
62
|
+
|
63
|
+
def java_cmd
|
64
|
+
["java", *jvm_options, "-jar", MNCONVERT_JAR_PATH]
|
65
|
+
end
|
66
|
+
|
67
|
+
def validate(opts)
|
54
68
|
output_format = opts[:output_format]
|
69
|
+
debug = opts[:debug]
|
55
70
|
|
56
|
-
case input_format
|
71
|
+
case opts[:input_format]
|
57
72
|
when InputFormat::MN
|
58
73
|
validate_mn(opts, output_format)
|
59
74
|
when InputFormat::STS
|
60
75
|
validate_sts(opts, output_format)
|
61
76
|
else
|
62
|
-
|
77
|
+
puts "input format will be decided by #{MNCONVERT_JAR_NAME}" if debug
|
63
78
|
end
|
64
79
|
end
|
65
80
|
|
@@ -84,16 +99,12 @@ module MnConvert
|
|
84
99
|
end
|
85
100
|
|
86
101
|
def optional_opts(opts)
|
87
|
-
result = {
|
88
|
-
|
89
|
-
imagesdir: "--imagesdir",
|
90
|
-
check_type: "--check-type",
|
91
|
-
output_format: "--output-format",
|
92
|
-
xsl_file: "--xsl-file",
|
93
|
-
}.reject { |k, _| opts[k].nil? }.map { |k, v| "#{v} #{opts[k]}" }
|
102
|
+
result = OPTIONAL_OPTS.reject { |k, _| opts[k].nil? }
|
103
|
+
result = result.map { |k, v| "#{v} #{opts[k]}" }
|
94
104
|
|
95
105
|
result << "--debug" if opts[:debug]
|
96
106
|
result << "--split-bibdata" if opts[:split_bibdata]
|
107
|
+
result << "--semantic" if opts[:semantic]
|
97
108
|
|
98
109
|
result
|
99
110
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mnconvert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
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-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
mnconvert converts Metanorma XML into NISO STS XML.
|