mnconvert 1.13.0 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c168fcbff9013a1acf4318cc88b7b5c90c3004ef250fa2bbdc885b8e4542a0e3
4
- data.tar.gz: cee38d1e2eb34117860829504f8d21d3b221d20a6061e87cfeb43adcd4c42a9c
3
+ metadata.gz: a81599221a272e090908462b3f615a71611cf53e5c8c5f450866ed2514a7cf3c
4
+ data.tar.gz: 93cfb1a2d7f8d9e1bc846a4d2e44f38748131e9c3e8ff384cffb30fd35c8b14a
5
5
  SHA512:
6
- metadata.gz: efc8815680af9f95db3d560b113ebd334cd06cbe61388b6547110a8a4d80bc3237deb9ac3a7f185c48db46fdfeb033add2a297f37971027f7ce928d5471595fe
7
- data.tar.gz: ff74ee243c5a9db87ae0957b0ff880fd4088e28323922a29ed15dcaef5865e90df8f917b546eecb44c76c6aeed32341794d25d50efba02b367ef734b2692d101
6
+ metadata.gz: b284d2a94698d0bae078640ce501d6e0337dac4972777ba63f8cc0f18207913da041282b0f60b4a0bc90bb3fff5bba00c0230eb45bf4d2ff5f644d5626b6ef5c
7
+ data.tar.gz: d8d6d23ddb563d97235d61c8df661d16f9a5281878b7c140d2a43c572e4cabe45a7d2e77168fd62c69c900d0ce18cbfee5222deabe8f23def1d6d64b32b602af
@@ -10,23 +10,6 @@ on:
10
10
 
11
11
  jobs:
12
12
  rake:
13
- name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
- runs-on: ${{ matrix.os }}
15
- continue-on-error: ${{ matrix.experimental }}
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 }}
@@ -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@v1
13
- - name: Add writable remote
14
- run: |
15
- git config --global user.name metanorma-ci
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
- git remote add github https://metanorma-ci:${{ secrets.METANORMA_CI_PAT_TOKEN }}@github.com/$GITHUB_REPOSITORY
18
- git pull github ${GITHUB_REF} --ff-only
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
- run: |
23
- echo mnconvert_VERSION=${mnconvert_TAG#*/v} >> ${GITHUB_ENV}
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
- architecture: 'x64'
29
- - name: Update gems
30
- run: |
31
- gem install gem-release
32
- gem install bundler
33
- bundle install --jobs 4 --retry 3
34
- - name: Update version
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
- - name: Run specs
42
- run: |
43
- bundle exec rake
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 github HEAD:${GITHUB_REF} --tags
44
+ git push origin HEAD:${GITHUB_REF} --tags
@@ -4,6 +4,7 @@ on:
4
4
  push:
5
5
  tags:
6
6
  - '*'
7
+ workflow_dispatch: # just for manual release if previous was failed
7
8
 
8
9
  jobs:
9
10
  release:
data/.gitignore CHANGED
@@ -11,6 +11,3 @@
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
13
  /.rubocop-http*
14
-
15
- /spec/fixtures/rice-en.cd.mn.xml
16
- /spec/fixtures/rice-en.final.sts.xml
data/Rakefile CHANGED
@@ -1,28 +1,31 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
- require_relative 'lib/mnconvert/version'
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 :default => ['bin/mnconvert.jar', 'spec/fixtures/rice-en.cd.mn.xml', 'spec/fixtures/rice-en.final.sts.xml', :spec]
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
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.5")
12
- return open(url)
13
- end
14
- return URI.open(url)
17
+ URI.parse(url).open
15
18
  end
16
19
 
17
- file 'bin/mnconvert.jar' do |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, 'wb') do |file|
21
- file.write uri_open(url).read
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 'spec/fixtures/rice-en.cd.mn.xml' do |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 'spec/fixtures/rice-en.final.sts.xml' do |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
@@ -1,4 +1,4 @@
1
1
  module MnConvert
2
- VERSION = "1.13.0"
2
+ VERSION = "1.15.0"
3
3
  MNCONVERT_JAR_VERSION = VERSION
4
4
  end
data/lib/mnconvert.rb CHANGED
@@ -7,7 +7,9 @@ module MnConvert
7
7
  STS = :sts
8
8
  end
9
9
 
10
- MNCONVERT_JAR_PATH = File.join(File.dirname(__FILE__), "../bin/mnconvert.jar")
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, output_file, input_format, opts = {})
35
- validate(opts, input_format)
36
+ def self.convert(input_file, opts = {})
37
+ validate(opts)
36
38
 
37
- cmd = ["java", *jvm_options, "-jar", MNCONVERT_JAR_PATH,
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
- def validate(opts, input_format)
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
- raise StandardError.new("Invalid input format: #{input_format}")
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
- sts_type: "--type",
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.13.0
4
+ version: 1.15.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: 2021-11-16 00:00:00.000000000 Z
11
+ date: 2022-03-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  mnconvert converts Metanorma XML into NISO STS XML.