mn2sts 1.0.1 → 1.8.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: faa2b82e626f0e881dfb528d5d8af44a0595e788805e397e8e407cd3729a4da8
4
- data.tar.gz: 827af3746c0532afd6ad7e7ff2eafb2113205438c0ebdf8d6ec7f0bc29055849
3
+ metadata.gz: 728c21f447228036c9c7bd4f3e8069db7f122c9e3c3adc2feba8cb6c622692a1
4
+ data.tar.gz: 81816654bc4fa7cbf7136c4260786107b94f821a6a4930d9e7b5d1e1dae84159
5
5
  SHA512:
6
- metadata.gz: 33d036cd117a176b9a61e44822bf05780a2237fba5b443366aa7100478e6a345de87ce06b86cdb8f3cfe551732ab977134bcc9b1f1eed577bb6e54fadefa43d6
7
- data.tar.gz: d86909d3bd656d2f02a1b0491a8f9d16aadfd57a23ad6c1ff128da9aa97c056317290fd38bfa105137f512b63cb714f0d7aa49323d6a28b31201e29d6a984df6
6
+ metadata.gz: bed52d1f5a451a1013364c6089171292fe41408b581f2d05c3dcbe7c0dcc40fd91c8bb0988fe795cd20fabdd1e327224a3561515764b3b66547395566283e110
7
+ data.tar.gz: 588205a92867327303f3a39320c6fcb695dfe277657c90ebcb2cfa45ddff743382f55e9bbd2e4cf45b117bcc8dcca25cf5c72a17b4c6b9ccf33078ed0edfd49b
@@ -0,0 +1,42 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: rake
4
+
5
+ on:
6
+ push:
7
+ branches: [ master, main ]
8
+ tags: [ v* ]
9
+ pull_request:
10
+
11
+ jobs:
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: [ '2.7', '2.6', '2.5', '2.4' ]
20
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
21
+ experimental: [ false ]
22
+ include:
23
+ - ruby: '3.0'
24
+ os: 'ubuntu-latest'
25
+ experimental: true
26
+ - ruby: '3.0'
27
+ os: 'windows-latest'
28
+ experimental: true
29
+ - ruby: '3.0'
30
+ os: 'macos-latest'
31
+ experimental: true
32
+ steps:
33
+ - uses: actions/checkout@v2
34
+ with:
35
+ submodules: true
36
+
37
+ - uses: ruby/setup-ruby@v1
38
+ with:
39
+ ruby-version: ${{ matrix.ruby }}
40
+ bundler-cache: true
41
+
42
+ - run: bundle exec rake
@@ -20,7 +20,7 @@ jobs:
20
20
  env:
21
21
  mn2sts_TAG: ${{ github.event.client_payload.ref }}
22
22
  run: |
