relaton-iev 1.1.0 → 1.1.4
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 +4 -4
- data/.github/workflows/rake.yml +36 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +6 -4
- data/README.adoc +1 -3
- data/Rakefile +1 -1
- data/bin/rspec +1 -2
- data/lib/relaton_iev/version.rb +1 -1
- data/lib/relaton_iev.rb +56 -55
- data/relaton_iev.gemspec +7 -5
- metadata +14 -30
- data/.github/workflows/macos.yml +0 -31
- data/.github/workflows/ubuntu.yml +0 -43
- data/.github/workflows/windows.yml +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fe2ce99811a0a55a1f458810612cdddc6c496eea33e43a42bc582edaceccde7
|
4
|
+
data.tar.gz: a1a335641f829d1bc444061806a6982aaa10599aab57fac64223f7af0f328b3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: beb4a621afedd7459552fdcde28dddb87278fd95a9ad9dbc6390410fa7b434abd2823f9ba32f6e0fdbca6eaa3a7119ac77f225ffe7ba5af4ffbad7ad667dea5a
|
7
|
+
data.tar.gz: f06e7ec49dfb4b2e3bf61a0ae272f632bb7dbdcfdb275275c43b5657f0bb51d11c24cf7db7318b1c9752b00e2f0404956aac7e86ba2cf889f6f5fe96d36a416d
|
@@ -0,0 +1,36 @@
|
|
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', '3.0' ]
|
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
|
+
# https://github.com/ruby-debug/debase/issues/89#issuecomment-686827382
|
28
|
+
- if: matrix.os == 'macos-latest' && matrix.ruby == '2.5'
|
29
|
+
run: echo BUNDLE_BUILD__DEBASE="--with-cflags=\"-Wno-error=implicit-function-declaration\"" >> $GITHUB_ENV
|
30
|
+
|
31
|
+
- uses: ruby/setup-ruby@v1
|
32
|
+
with:
|
33
|
+
ruby-version: ${{ matrix.ruby }}
|
34
|
+
bundler-cache: true
|
35
|
+
|
36
|
+
- run: bundle exec rake
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# This project follows the Ribose OSS style guide.
|
2
2
|
# https://github.com/riboseinc/oss-guides
|
3
3
|
# All project-specific additions and overrides should be specified in this file.
|
4
|
-
|
5
4
|
inherit_from:
|
6
5
|
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
|
6
|
+
|
7
|
+
# local repo-specific modifications
|
8
|
+
|
7
9
|
AllCops:
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
DisplayCopNames: false
|
11
|
+
StyleGuideCopsOnly: false
|
12
|
+
TargetRubyVersion: 2.5
|
data/README.adoc
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
= RelatonIev Refactor IEV reference
|
2
2
|
|
3
3
|
image:https://img.shields.io/gem/v/relaton-iev.svg["Gem Version", link="https://rubygems.org/gems/relaton-iev"]
|
4
|
-
image:https://github.com/relaton/relaton-iev/workflows/
|
5
|
-
image:https://github.com/relaton/relaton-iev/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/relaton/relaton-iev/actions?workflow=windows"]
|
6
|
-
image:https://github.com/relaton/relaton-iev/workflows/ubuntu/badge.svg["Build Status (Ubuntu)", link="https://github.com/relaton/relaton-iev/actions?workflow=ubuntu"]
|
4
|
+
image:https://github.com/relaton/relaton-iev/workflows/rake/badge.svg["Build Status", link="https://github.com/relaton/relaton-iev/actions?workflow=rake"]
|
7
5
|
image:https://codeclimate.com/github/relaton/relaton-iev/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/relaton/relaton-iev"]
|
8
6
|
image:https://img.shields.io/github/issues-pr-raw/relaton/relaton-iev.svg["Pull Requests", link="https://github.com/relaton/relaton-iev/pulls"]
|
9
7
|
image:https://img.shields.io/github/commits-since/relaton/relaton-iev/latest.svg["Commits since latest",link="https://github.com/relaton/relaton-iev/releases"]
|
data/Rakefile
CHANGED
data/bin/rspec
CHANGED
data/lib/relaton_iev/version.rb
CHANGED
data/lib/relaton_iev.rb
CHANGED
@@ -5,67 +5,68 @@ module RelatonIev
|
|
5
5
|
class Error < StandardError; end
|
6
6
|
|
7
7
|
class << self
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
parts
|
8
|
+
# converts generic IEV citation to citation of IEC 60050-n
|
9
|
+
# assumes IEV citations are of form
|
10
|
+
# <eref type="inline" bibitemid="a" citeas="IEC 60050">
|
11
|
+
# <locality type="clause"><referenceFrom>101-01-01</referenceFrom>
|
12
|
+
# </locality></eref>
|
13
|
+
#
|
14
|
+
# @param xmldoc [Nokogiri::XML::Documet]
|
15
|
+
# @return [Set<String>]
|
16
|
+
def links_iev2iec60050part(xmldoc)
|
17
|
+
parts = Set.new
|
18
|
+
xmldoc.xpath("//*[@citeas = 'IEC 60050:2011']").each do |x|
|
19
|
+
m = x&.at(".//locality[@type = 'clause']/referenceFrom")&.text
|
20
|
+
&.sub(/^(\d+).*$/, "\\1") or next
|
21
|
+
|
22
|
+
parts << m
|
23
|
+
x["citeas"] = x["citeas"].sub(/60050/, "60050-#{m}")
|
24
|
+
x["bibitemid"] = "IEC60050-#{m}"
|
26
25
|
end
|
26
|
+
parts
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
x["citeas"] = x["citeas"].sub(/:2011$/, ":#{date}")
|
44
|
-
end
|
29
|
+
# replace generic IEV reference with references to all extracted
|
30
|
+
# IEV parts
|
31
|
+
#
|
32
|
+
# @param xmodoc [Nokogiri::XML::Document]
|
33
|
+
# @param parts [Set<String>]
|
34
|
+
# @param iev [Nokogiri::XML::Element]
|
35
|
+
# @param bibdb [Relaton::Db, NilClass]
|
36
|
+
# @return [Nokogiri::XML::Element]
|
37
|
+
def refs_iev2iec60050part(xmldoc, parts, bibdb = nil)
|
38
|
+
new_iev = ""
|
39
|
+
parts.sort.each do |p|
|
40
|
+
hit = bibdb&.fetch("IEC 60050-#{p}", nil, keep_year: true) or next
|
41
|
+
new_iev += refs_iev2iec60050part1(xmldoc, p, hit)
|
42
|
+
xmldoc.xpath("//*[@citeas = 'IEC 60050-#{p}:2011']").each do |x|
|
43
|
+
x["citeas"] = x["citeas"].sub(/:2011$/, ":#{hit.date[0].on(:year)}")
|
45
44
|
end
|
46
|
-
iev.replace(new_iev)
|
47
45
|
end
|
46
|
+
new_iev
|
47
|
+
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
id = xmldoc.at("//bibitem[@id = 'IEC60050-#{p}']") ? "-1" : ""
|
53
|
-
hit.to_xml.sub(/ id="[^"]+"/, %{ id="IEC60050-#{p}#{id}"})
|
54
|
-
end
|
49
|
+
def refs_iev2iec60050part1(xmldoc, part, hit)
|
50
|
+
date = hit.date[0].on(:year)
|
51
|
+
return "" if already_contains_ref(xmldoc, part, date)
|
55
52
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
"[text() = 'IEC 60050-#{p}:#{date}']")
|
60
|
-
end
|
53
|
+
id = xmldoc.at("//bibitem[@id = 'IEC60050-#{part}']") ? "-1" : ""
|
54
|
+
hit.to_xml.sub(/ id="[^"]+"/, %{ id="IEC60050-#{part}#{id}"})
|
55
|
+
end
|
61
56
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
57
|
+
def already_contains_ref(xmldoc, part, date)
|
58
|
+
xmldoc.at("//bibliography//bibitem[not(ancestor::bibitem)]/"\
|
59
|
+
"docidentifier[@type = 'IEC']"\
|
60
|
+
"[text() = 'IEC 60050-#{part}:#{date}']")
|
61
|
+
end
|
62
|
+
|
63
|
+
# @param xmldoc [Nokogiri::XML::Document]
|
64
|
+
# @param bibdb [Relaton::Db, NilClass]
|
65
|
+
# @return [Nokogiri::XML::Element]
|
66
|
+
def iev_cleanup(xmldoc, bibdb = nil)
|
67
|
+
iev = xmldoc.at("//bibitem[docidentifier = 'IEC 60050:2011']") || return
|
68
|
+
parts = links_iev2iec60050part(xmldoc)
|
69
|
+
iev.replace(refs_iev2iec60050part(xmldoc, parts, bibdb))
|
70
|
+
end
|
70
71
|
end
|
71
72
|
end
|
data/relaton_iev.gemspec
CHANGED
@@ -14,22 +14,24 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
17
|
-
`git ls-files -z`.split("\x0")
|
17
|
+
`git ls-files -z`.split("\x0")
|
18
|
+
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
19
|
end
|
19
20
|
spec.bindir = "exe"
|
20
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
22
|
spec.require_paths = ["lib"]
|
22
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
23
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
23
24
|
|
24
|
-
spec.add_development_dependency "debase"
|
25
|
+
# spec.add_development_dependency "debase"
|
25
26
|
spec.add_development_dependency "pry-byebug"
|
26
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
27
28
|
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
-
spec.add_development_dependency "ruby-debug-ide"
|
29
|
+
# spec.add_development_dependency "ruby-debug-ide"
|
30
|
+
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
29
31
|
spec.add_development_dependency "simplecov"
|
30
32
|
spec.add_development_dependency "vcr"
|
31
33
|
spec.add_development_dependency "webmock"
|
32
|
-
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
33
34
|
|
35
|
+
spec.add_dependency "nokogiri", "~> 1.13.0"
|
34
36
|
spec.add_dependency "relaton", ">= 1.6"
|
35
37
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-iev
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.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:
|
11
|
+
date: 2022-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: debase
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: pry-byebug
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,19 +53,19 @@ dependencies:
|
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '3.0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
56
|
+
name: equivalent-xml
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- - "
|
59
|
+
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
61
|
+
version: '0.6'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- - "
|
66
|
+
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
68
|
+
version: '0.6'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: simplecov
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,19 +109,19 @@ dependencies:
|
|
123
109
|
- !ruby/object:Gem::Version
|
124
110
|
version: '0'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
112
|
+
name: nokogiri
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
128
114
|
requirements:
|
129
115
|
- - "~>"
|
130
116
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
132
|
-
type: :
|
117
|
+
version: 1.13.0
|
118
|
+
type: :runtime
|
133
119
|
prerelease: false
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
122
|
- - "~>"
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
124
|
+
version: 1.13.0
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: relaton
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,9 +143,7 @@ executables: []
|
|
157
143
|
extensions: []
|
158
144
|
extra_rdoc_files: []
|
159
145
|
files:
|
160
|
-
- ".github/workflows/
|
161
|
-
- ".github/workflows/ubuntu.yml"
|
162
|
-
- ".github/workflows/windows.yml"
|
146
|
+
- ".github/workflows/rake.yml"
|
163
147
|
- ".gitignore"
|
164
148
|
- ".rspec"
|
165
149
|
- ".rubocop.yml"
|
@@ -185,14 +169,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
185
169
|
requirements:
|
186
170
|
- - ">="
|
187
171
|
- !ruby/object:Gem::Version
|
188
|
-
version: 2.
|
172
|
+
version: 2.5.0
|
189
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
174
|
requirements:
|
191
175
|
- - ">="
|
192
176
|
- !ruby/object:Gem::Version
|
193
177
|
version: '0'
|
194
178
|
requirements: []
|
195
|
-
rubygems_version: 3.
|
179
|
+
rubygems_version: 3.3.9
|
196
180
|
signing_key:
|
197
181
|
specification_version: 4
|
198
182
|
summary: 'RelatonIev: manipulates IEV references to IEC 60050.'
|
data/.github/workflows/macos.yml
DELETED
@@ -1,31 +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
|
-
|
10
|
-
jobs:
|
11
|
-
test-macos:
|
12
|
-
name: Test on Ruby ${{ matrix.ruby }} macOS
|
13
|
-
runs-on: macos-latest
|
14
|
-
strategy:
|
15
|
-
fail-fast: false
|
16
|
-
matrix:
|
17
|
-
ruby: [ '2.6', '2.5', '2.4' ]
|
18
|
-
steps:
|
19
|
-
- uses: actions/checkout@master
|
20
|
-
- name: Use Ruby
|
21
|
-
uses: actions/setup-ruby@v1
|
22
|
-
with:
|
23
|
-
ruby-version: ${{ matrix.ruby }}
|
24
|
-
architecture: 'x64'
|
25
|
-
- name: Update gems
|
26
|
-
run: |
|
27
|
-
sudo gem install bundler --force
|
28
|
-
bundle install --jobs 4 --retry 3
|
29
|
-
- name: Run specs
|
30
|
-
run: |
|
31
|
-
bundle exec rake
|
@@ -1,43 +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
|
-
pull_request:
|
9
|
-
|
10
|
-
jobs:
|
11
|
-
test-linux:
|
12
|
-
name: Test on Ruby ${{ matrix.ruby }} Ubuntu
|
13
|
-
runs-on: ubuntu-latest
|
14
|
-
strategy:
|
15
|
-
fail-fast: false
|
16
|
-
matrix:
|
17
|
-
ruby: [ '2.6', '2.5', '2.4' ]
|
18
|
-
steps:
|
19
|
-
- uses: actions/checkout@master
|
20
|
-
- name: Use Ruby
|
21
|
-
uses: actions/setup-ruby@v1
|
22
|
-
with:
|
23
|
-
ruby-version: ${{ matrix.ruby }}
|
24
|
-
architecture: 'x64'
|
25
|
-
- name: Update gems
|
26
|
-
run: |
|
27
|
-
gem install bundler
|
28
|
-
bundle install --jobs 4 --retry 3
|
29
|
-
- name: Run specs
|
30
|
-
run: |
|
31
|
-
bundle exec rake
|
32
|
-
- name: Trigger dependent repositories
|
33
|
-
if: github.ref == 'refs/heads/master' && matrix.ruby == '2.6'
|
34
|
-
env:
|
35
|
-
GH_USERNAME: ${{ secrets.PAT_USERNAME }}
|
36
|
-
GH_ACCESS_TOKEN: ${{ secrets.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
|
-
for repo in $DEPENDENT_REPOS
|
41
|
-
do
|
42
|
-
sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "{ \"ref\": \"${GITHUB_REF}\" }"
|
43
|
-
done
|
@@ -1,33 +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
|
-
|
10
|
-
jobs:
|
11
|
-
test-windows:
|
12
|
-
name: Test on Ruby ${{ matrix.ruby }} Windows
|
13
|
-
runs-on: windows-latest
|
14
|
-
strategy:
|
15
|
-
fail-fast: false
|
16
|
-
matrix:
|
17
|
-
ruby: [ '2.6', '2.5', '2.4' ]
|
18
|
-
steps:
|
19
|
-
- uses: actions/checkout@master
|
20
|
-
- name: Use Ruby
|
21
|
-
uses: actions/setup-ruby@v1
|
22
|
-
with:
|
23
|
-
ruby-version: ${{ matrix.ruby }}
|
24
|
-
architecture: 'x64'
|
25
|
-
- name: Update gems
|
26
|
-
shell: pwsh
|
27
|
-
run: |
|
28
|
-
gem install bundler
|
29
|
-
bundle config --local path vendor/bundle
|
30
|
-
bundle install --jobs 4 --retry 3
|
31
|
-
- name: Run specs
|
32
|
-
run: |
|
33
|
-
bundle exec rake
|