metanorma 1.5.0 → 1.5.2

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: 90bf0ce070f2311504682547eb3024210586686123020f92a776fc590fe478a9
4
- data.tar.gz: 330f7930f8c1bfd3972fff06b59d1a31bdd78893a849d4b01f377051c7137089
3
+ metadata.gz: 2dd771e6d08104e0da071e1a9326ebdd909565d6e53b5393b4375dde3507e157
4
+ data.tar.gz: ff4931bf6d1fd1bbed2ffb47b4dbf6dbda95027caff1d24f388f881e4827da65
5
5
  SHA512:
6
- metadata.gz: 878e9d88ee70e5bfeda7198d596b77d4785f0c4aab345aedf7eabf67d5a28dddfb04df560376376b2137aa20f330986efee59d3f456ccf15d4fbca64ce45d1c8
7
- data.tar.gz: 69f19f897413b45d7111fcabeba645a2aaffe48900230b18f08eef4977219d009ac91a5952f9c1afb985fb31ccb936f25b169ebc1c29e46256852d358869a6d8
6
+ metadata.gz: 55f9e339d45f4cd40e6666660fdd2ad2c52b85332c07b64b66f59208cabd703e79ac38dda55070c99cd79a45b09199fb487b7aa5701553e1599d8239f8a50959
7
+ data.tar.gz: ba2ccbb163a0bad558a56680a8bf66d112ca3cc0f72fb87772b678b029d3c8ac3e27152f28442c5cade32149ab86a09e1ebebe19786e1a770c53f85036f3723e
@@ -38,10 +38,8 @@ module Metanorma
38
38
 
39
39
  # @param bib [Nokogiri::XML::Element]
40
40
  # @param identifier [String]
41
- def update_bibitem(bib, identifier) # rubocop:disable Metrics/AbcSize
42
- docid = bib&.at(ns("./docidentifier"))&.children&.to_xml
43
- return fail_update_bibitem(docid, identifier) unless @files[docid]
44
-
41
+ def update_bibitem(bib, identifier)
42
+ docid = get_bibitem_docid(bib, identifier) or return
45
43
  newbib = dup_bibitem(docid, bib)
46
44
  bib.replace(newbib)