23
- echo "::set-env name=mn2sts_VERSION::${mn2sts_TAG#*/v}"
23
+ echo mn2sts_VERSION=${mn2sts_TAG#*/v} >> ${GITHUB_ENV}
24
24
  - name: Use Ruby
25
25
  uses: actions/setup-ruby@v1
26
26
  with:
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
 
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
+ /.rubocop-http*
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ # This project follows the Ribose OSS style guide.
2
+ # https://github.com/riboseinc/oss-guides
3
+ # All project-specific additions and overrides should be specified in this file.
4
+
5
+ inherit_from:
6
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
data/README.adoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = mn2sts Ruby gem
2
2
 
3
- image:https://img.shields.io/gem/v/metanorma.svg["Gem Version", link="https://rubygems.org/gems/metanorma"]
3
+ image:https://img.shields.io/gem/v/mn2sts.svg["Gem Version", link="https://rubygems.org/gems/mn2sts"]
4
4
  image:https://github.com/metanorma/mn2sts-ruby/workflows/ubuntu/badge.svg["Ubuntu Build Status", link="https://github.com/metanorma/mn2sts-ruby/actions?query=workflow%3Aubuntu"]
5
5
  image:https://github.com/metanorma/mn2sts-ruby/workflows/macos/badge.svg["OSX Build Status", link="https://github.com/metanorma/mn2sts-ruby/actions?query=workflow%3Amacos"]
6
6
  image:https://github.com/metanorma/mn2sts-ruby/workflows/windows/badge.svg["Windows Build Status", link="https://github.com/metanorma/mn2sts-ruby/actions?query=workflow%3Awindows"]
@@ -30,7 +30,7 @@ Or include it in your gemspec.
30
30
  [source,ruby]
31
31
  ----
32
32
  require 'mn2sts'
33
- Mn2sts.convert(sample_xml_path, output_pdf_path, sample_xsl_path)
33
+ Mn2sts.convert(sample_xml_path, output_pdf_path)
34
34
  ----
35
35
 
36
36
  == Updating the gem
data/Rakefile CHANGED
@@ -1,10 +1,11 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
3
  require_relative 'lib/mn2sts/version'
4
+ require 'open-uri'
4
5
 
5
6
  RSpec::Core::RakeTask.new(:spec)
6
7
 
7
- task :default => :spec
8
+ task :default => ['bin/mn2sts.jar', 'spec/fixtures/rice-en.cd.mn.xml', :spec]
8
9
 
9
10
  require 'open-uri'
10
11
 
@@ -15,3 +16,15 @@ file 'bin/mn2sts.jar' do |file|
15
16
  file.write open(url).read
16
17
  end
17
18
  end
19
+
20
+ file 'spec/fixtures/rice-en.cd.mn.xml' do |file|
21
+ uri = "https://raw.githubusercontent.com/metanorma/mn-samples-iso/gh-pages/documents/international-standard/rice-en.cd.xml"
22
+
23
+ File.open(file.name, "w") do |saved_file|
24
+ # the following "open" is provided by open-uri
25
+ open(uri, "r") do |read_file|
26
+ saved_file.write(read_file.read)
27
+ end
28
+ end
29
+
30
+ end
data/bin/mn2sts.jar CHANGED
Binary file
data/lib/mn2sts.rb CHANGED
@@ -1,35 +1,45 @@
1
- require 'open3'
2
- require 'mn2sts/version'
1
+ require "open3"
2
+ require "mn2sts/version"
3
3
 
4
4
  module Mn2sts
5
- MN2STS_JAR_PATH = File.join(File.dirname(__FILE__), '../bin/mn2sts.jar')
5
+ MN2STS_JAR_PATH = File.join(File.dirname(__FILE__), "../bin/mn2sts.jar")
6
+
7
+ def self.jvm_options
8
+ options = []
9
+
10
+ if RbConfig::CONFIG["host_os"].match?(/darwin|mac os/)
11
+ options << "-Dapple.awt.UIElement=true"
12
+ end
13
+
14
+ options
15
+ end
6
16
 
7
17
  def self.help
8
- cmd = ['java', '-jar', MN2STS_JAR_PATH].join(' ')
9
- message, error_str, status = Open3.capture3(cmd)
18
+ cmd = ["java", *jvm_options, "-jar", MN2STS_JAR_PATH].join(" ")
19
+ message, = Open3.capture3(cmd)
10
20
  message
11
21
  end
12
22
 
13
23
  def self.version
14
- cmd = ['java', '-jar', MN2STS_JAR_PATH, '-v'].join(' ')
15
- message, error_str, status = Open3.capture3(cmd)
24
+ cmd = ["java", *jvm_options, "-jar", MN2STS_JAR_PATH, "-v"].join(" ")
25
+ message, = Open3.capture3(cmd)
16
26
  message.strip
17
27
  end
18
28
 
19
- def self.convert(url_path, output_path, xsl_stylesheet)
20
- return if url_path.nil? || output_path.nil? || xsl_stylesheet.nil?
29
+ def self.convert(xml_path_in, xml_path_out, opts = {})
30
+ return if xml_path_in.nil? || xml_path_out.nil?
31
+
32
+ cmd = ["java", "-Xss5m", "-Xmx1024m", *jvm_options, "-jar", MN2STS_JAR_PATH,
33
+ "--xml-file-in", xml_path_in, "--xml-file-out", xml_path_out].join(" ")
21
34
 
22
- puts MN2STS_JAR_PATH
23
- cmd = ['java', '-Xss5m', '-Xmx1024m', '-jar', MN2STS_JAR_PATH, '--xml-file',
24
- url_path, '--xsl-file', xsl_stylesheet, '--pdf-file',
25
- output_path].join(' ')
35
+ cmd += " --output-format iso" if opts[:iso]
26
36
 
27
37
  puts cmd
28
38
  _, error_str, status = Open3.capture3(cmd)
29
39
 
30
40
  unless status.success?
41
+ warn error_str
31
42
  raise error_str
32
43
  end
33
44
  end
34
-
35
45
  end
@@ -1,4 +1,4 @@
1
1
  module Mn2sts
2
- MN2STS_JAR_VERSION = '1.0'
3
- VERSION = "#{MN2STS_JAR_VERSION}.1"
2
+ MN2STS_JAR_VERSION = '1.8'
3
+ VERSION = "#{MN2STS_JAR_VERSION}.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mn2sts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-24 00:00:00.000000000 Z
11
+ date: 2021-05-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  mn2sts converts Metanorma XML into NISO STS XML.
@@ -20,13 +20,12 @@ executables: []
20
20
  extensions: []
21
21
  extra_rdoc_files: []
22
22
  files:
23
- - ".github/workflows/macos.yml"
23
+ - ".github/workflows/rake.yml"
24
24
  - ".github/workflows/release-tag.yml"
25
25
  - ".github/workflows/release.yml"
26
- - ".github/workflows/ubuntu.yml"
27
- - ".github/workflows/windows.yml"
28
26
  - ".gitignore"
29
27
  - ".rspec"
28
+ - ".rubocop.yml"
30
29
  - CODE_OF_CONDUCT.md
31
30
  - Gemfile
32
31
  - README.adoc
@@ -41,7 +40,7 @@ homepage: https://github.com/metanorma/mn2sts-ruby
41
40
  licenses:
42
41
  - BSD-2-Clause
43
42
  metadata: {}
44
- post_install_message:
43
+ post_install_message:
45
44
  rdoc_options: []
46
45
  require_paths:
47
46
  - lib
@@ -56,8 +55,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
55
  - !ruby/object:Gem::Version
57
56
  version: '0'
58
57
  requirements: []
59
- rubygems_version: 3.0.3
60
- signing_key:
58
+ rubygems_version: 3.1.4
59
+ signing_key:
61
60
  specification_version: 4
62
61
  summary: mn2sts converts Metanorma XML into NISO STS XML.
63
62
  test_files: []
@@ -1,39 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: macos
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- paths-ignore:
10
- - .github/workflows/ubuntu.yml
11
- - .github/workflows/windows.yml
12
-
13
- jobs:
14
- test-macos:
15
- name: Test on Ruby ${{ matrix.ruby }} macOS
16
- runs-on: macos-latest
17
- continue-on-error: ${{ matrix.experimental }}
18
- strategy:
19
- fail-fast: false
20
- matrix:
21
- ruby: [ '2.6', '2.5', '2.4' ]
22
- experimental: [false]
23
- include:
24
- - ruby: '2.7'
25
- experimental: true
26
- steps:
27
- - uses: actions/checkout@master
28
- - name: Use Ruby
29
- uses: actions/setup-ruby@v1
30
- with:
31
- ruby-version: ${{ matrix.ruby }}
32
- architecture: 'x64'
33
- - name: Update gems
34
- run: |
35
- sudo gem install bundler --force
36
- bundle install --jobs 4 --retry 3
37
- - name: Run specs
38
- run: |
39
- bundle exec rake
@@ -1,53 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: ubuntu
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- tags:
9
- - '*'
10
- pull_request:
11
- paths-ignore:
12
- - .github/workflows/macos.yml
13
- - .github/workflows/windows.yml
14
-
15
- jobs:
16
- test-linux:
17
- name: Test on Ruby ${{ matrix.ruby }} Ubuntu
18
- runs-on: ubuntu-latest
19
- continue-on-error: ${{ matrix.experimental }}
20
- strategy:
21
- fail-fast: false
22
- matrix:
23
- ruby: [ '2.6', '2.5', '2.4' ]
24
- experimental: [false]
25
- include:
26
- - ruby: '2.7'
27
- experimental: true
28
- steps:
29
- - uses: actions/checkout@master
30
- - name: Use Ruby
31
- uses: actions/setup-ruby@v1
32
- with:
33
- ruby-version: ${{ matrix.ruby }}
34
- architecture: 'x64'
35
- - name: Update gems
36
- run: |
37
- gem install bundler
38
- bundle install --jobs 4 --retry 3
39
- - name: Run specs
40
- run: |
41
- bundle exec rake
42
- - name: Trigger dependent repositories
43
- if: github.ref == 'refs/heads/master' && matrix.ruby == '2.6'
44
- env:
45
- GH_USERNAME: ${{ secrets.PAT_USERNAME }}
46
- GH_ACCESS_TOKEN: ${{ secrets.PAT_TOKEN }}
47
- run: |
48
- curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/trigger-gh-actions.sh
49
- [[ -f ".github/workflows/dependent_repos.env" ]] && source .github/workflows/dependent_repos.env
50
- for repo in $DEPENDENT_REPOS
51
- do
52
- sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "{ \"ref\": \"${GITHUB_REF}\" }"
53
- done
@@ -1,41 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: windows
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- paths-ignore:
10
- - .github/workflows/macos.yml
11
- - .github/workflows/ubuntu.yml
12
-
13
- jobs:
14
- test-windows:
15
- name: Test on Ruby ${{ matrix.ruby }} Windows
16
- runs-on: windows-latest
17
- continue-on-error: ${{ matrix.experimental }}
18
- strategy:
19
- fail-fast: false
20
- matrix:
21
- ruby: [ '2.6', '2.5', '2.4' ]
22
- experimental: [false]
23
- include:
24
- - ruby: '2.7'
25
- experimental: true
26
- steps:
27
- - uses: actions/checkout@master
28
- - name: Use Ruby
29
- uses: actions/setup-ruby@v1
30
- with:
31
- ruby-version: ${{ matrix.ruby }}
32
- architecture: 'x64'
33
- - name: Update gems
34
- shell: pwsh
35
- run: |
36
- gem install bundler
37
- bundle config --local path vendor/bundle
38
- bundle install --jobs 4 --retry 3
39
- - name: Run specs
40
- run: |
41
- bundle exec rake