relaton-iev 0.1.3 → 0.1.4

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: 53aaa66f833891f4c0a076e87b6cf851c4bd5963aaa6f5f3339ea6cc173343c2
4
- data.tar.gz: 7e5a255631d0896e81db01c8a80707682b7c60aef7b4b942e7b31fcabf2fce3e
3
+ metadata.gz: 306f391fd8e1cfae0e07ce81a1d942b38a33d4d31066ef5f05352a5e71bf7d93
4
+ data.tar.gz: 97829207f221e0733c4569bfd7d652cadb46772d2629a037e90c229f11fa235a
5
5
  SHA512:
6
- metadata.gz: fb89a78e27b507e3efff673361b66fe8baa69ecea089f9b1b640f685355a683518b8c06cda1ebe13dae49f27ff4571ec5891579315179978373c5d3129133aee
7
- data.tar.gz: 20299b00f1f857f5fa0f63f029b10a491a26df3e238c9cf20b240077ff9312499aac5db95e5359c4e168ed5c1485d259584f3e3c84cbc66cd9fe11459fb707b2
6
+ metadata.gz: ca6c941e514afa7d7320a3bc8f7105ac1023c714073822e83cd2c0bb7fe8204e6b559bbdc5ac9fdc488e270abbaabedb51893ecd8d5dcc655f8a4207427cf85e
7
+ data.tar.gz: 63b83ae7da519fe7764f2817b1f85d28ba50466785cea67e587c40c958924f5fcd0517a1639f40f4bfc45edad30631a028dbacd0ffaada935f60e7b78f3f84a3
@@ -0,0 +1,61 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: defaults
4
+
5
+ on:
6
+ push:
7
+ branches: [ master ]
8
+ pull_request:
9
+ branches: [ '**' ]
10
+
11
+ jobs:
12
+ test-nix:
13
+ name: Test on Ruby ${{ matrix.ruby }} *nix
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ os: [ macos-latest, ubuntu-latest ]
18
+ ruby: [ '2.6', '2.5', '2.4' ]
19
+ runs-on: ${{ matrix.os }}
20
+ steps:
21
+ - uses: actions/checkout@master
22
+ - name: Use Ruby
23
+ uses: actions/setup-ruby@v1
24
+ with:
25
+ ruby-version: ${{ matrix.ruby }}
26
+ architecture: 'x64'
27
+ - name: Update gems
28
+ run: |
29
+ source doctypes.env
30
+ gem install metanorma-cli metanorma-$TYPE
31
+ - name: Use Node
32
+ uses: actions/setup-node@v1
33
+ with:
34
+ node-version: '8'
35
+ - name: Install Puppeteer
36
+ run: |
37
+ npm install -g puppeteer
38
+ - name: Use Python
39
+ uses: actions/setup-python@v1
40
+ with:
41
+ python-version: '2.7'
42
+ architecture: 'x64'
43
+ - name: Install xml2rfc
44
+ run: |
45
+ pip install xml2rfc
46
+ - name: Metanorma compile
47
+ run: |
48
+ source doctypes.env
49
+ for template in $DOCTYPES
50
+ do
51
+ metanorma new test/$template --type $TYPE --doctype $template --template . --overwrite
52
+ if [ -f test/${template}/document.adoc ]
53
+ then
54
+ metanorma compile test/${template}/document.adoc
55
+ else
56
+ for docfile in test/${template}/*.adoc
57
+ do
58
+ metanorma compile $docfile
59
+ done
60
+ fi
61
+ done
@@ -1,14 +1,19 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
3
  name: windows
4
4
 
5
- on: [push]
5
+ on:
6
+ push:
7
+ branches: [ master ]
8
+ pull_request:
9
+ branches: [ '**' ]
6
10
 
7
11
  jobs:
8
12
  test-windows:
9
13
  name: Test on Ruby ${{ matrix.ruby }} Windows
10
14
  runs-on: windows-latest
11
15
  strategy:
16
+ fail-fast: false
12
17
  matrix:
13
18
  ruby: [ '2.6', '2.5', '2.4' ]
14
19
  steps:
@@ -21,10 +26,38 @@ jobs:
21
26
  - name: Update gems
22
27
  shell: pwsh
23
28
  run: |
24
- gem install bundler -v "~> 2"
25
- bundle config --local path vendor/bundle
26
- bundle update
27
- bundle install --jobs 4 --retry 3
28
- - name: Run specs
29
+ $docTypes = ConvertFrom-StringData (Get-Content ./doctypes.env -Raw)
30
+ gem install metanorma-cli metanorma-$($docTypes.TYPE)
31
+ - name: Use Node
32
+ uses: actions/setup-node@v1
33
+ with:
34
+ node-version: '8'
35
+ - name: Install Puppeteer
36
+ shell: pwsh
37
+ run: |
38
+ npm install -g puppeteer
39
+ - name: Use Python
40
+ uses: actions/setup-python@v1
41
+ with:
42
+ python-version: '2.7'
43
+ architecture: 'x64'
44
+ - name: Install xml2rfc
45
+ run: |
46
+ pip install xml2rfc
47
+ - name: Metanorma compile
48
+ shell: pwsh
29
49
  run: |
30
- bundle exec rake
50
+ $ErrorActionPreference = "Stop" <# https://stackoverflow.com/a/16334189/902217 #>
51
+ $docTypes = ConvertFrom-StringData (Get-Content ./doctypes.env -Raw)
52
+ $docTypes.DOCTYPES.Split(" ") | % {
53
+ $t = $_.Trim('"')
54
+ & cmd /c "metanorma new result\$t --type $($docTypes.TYPE) --doctype $t --template . --overwrite 2>&1"
55
+ $doc = "result\$t\document.adoc"
56
+ if (Test-Path -Path $doc) {
57
+ & cmd /c "metanorma compile $doc 2>&1"
58
+ } else {
59
+ Get-ChildItem ".\result\$t" -Filter *.adoc | % {
60
+ & cmd /c "metanorma compile $_.FullName 2>&1"
61
+ }
62
+ }
63
+ }
data/bin/rspec ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path(
11
+ "../../Gemfile", Pathname.new(__FILE__).realpath
12
+ )
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rspec-core", "rspec")
18
+
data/lib/relaton_iev.rb CHANGED
@@ -37,8 +37,8 @@ module RelatonIev
37
37
  new_iev = ""
38
38
  parts.sort.each do |p|
39
39
  hit = bibdb&.fetch("IEC 60050-#{p}", nil, keep_year: true) || next
40
- new_iev += hit.to_xml.sub(/ id="[^"]+"/, %{ id="IEC60050-#{p}"})
41
40
  date = hit.date[0].on.year
41
+ new_iev += refsIev2iec60050part1(xmldoc, p, hit)
42
42
  xmldoc.xpath("//*[@citeas = 'IEC 60050-#{p}:2011']").each do |x|
43
43
  x["citeas"] = x["citeas"].sub(/:2011$/, ":#{date}")
44
44
  end
@@ -46,6 +46,19 @@ module RelatonIev
46
46
  iev.replace(new_iev)
47
47
  end
48
48
 
49
+ def refsIev2iec60050part1(xmldoc, p, hit)
50
+ date = hit.date[0].on.year
51
+ return "" if already_contains_ref(xmldoc, p, date)
52
+ id = xmldoc.at("//bibitem[@id = 'IEC60050-#{p}']") ? "-1" : ""
53
+ hit.to_xml.sub(/ id="[^"]+"/, %{ id="IEC60050-#{p}#{id}"})
54
+ end
55
+
56
+ def already_contains_ref(xmldoc, p, date)
57
+ xmldoc.at("//bibliography//bibitem[not(ancestor::bibitem)]/"\
58
+ "docidentifier[@type = 'IEC']"\
59
+ "[text() = 'IEC 60050-#{p}:#{date}']")
60
+ end
61
+
49
62
  # @param xmldoc [Nokogiri::XML::Document]
50
63
  # @param bibdb [Relaton::Db, NilClass]
51
64
  # @return [Nokogiri::XML::Element]
@@ -1,3 +1,3 @@
1
1
  module RelatonIev
2
- VERSION = "0.1.3".freeze
2
+ VERSION = "0.1.4".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-iev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-12 00:00:00.000000000 Z
11
+ date: 2020-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debase
@@ -157,6 +157,7 @@ executables: []
157
157
  extensions: []
158
158
  extra_rdoc_files: []
159
159
  files:
160
+ - ".github/workflows/defaults.yml"
160
161
  - ".github/workflows/macos.yml"
161
162
  - ".github/workflows/ubuntu.yml"
162
163
  - ".github/workflows/windows.yml"
@@ -168,6 +169,7 @@ files:
168
169
  - README.adoc
169
170
  - Rakefile
170
171
  - bin/console
172
+ - bin/rspec
171
173
  - bin/setup
172
174
  - lib/relaton_iev.rb
173
175
  - lib/relaton_iev/version.rb