47
45
  _file, url = targetfile(@files[docid], relative: true, read: false,
@@ -52,6 +50,19 @@ module Metanorma
52
50
  newbib.at(ns("./docidentifier")).previous = uri_node
53
51
  end
54
52
 
53
+ def get_bibitem_docid(bib, identifier)
54
+ # IDs for repo references are untyped by default
55
+ docid = bib.at(ns("./docidentifier[not(@type)]")) ||
56
+ bib.at(ns("./docidentifier"))
57
+ docid &&= docid.children.to_xml
58
+ if @files[docid]
59
+ docid
60
+ else
61
+ fail_update_bibitem(docid, identifier)
62
+ nil
63
+ end
64
+ end
65
+
55
66
  def fail_update_bibitem(docid, identifier)
56
67
  error = "[metanorma] Cannot find crossreference to document #{docid} "\
57
68
  "in document #{identifier}."
@@ -75,7 +86,8 @@ module Metanorma
75
86
  # in another file in the collection)
76
87
  # @param file [String] XML content
77
88
  # @param identifier [String] docid
78
- # @param internal_refs [Hash{String=>Hash{String=>String}] schema name to anchor to filename
89
+ # @param internal_refs [Hash{String=>Hash{String=>String}] schema name to
90
+ # anchor to filename
79
91
  # @return [String] XML content
80
92
  def update_xrefs(file, identifier, internal_refs)
81
93
  docxml = Nokogiri::XML(file) { |config| config.huge }
@@ -142,11 +154,12 @@ module Metanorma
142
154
  def update_direct_refs_to_docs(docxml, identifier)
143
155
  erefs = collect_erefs(docxml)
144
156
  docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |b|
145
- docid = b&.at(ns("./docidentifier[@type = 'repository']"))&.text
157
+ docid = b.at(ns("./docidentifier[@type = 'repository']"))&.text
146
158
  next unless docid && %r{^current-metanorma-collection/}.match(docid)
147
159
 
148
160
  update_bibitem(b, identifier)
149
- docid = b&.at(ns("./docidentifier"))&.children&.to_xml or next
161
+ docid = b.at(ns("./docidentifier")) or next
162
+ docid = docid.children.to_xml
150
163
  erefs[:citeas][docid] and update_anchors(b, docxml, docid)
151
164
  end
152
165
  end
@@ -211,9 +224,9 @@ module Metanorma
211
224
  # anchor given the locality, and insert it into the crossref
212
225
  def update_anchor_create_loc(_bib, eref, docid)
213
226
  ins = eref.at(ns("./localityStack")) or return
214
- type = ins&.at(ns("./locality/@type"))&.text
227
+ type = ins.at(ns("./locality/@type"))&.text
215
228
  type = "clause" if type == "annex"
216
- ref = ins&.at(ns("./locality/referenceFrom"))&.text
229
+ ref = ins.at(ns("./locality/referenceFrom"))&.text
217
230
  anchor = @files[docid][:anchors].dig(type, ref) or return
218
231
  ins << "<locality type='anchor'><referenceFrom>#{anchor.sub(/^_/, '')}"\
219
232
  "</referenceFrom></locality>"
@@ -119,7 +119,7 @@ module Metanorma
119
119
  end
120
120
 
121
121
  def attr(key)
122
- if key == "fonts-manifest" && @font_locations
122
+ if key == "fonts-manifest" && @fonts_manifest
123
123
  @fonts_manifest
124
124
  end
125
125
  end
@@ -40,9 +40,9 @@ module Metanorma
40
40
  end
41
41
 
42
42
  def attachment_bibitem(identifier)
43
- Nokogiri::XML(
44
- "<bibdata><docidentifier>#{identifier}</docidentifier></bibdata>",
45
- )
43
+ Nokogiri::XML <<~DOCUMENT
44
+ <bibdata><docidentifier>#{identifier}</docidentifier></bibdata>
45
+ DOCUMENT
46
46
  end
47
47
 
48
48
  private
@@ -94,9 +94,10 @@ module Metanorma
94
94
 
95
95
  # @return [String]
96
96
  def type
97
- @type ||= (@bibitem.docidentifier.first&.type&.downcase ||
98
- @bibitem.docidentifier.first&.id&.match(/^[^\s]+/)&.to_s)&.downcase ||
99
- "standoc"
97
+ first = @bibitem.docidentifier.first
98
+ @type ||= (first&.type&.downcase ||
99
+ first&.id&.match(/^[^\s]+/)&.to_s)&.downcase ||
100
+ "standoc"
100
101
  end
101
102
 
102
103
  private
@@ -71,7 +71,8 @@ module Metanorma
71
71
  toc-figures toc-tables toc-recommendations fonts
72
72
  font-license-agreement pdf-allow-access-content
73
73
  pdf-encrypt-metadata iso-word-template document-scheme
74
- localize-number).freeze
74
+ localize-number iso-word-bg-strip-color
75
+ modspec-identifier-base).freeze
75
76
 
76
77
  def extract_options(file)
77
78
  header = file.sub(/\n\n.*$/m, "\n")
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "1.5.0".freeze
2
+ VERSION = "1.5.2".freeze
3
3
  end
data/metanorma.gemspec CHANGED
@@ -14,13 +14,14 @@ Gem::Specification.new do |spec|
14
14
  spec.license = "BSD-2-Clause"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
- f.match(%r{^(test|spec|features)/})
17
+ f.match(%r{^(test|spec|features|bin|.github)/}) \
18
+ || f.match(%r{Rakefile|bin/rspec})
18
19
  end
19
20
  spec.extra_rdoc_files = %w[README.adoc CHANGELOG.adoc LICENSE.txt]
20
21
  spec.bindir = "bin"
21
22
  # spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
23
  spec.require_paths = ["lib"]
23
- spec.required_ruby_version = ">= 2.5.0"
24
+ spec.required_ruby_version = ">= 2.7.0"
24
25
 
25
26
  spec.add_runtime_dependency "asciidoctor"
26
27
  spec.add_runtime_dependency "fontist", ">= 1.14.3"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-26 00:00:00.000000000 Z
