mnconvert 1.11.0 → 1.14.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e588bf71033aebf0b7dff538f51c7a7901c9e9f256e8ef17d52178beac0c3f83
4
- data.tar.gz: a9587e9277ced4f5fbf700b5b98bcffa5ce18e7635f4162f22b0bd2dd7c7fd8c
3
+ metadata.gz: be0ea3afb67d3ce030ecde2c774ed29b2fcdbdc1881db7a9ae8910fdcf1f0e3b
4
+ data.tar.gz: fded1db54970ef59df71ffd59cc57c4b8a405a62d355774f75cf2a41218fa47e
5
5
  SHA512:
6
- metadata.gz: 1b36239b95aa21db55faaaa835267bcabfb61a0ff0bfcfa85cea56e914b5bd4041b0c1ce4dd9c551c34d3327c266f61ba2501fa4fb3e122fee8955599f203f84
7
- data.tar.gz: 662a17eb49f3b808a033aeae351e544a0faa954da1a6371b260447b8c3ccddfc140e299c7bdc3bc562b7fd7a2810257cc67ef10b893cbaf6aa1267b58cfc1eca
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@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.11.0"
2
+ VERSION = "1.14.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.11.0
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: 2021-10-29 00:00:00.000000000 Z
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.