mnconvert 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: db64df9fcc103fb4480fe551d15bee77a84e07befa098ce5ec08677432843de0
4
+ data.tar.gz: e63588f245166fac64ffcc5850b1105008888d92ac44d82340b3ab1aebf6a2d8
5
+ SHA512:
6
+ metadata.gz: 07ad349d564d950caea0be739b514828e738aca8c766384fdddbdcd503bee2d2e763fb199c16e0a3a9f10815e6b16a2245adc22143f34f1b6389c771121e4eee
7
+ data.tar.gz: 888db996e8a0df6dbe086d4771ca1effa769f9065f7ffd6aa2a2362400c85227e3d36a8b9f9bd838f1b7d3ada8d6aa7b1c2a013c588102dc03b82408bcad31f9
@@ -0,0 +1,32 @@
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: [ '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
@@ -0,0 +1,49 @@
1
+ name: release-tag
2
+
3
+ on:
4
+ repository_dispatch:
5
+ types: [ metanorma/mnconvert ]
6
+
7
+ jobs:
8
+ tag_repo:
9
+ runs-on: ubuntu-18.04
10
+ if: startsWith(github.event.client_payload.ref, 'refs/tags/v')
11
+ steps:
12
+ - uses: actions/checkout@v1
13
+ - name: Add writable remote
14
+ run: |
15
+ git config --global user.name metanorma-ci
16
+ 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
20
+ env:
21
+ 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
26
+ with:
27
+ 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: |
39
+ rm -f bin/mnconvert.jar
40
+ rake bin/mnconvert.jar
41
+ - name: Run specs
42
+ run: |
43
+ bundle exec rake
44
+ - name: Push commit and tag
45
+ run: |
46
+ git add -u bin/mnconvert.jar lib/mnconvert/version.rb
47
+ git commit -m "Bump version to ${mnconvert_VERSION}"
48
+ git tag v${mnconvert_VERSION}
49
+ git push github HEAD:${GITHUB_REF} --tags
@@ -0,0 +1,41 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*'
7
+
8
+ jobs:
9
+ release:
10
+ runs-on: ubuntu-18.04
11
+ steps:
12
+ - uses: actions/checkout@v1
13
+ - name: Use Ruby
14
+ uses: actions/setup-ruby@v1
15
+ with:
16
+ ruby-version: '2.6'
17
+ architecture: 'x64'
18
+ - name: Update gems
19
+ run: |
20
+ gem install bundler
21
+ bundle install --jobs 4 --retry 3
22
+ - name: Update mnconvert.jar
23
+ run: |
24
+ rm -f bin/mnconvert.jar
25
+ rake bin/mnconvert.jar
26
+ - name: Run specs
27
+ run: |
28
+ bundle exec rake
29
+ - name: Publish to rubygems.org
30
+ env:
31
+ RUBYGEMS_API_KEY: ${{secrets.METANORMA_CI_RUBYGEMS_API_KEY}}
32
+ run: |
33
+ gem install gem-release
34
+ touch ~/.gem/credentials
35
+ cat > ~/.gem/credentials << EOF
36
+ ---
37
+ :rubygems_api_key: ${RUBYGEMS_API_KEY}
38
+ EOF
39
+ chmod 0600 ~/.gem/credentials
40
+ git status
41
+ gem release
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /Gemfile.lock
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+ /.rubocop-http*
14
+
15
+ /spec/fixtures/rice-en.cd.mn.xml
16
+ /spec/fixtures/rice-en.final.sts.xml
data/.hound.yml ADDED
@@ -0,0 +1,5 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ ruby:
4
+ enabled: true
5
+ config_file: .rubocop.yml
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ inherit_from:
4
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
5
+
6
+ # local repo-specific modifications
7
+ # ...
8
+
9
+ AllCops:
10
+ TargetRubyVersion: 2.5
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at ronald.tse@ribose.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in mnconvert.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
data/README.adoc ADDED
@@ -0,0 +1,53 @@
1
+ = mnconvert Ruby gem
2
+
3
+ image:https://img.shields.io/gem/v/mnconvert.svg["Gem Version", link="https://rubygems.org/gems/mnconvert"]
4
+ image:https://github.com/metanorma/mnconvert-ruby/workflows/rake/badge.svg["Ubuntu Build Status", link="https://github.com/metanorma/mnconvert-ruby/actions/workflows/rake.yml"]
5
+ image:https://codeclimate.com/github/metanorma/mnconvert-ruby/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/mnconvert-ruby"]
6
+ image:https://img.shields.io/github/issues-pr-raw/metanorma/mnconvert-ruby.svg["Pull Requests", link="https://github.com/metanorma/mnconvert-ruby/pulls"]
7
+ image:https://img.shields.io/github/commits-since/metanorma/mnconvert-ruby/latest.svg["Commits since latest",link="https://github.com/metanorma/mnconvert-ruby/releases"]
8
+
9
+ == Purpose
10
+
11
+ The mnconvert Ruby gem is a wrapper around the Java https://github.com/metanorma/mnconvert[mnconvert]
12
+ which:
13
+
14
+ * converts Metanorma presentational XML into various output formats, including
15
+ ISOSTS;
16
+ * converts other formats to Metanorma AsciiDoc or Metanorma XML.
17
+
18
+ This gem is used to provide mnconvert.jar with mirrored version numbers, to allow
19
+ Ruby code to easily refer to the desired mnconvert version as dependencies.
20
+
21
+ == Installation
22
+
23
+ [source,ruby]
24
+ ----
25
+ gem install mnconvert
26
+ ----
27
+
28
+ Or include it in your gemspec.
29
+
30
+ == Usage
31
+
32
+ [source,ruby]
33
+ ----
34
+ require 'mnconvert'
35
+ MnConvert.convert(sample_xml_path, output_pdf_path)
36
+ ----
37
+
38
+ == Updating the gem
39
+
40
+ Update `lib/mnconvert/version.rb` to the desired version of
41
+ https://github.com/metanorma/mnconvert[mnconvert].
42
+
43
+ Run `rake` to download the `bin/mnconvert.jar` file:
44
+
45
+ [source,ruby]
46
+ ----
47
+ rm -f bin/mnconvert.jar
48
+ rake bin/mnconvert.jar
49
+ ----
50
+
51
+ Then release the gem with `rake release`.
52
+
53
+
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require_relative 'lib/mnconvert/version'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => ['bin/mnconvert.jar', 'spec/fixtures/rice-en.cd.mn.xml', 'spec/fixtures/rice-en.final.sts.xml', :spec]
8
+
9
+ def uri_open(url)
10
+ 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)
15
+ end
16
+
17
+ file 'bin/mnconvert.jar' do |file|
18
+ ver = MnConvert::MNCONVERT_JAR_VERSION
19
+ 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
22
+ end
23
+ end
24
+
25
+ file 'spec/fixtures/rice-en.cd.mn.xml' do |file|
26
+ uri = "https://raw.githubusercontent.com/metanorma/mn-samples-iso/gh-pages/documents/international-standard/rice-en.cd.xml"
27
+
28
+ File.open(file.name, "w") do |saved_file|
29
+ saved_file.write(uri_open(uri).read)
30
+ end
31
+ end
32
+
33
+ file 'spec/fixtures/rice-en.final.sts.xml' do |file|
34
+ uri = "https://raw.githubusercontent.com/metanorma/sts2mn/master/src/test/resources/rice-en.final.sts.xml"
35
+
36
+ File.open(file.name, "w") do |saved_file|
37
+ saved_file.write(uri_open(uri).read)
38
+ end
39
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mnconvert"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/mnconvert.jar ADDED
Binary file
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/mnconvert.rb ADDED
@@ -0,0 +1,101 @@
1
+ require "open3"
2
+ require "mnconvert/version"
3
+
4
+ module MnConvert
5
+ module InputFormat
6
+ MN = :metanorma
7
+ STS = :sts
8
+ end
9
+
10
+ MNCONVERT_JAR_PATH = File.join(File.dirname(__FILE__), "../bin/mnconvert.jar")
11
+
12
+ def self.jvm_options
13
+ options = ["-Xss5m", "-Xmx1024m"]
14
+
15
+ if RbConfig::CONFIG["host_os"].match?(/darwin|mac os/)
16
+ options << "-Dapple.awt.UIElement=true"
17
+ end
18
+
19
+ options
20
+ end
21
+
22
+ def self.help
23
+ cmd = ["java", *jvm_options, "-jar", MNCONVERT_JAR_PATH].join(" ")
24
+ message, = Open3.capture3(cmd)
25
+ message
26
+ end
27
+
28
+ def self.version
29
+ cmd = ["java", *jvm_options, "-jar", MNCONVERT_JAR_PATH, "-v"].join(" ")
30
+ message, = Open3.capture3(cmd)
31
+ message.strip
32
+ end
33
+
34
+ def self.convert(input_file, output_file, input_format, opts = {})
35
+ validate(opts, input_format)
36
+
37
+ cmd = ["java", *jvm_options, "-jar", MNCONVERT_JAR_PATH,
38
+ input_file, "--input-format", input_format,
39
+ "--output", output_file, *optional_opts(opts)].join(" ")
40
+
41
+ puts cmd if opts[:debug]
42
+ output_str, error_str, status = Open3.capture3(cmd)
43
+ p output_str if opts[:debug]
44
+
45
+ unless status.success?
46
+ raise error_str
47
+ end
48
+ end
49
+
50
+ class << self
51
+ private
52
+
53
+ def validate(opts, input_format)
54
+ output_format = opts[:output_format]
55
+
56
+ case input_format
57
+ when InputFormat::MN
58
+ validate_mn(opts, output_format)
59
+ when InputFormat::STS
60
+ validate_sts(opts, output_format)
61
+ else
62
+ raise StandardError.new("Invalid input format: #{input_format}")
63
+ end
64
+ end
65
+
66
+ def validate_mn(opts, output_format)
67
+ unless output_format.nil? || %w(iso niso).include?(output_format.to_s)
68
+ raise StandardError.new("Invalid output format: #{output_format}")
69
+ end
70
+
71
+ if opts[:split_bibdata]
72
+ raise StandardError.new("split_bibdata valid only for sts input")
73
+ end
74
+
75
+ if opts[:sts_type]
76
+ raise StandardError.new("sts_type valid only for sts input")
77
+ end
78
+ end
79
+
80
+ def validate_sts(_opts, output_format)
81
+ unless output_format.nil? || %w(xml adoc).include?(output_format.to_s)
82
+ raise StandardError.new("Invalid output format: #{output_format}")
83
+ end
84
+ end
85
+
86
+ 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]}" }
94
+
95
+ result << "--debug" if opts[:debug]
96
+ result << "--split-bibdata" if opts[:split_bibdata]
97
+
98
+ result
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,4 @@
1
+ module MnConvert
2
+ VERSION = "1.8.0"
3
+ MNCONVERT_JAR_VERSION = VERSION
4
+ end
data/mnconvert.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ require_relative 'lib/mnconvert/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "mnconvert"
5
+ spec.version = MnConvert::VERSION
6
+ spec.authors = ["Ribose Inc."]
7
+ spec.email = ["open.source@ribose.com"]
8
+
9
+ spec.summary = "mnconvert converts Metanorma XML into NISO STS XML."
10
+ spec.description = <<~DESCRIPTION
11
+ mnconvert converts Metanorma XML into NISO STS XML.
12
+ This gem is a wrapper around mnconvert.jar available from
13
+ https://github.com/metanorma/mnconvert, with versions matching the JAR file.
14
+ DESCRIPTION
15
+
16
+ spec.homepage = "https://github.com/metanorma/mnconvert-ruby"
17
+ spec.license = "BSD-2-Clause"
18
+
19
+ spec.bindir = "bin"
20
+ spec.require_paths = ["lib"]
21
+ spec.files = `git ls-files`.split("\n")
22
+ spec.test_files = `git ls-files -- {spec}/*`.split("\n")
23
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mnconvert
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.8.0
5
+ platform: ruby
6
+ authors:
7
+ - Ribose Inc.
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-07-08 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |
14
+ mnconvert converts Metanorma XML into NISO STS XML.
15
+ This gem is a wrapper around mnconvert.jar available from
16
+ https://github.com/metanorma/mnconvert, with versions matching the JAR file.
17
+ email:
18
+ - open.source@ribose.com
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - ".github/workflows/rake.yml"
24
+ - ".github/workflows/release-tag.yml"
25
+ - ".github/workflows/release.yml"
26
+ - ".gitignore"
27
+ - ".hound.yml"
28
+ - ".rspec"
29
+ - ".rubocop.yml"
30
+ - CODE_OF_CONDUCT.md
31
+ - Gemfile
32
+ - README.adoc
33
+ - Rakefile
34
+ - bin/console
35
+ - bin/mnconvert.jar
36
+ - bin/setup
37
+ - lib/mnconvert.rb
38
+ - lib/mnconvert/version.rb
39
+ - mnconvert.gemspec
40
+ homepage: https://github.com/metanorma/mnconvert-ruby
41
+ licenses:
42
+ - BSD-2-Clause
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 2.4.0
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubygems_version: 3.0.3.1
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: mnconvert converts Metanorma XML into NISO STS XML.
63
+ test_files: []