11
+ date: 2022-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -258,10 +258,6 @@ extra_rdoc_files:
258
258
  - CHANGELOG.adoc
259
259
  - LICENSE.txt
260
260
  files:
261
- - ".github/workflows/dependent_repos.env"
262
- - ".github/workflows/notify.yml"
263
- - ".github/workflows/rake.yml"
264
- - ".github/workflows/release.yml"
265
261
  - ".gitignore"
266
262
  - ".hound.yml"
267
263
  - ".rspec"
@@ -271,12 +267,6 @@ files:
271
267
  - Gemfile
272
268
  - LICENSE.txt
273
269
  - README.adoc
274
- - Rakefile
275
- - bin/console
276
- - bin/metanorma-pdf.js
277
- - bin/rasterize.js
278
- - bin/rspec
279
- - bin/setup
280
270
  - lib/metanorma.rb
281
271
  - lib/metanorma/asciidoctor_extensions.rb
282
272
  - lib/metanorma/asciidoctor_extensions/glob_include_processor.rb
@@ -314,14 +304,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
314
304
  requirements:
315
305
  - - ">="
316
306
  - !ruby/object:Gem::Version
317
- version: 2.5.0
307
+ version: 2.7.0
318
308
  required_rubygems_version: !ruby/object:Gem::Requirement
319
309
  requirements:
320
310
  - - ">="
321
311
  - !ruby/object:Gem::Version
322
312
  version: '0'
323
313
  requirements: []
324
- rubygems_version: 3.1.6
314
+ rubygems_version: 3.3.7
325
315
  signing_key:
326
316
  specification_version: 4
327
317
  summary: Metanorma is the standard of standards; the metanorma gem allows you to create
@@ -1,2 +0,0 @@
1
- ORGANISATION=metanorma
2
- DEPENDENT_REPOS="metanorma-docker"
@@ -1,47 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: notify
4
-
5
- on:
6
- repository_dispatch:
7
- types: [ notify ]
8
-
9
- jobs:
10
- notify:
11
- name: Notify dependent repos
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v2
15
-
16
- - name: Trigger repositories
17
- env:
18
- GH_USERNAME: metanorma-ci
19
- GH_ACCESS_TOKEN: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
20
- run: |
21
- curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/trigger-gh-actions.sh
22
- [[ -f ".github/workflows/dependent_repos.env" ]] && source .github/workflows/dependent_repos.env
23
- CLIENT_PAYLOAD=$(cat <<EOF
24
- "{ "ref": "${{ github.event.client_payload.ref }}", "repo": "${GITHUB_REPOSITORY}" }"
25
- EOF
26
- )
27
- for repo in $TEMPLATE_REPOS" $SAMPLES_REPOS"
28
- do
29
- sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "$CLIENT_PAYLOAD"
30
- done
31
-
32
- - name: Trigger release repositories
33
- if: github.event.client_payload.ref == 'refs/heads/master' || startsWith(github.event.client_payload.ref, 'refs/tags/v')
34
- env:
35
- GH_USERNAME: metanorma-ci
36
- GH_ACCESS_TOKEN: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
37
- run: |
38
- curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/trigger-gh-actions.sh
39
- [[ -f ".github/workflows/dependent_repos.env" ]] && source .github/workflows/dependent_repos.env
40
- CLIENT_PAYLOAD=$(cat <<EOF
41
- "{ "ref": "${{ github.event.client_payload.ref }}", "repo": "${GITHUB_REPOSITORY}" }"
42
- EOF
43
- )
44
- for repo in $DEPENDENT_REPOS
45
- do
46
- sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "$CLIENT_PAYLOAD"
47
- done
@@ -1,15 +0,0 @@
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
- uses: metanorma/ci/.github/workflows/inkscape-rake.yml@main
14
- secrets:
15
- pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
@@ -1,27 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: release
4
-
5
- on:
6
- workflow_dispatch:
7
- inputs:
8
- next_version:
9
- description: |
10
- Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
11
- required: true
12
- default: 'skip'
13
- push:
14
- tags: [ v* ]
15
-
16
- jobs:
17
- release:
18
- uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
19
- with:
20
- next_version: ${{ github.event.inputs.next_version }}
21
- release_command: rake release
22
- bundler_cache: false
23
- post_install: gem install bundler rake rspec
24
- secrets:
25
- rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
26
- pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
27
-
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task default: :spec
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "metanorma"
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/metanorma-pdf.js DELETED
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- const puppeteer = require('puppeteer');
5
-
6
- const args = () => {
7
- let args = ['--no-sandbox', '--disable-setuid-sandbox', '--headless'];
8
- if (!process.platform.startsWith('win')) {
9
- args << '--single-process';
10
- }
11
- return {args};
12
- }
13
-
14
- const createPdf = async() => {
15
- let browser;
16
- let exitCode = 0;
17
- try {
18
- browser = await puppeteer.launch(args());
19
- const page = await browser.newPage();
20
- await page.goto(process.argv[2], {
21
- waitUntil: 'networkidle0',
22
- timeout: 120000 //ms
23
- });
24
- await page.pdf({
25
- path: process.argv[3],
26
- format: 'A4'
27
- });
28
- } catch (err) {
29
- console.error(err.message);
30
- console.error(err.stack);
31
- exitCode = 1;
32
- } finally {
33
- if (browser) {
34
- browser.close();
35
- }
36
- process.exit(exitCode);
37
- }
38
- };
39
- createPdf();
data/bin/rasterize.js DELETED
@@ -1,49 +0,0 @@
1
- "use strict";
2
- var page = require('webpage').create(),
3
- system = require('system'),
4
- address, output, size, pageWidth, pageHeight;
5
-
6
- if (system.args.length < 3 || system.args.length > 5) {
7
- console.log('Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]');
8
- console.log(' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"');
9
- console.log(' image (png/jpg output) examples: "1920px" entire page, window width 1920px');
10
- console.log(' "800px*600px" window, clipped to 800x600');
11
- phantom.exit(1);
12
- } else {
13
- address = system.args[1];
14
- output = system.args[2];
15
- page.viewportSize = { width: 600, height: 600 };
16
- if (system.args.length > 3 && system.args[2].substr(-4) === ".pdf") {
17
- size = system.args[3].split('*');
18
- page.paperSize = size.length === 2 ? { width: size[0], height: size[1], margin: '0px' }
19
- : { format: system.args[3], orientation: 'portrait', margin: '1cm' };
20
- } else if (system.args.length > 3 && system.args[3].substr(-2) === "px") {
21
- size = system.args[3].split('*');
22
- if (size.length === 2) {
23
- pageWidth = parseInt(size[0], 10);
24
- pageHeight = parseInt(size[1], 10);
25
- page.viewportSize = { width: pageWidth, height: pageHeight };
26
- page.clipRect = { top: 0, left: 0, width: pageWidth, height: pageHeight };
27
- } else {
28
- console.log("size:", system.args[3]);
29
- pageWidth = parseInt(system.args[3], 10);
30
- pageHeight = parseInt(pageWidth * 3/4, 10); // it's as good an assumption as any
31
- console.log ("pageHeight:",pageHeight);
32
- page.viewportSize = { width: pageWidth, height: pageHeight };
33
- }
34
- }
35
- if (system.args.length > 4) {
36
- page.zoomFactor = system.args[4];
37
- }
38
- page.open(address, function (status) {
39
- if (status !== 'success') {
40
- console.log('Unable to load the address!');
41
- phantom.exit(1);
42
- } else {
43
- window.setTimeout(function () {
44
- page.render(output);
45
- phantom.exit();
46
- }, 200);
47
- }
48
- });
49
- }
data/bin/rspec DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # This file was generated by Bundler.
6
- #
7
- # The application 'rspec' is installed as part of a gem, and
8
- # this file is here to facilitate running it.
9
- #
10
-
11
- require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
- Pathname.new(__FILE__).realpath)
14
-
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
16
-
17
- if File.file?(bundle_binstub)
18
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
- load(bundle_binstub)
20
- else
21
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
- Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
- end
24
- end
25
-
26
- require "rubygems"
27
- require "bundler/setup"
28
-
29
- load Gem.bin_path("rspec-core", "rspec")
data/bin/setup DELETED
@@ -1,8 +0,0 @@
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