relaton-iev 0.1.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +8 -4
- data/.github/workflows/ubuntu.yml +20 -4
- data/.github/workflows/windows.yml +8 -5
- data/README.adoc +6 -3
- data/bin/rspec +18 -0
- data/lib/relaton_iev.rb +16 -3
- data/lib/relaton_iev/version.rb +1 -1
- data/relaton_iev.gemspec +1 -2
- metadata +11 -26
- data/Gemfile.lock +0 -128
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0de88901d509f5420300ab1e23c96b5f573d444e516aae83c26d4495f12e5986
|
4
|
+
data.tar.gz: 82bd64527c49ca8a93e62542b3135db2f6f0abe17527517ffe1e7b0cebfcb173
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b962c9dcd052b7131a494ecc29b2943401e52057193ec07c5d6aee2a99570725265b17afc75654a4c390ac6db94de7b4e140ac64b586bd79b4bd85e3479c647c
|
7
|
+
data.tar.gz: 42808e1692e8cc54928d932988a9b85dad3ac10eab458016453b8d50bf0fee33d69813d86e3a9eb9f2adc7eda6b9cdb2917e446488d122c90996c3cdbd3b6f46
|
data/.github/workflows/macos.yml
CHANGED
@@ -1,14 +1,18 @@
|
|
1
|
-
# Auto-generated
|
2
|
-
#
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
3
|
name: macos
|
4
4
|
|
5
|
-
on:
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master ]
|
8
|
+
pull_request:
|
6
9
|
|
7
10
|
jobs:
|
8
11
|
test-macos:
|
9
12
|
name: Test on Ruby ${{ matrix.ruby }} macOS
|
10
13
|
runs-on: macos-latest
|
11
14
|
strategy:
|
15
|
+
fail-fast: false
|
12
16
|
matrix:
|
13
17
|
ruby: [ '2.6', '2.5', '2.4' ]
|
14
18
|
steps:
|
@@ -20,7 +24,7 @@ jobs:
|
|
20
24
|
architecture: 'x64'
|
21
25
|
- name: Update gems
|
22
26
|
run: |
|
23
|
-
sudo gem install bundler
|
27
|
+
sudo gem install bundler --force
|
24
28
|
bundle install --jobs 4 --retry 3
|
25
29
|
- name: Run specs
|
26
30
|
run: |
|
@@ -1,14 +1,18 @@
|
|
1
|
-
# Auto-generated
|
2
|
-
#
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
3
|
name: ubuntu
|
4
4
|
|
5
|
-
on:
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master ]
|
8
|
+
pull_request:
|
6
9
|
|
7
10
|
jobs:
|
8
11
|
test-linux:
|
9
12
|
name: Test on Ruby ${{ matrix.ruby }} Ubuntu
|
10
13
|
runs-on: ubuntu-latest
|
11
14
|
strategy:
|
15
|
+
fail-fast: false
|
12
16
|
matrix:
|
13
17
|
ruby: [ '2.6', '2.5', '2.4' ]
|
14
18
|
steps:
|
@@ -20,8 +24,20 @@ jobs:
|
|
20
24
|
architecture: 'x64'
|
21
25
|
- name: Update gems
|
22
26
|
run: |
|
23
|
-
gem install bundler
|
27
|
+
gem install bundler
|
24
28
|
bundle install --jobs 4 --retry 3
|
25
29
|
- name: Run specs
|
26
30
|
run: |
|
27
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,14 +1,18 @@
|
|
1
|
-
# Auto-generated
|
2
|
-
#
|
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:
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master ]
|
8
|
+
pull_request:
|
6
9
|
|
7
10
|
jobs:
|
8
11
|
test-windows:
|
9
12
|
name: Test on Ruby ${{ matrix.ruby }} Windows
|
10
13
|
runs-on: windows-latest
|
11
14
|
strategy:
|
15
|
+
fail-fast: false
|
12
16
|
matrix:
|
13
17
|
ruby: [ '2.6', '2.5', '2.4' ]
|
14
18
|
steps:
|
@@ -21,9 +25,8 @@ jobs:
|
|
21
25
|
- name: Update gems
|
22
26
|
shell: pwsh
|
23
27
|
run: |
|
24
|
-
gem install bundler
|
28
|
+
gem install bundler
|
25
29
|
bundle config --local path vendor/bundle
|
26
|
-
bundle update
|
27
30
|
bundle install --jobs 4 --retry 3
|
28
31
|
- name: Run specs
|
29
32
|
run: |
|
data/README.adoc
CHANGED
@@ -1,9 +1,12 @@
|
|
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://
|
5
|
-
image:https://
|
6
|
-
image:https://
|
4
|
+
image:https://github.com/relaton/relaton-iev/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/relaton/relaton-iev/actions?workflow=macos"]
|
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"]
|
7
|
+
image:https://codeclimate.com/github/relaton/relaton-iev/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/relaton/relaton-iev"]
|
8
|
+
image:https://img.shields.io/github/issues-pr-raw/relaton/relaton-iev.svg["Pull Requests", link="https://github.com/relaton/relaton-iev/pulls"]
|
9
|
+
image:https://img.shields.io/github/commits-since/relaton/relaton-iev/latest.svg["Commits since latest",link="https://github.com/relaton/relaton-iev/releases"]
|
7
10
|
|
8
11
|
|
9
12
|
Metanorma references IEV as a single source, IEC 60050. In reality, IEC 60050 is dozens of separate documents, each with their own part number (corresponding to the starting number of the clause reference; so IEV clause 101-2-3 is actually IEC 60050-101 clause 101-2-3.) This gem helps rewrite the single IEV reference in a Metanorma document, out into all the references it actually corresponds to in the given document. It does so by parsing all first-level clauses in citations to IEV, replacing each by a reference to the IEC 60050 part corresponding to that clause, then looking up each of the IEC 60050 part documents using `relaton-iec`, and inserting those references into the XML document.
|
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
@@ -16,7 +16,7 @@ module RelatonIev
|
|
16
16
|
parts = Set.new
|
17
17
|
xmldoc.xpath("//eref[@citeas = 'IEC 60050:2011'] | "\
|
18
18
|
"//origin[@citeas = 'IEC 60050:2011']").each do |x|
|
19
|
-
cl = x&.at("
|
19
|
+
cl = x&.at(".//locality[@type = 'clause']/referenceFrom")&.text || next
|
20
20
|
m = /^(\d+)/.match cl || next
|
21
21
|
parts << m[0]
|
22
22
|
x["citeas"] = x["citeas"].sub(/60050/, "60050-#{m[0]}")
|
@@ -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
|
-
|
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]
|
data/lib/relaton_iev/version.rb
CHANGED
data/relaton_iev.gemspec
CHANGED
@@ -21,7 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
23
23
|
|
24
|
-
spec.add_development_dependency "bundler", "~> 2.0"
|
25
24
|
spec.add_development_dependency "debase"
|
26
25
|
spec.add_development_dependency "pry-byebug"
|
27
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -32,5 +31,5 @@ Gem::Specification.new do |spec|
|
|
32
31
|
spec.add_development_dependency "webmock"
|
33
32
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
34
33
|
|
35
|
-
spec.add_dependency "relaton", "
|
34
|
+
spec.add_dependency "relaton", ">= 1.6"
|
36
35
|
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:
|
4
|
+
version: 1.1.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:
|
11
|
+
date: 2020-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2.0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: debase
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,16 +140,16 @@ dependencies:
|
|
154
140
|
name: relaton
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
156
142
|
requirements:
|
157
|
-
- - "
|
143
|
+
- - ">="
|
158
144
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
145
|
+
version: '1.6'
|
160
146
|
type: :runtime
|
161
147
|
prerelease: false
|
162
148
|
version_requirements: !ruby/object:Gem::Requirement
|
163
149
|
requirements:
|
164
|
-
- - "
|
150
|
+
- - ">="
|
165
151
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
152
|
+
version: '1.6'
|
167
153
|
description: 'RelatonIev: manipulates IEV references to IEC 60050.'
|
168
154
|
email:
|
169
155
|
- open.source@ribose.com
|
@@ -178,11 +164,11 @@ files:
|
|
178
164
|
- ".rspec"
|
179
165
|
- ".rubocop.yml"
|
180
166
|
- Gemfile
|
181
|
-
- Gemfile.lock
|
182
167
|
- LICENSE.txt
|
183
168
|
- README.adoc
|
184
169
|
- Rakefile
|
185
170
|
- bin/console
|
171
|
+
- bin/rspec
|
186
172
|
- bin/setup
|
187
173
|
- lib/relaton_iev.rb
|
188
174
|
- lib/relaton_iev/version.rb
|
@@ -191,7 +177,7 @@ homepage: https://github.com/metanorma/relaton-iev
|
|
191
177
|
licenses:
|
192
178
|
- MIT
|
193
179
|
metadata: {}
|
194
|
-
post_install_message:
|
180
|
+
post_install_message:
|
195
181
|
rdoc_options: []
|
196
182
|
require_paths:
|
197
183
|
- lib
|
@@ -206,9 +192,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
192
|
- !ruby/object:Gem::Version
|
207
193
|
version: '0'
|
208
194
|
requirements: []
|
209
|
-
|
210
|
-
|
211
|
-
signing_key:
|
195
|
+
rubygems_version: 3.0.3
|
196
|
+
signing_key:
|
212
197
|
specification_version: 4
|
213
198
|
summary: 'RelatonIev: manipulates IEV references to IEC 60050.'
|
214
199
|
test_files: []
|
data/Gemfile.lock
DELETED
@@ -1,128 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
relaton-iev (0.1.1)
|
5
|
-
relaton (~> 0.5.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
addressable (2.7.0)
|
11
|
-
public_suffix (>= 2.0.2, < 5.0)
|
12
|
-
byebug (11.0.1)
|
13
|
-
cnccs (0.1.5)
|
14
|
-
coderay (1.1.2)
|
15
|
-
crack (0.4.3)
|
16
|
-
safe_yaml (~> 1.0.0)
|
17
|
-
debase (0.2.4.1)
|
18
|
-
debase-ruby_core_source (>= 0.10.2)
|
19
|
-
debase-ruby_core_source (0.10.7)
|
20
|
-
diff-lcs (1.3)
|
21
|
-
docile (1.3.2)
|
22
|
-
equivalent-xml (0.6.0)
|
23
|
-
nokogiri (>= 1.4.3)
|
24
|
-
faraday (0.17.1)
|
25
|
-
multipart-post (>= 1.2, < 3)
|
26
|
-
gb-agencies (0.0.6)
|
27
|
-
hashdiff (1.0.0)
|
28
|
-
isoics (0.1.8)
|
29
|
-
json (2.2.0)
|
30
|
-
method_source (0.9.2)
|
31
|
-
mini_portile2 (2.4.0)
|
32
|
-
multipart-post (2.1.1)
|
33
|
-
nokogiri (1.10.5)
|
34
|
-
mini_portile2 (~> 2.4.0)
|
35
|
-
pry (0.12.2)
|
36
|
-
coderay (~> 1.1.0)
|
37
|
-
method_source (~> 0.9.0)
|
38
|
-
pry-byebug (3.7.0)
|
39
|
-
byebug (~> 11.0)
|
40
|
-
pry (~> 0.10)
|
41
|
-
public_suffix (4.0.1)
|
42
|
-
rake (10.5.0)
|
43
|
-
relaton (0.5.19)
|
44
|
-
relaton-calconnect (~> 0.1.0)
|
45
|
-
relaton-gb (~> 0.6.0)
|
46
|
-
relaton-iec (~> 0.4.0)
|
47
|
-
relaton-ietf (~> 0.6.0)
|
48
|
-
relaton-iso (~> 0.6.0)
|
49
|
-
relaton-itu (~> 0.3.0)
|
50
|
-
relaton-nist (~> 0.3.0)
|
51
|
-
relaton-ogc (~> 0.1.0)
|
52
|
-
relaton-bib (0.3.12)
|
53
|
-
addressable
|
54
|
-
nokogiri
|
55
|
-
relaton-calconnect (0.1.2)
|
56
|
-
faraday
|
57
|
-
relaton-iso-bib (~> 0.3.0)
|
58
|
-
relaton-gb (0.6.8)
|
59
|
-
cnccs (~> 0.1.1)
|
60
|
-
gb-agencies (~> 0.0.1)
|
61
|
-
relaton-iso-bib (~> 0.3.0)
|
62
|
-
relaton-iec (0.4.12)
|
63
|
-
addressable
|
64
|
-
relaton-iso-bib (~> 0.3.0)
|
65
|
-
relaton-ietf (0.6.10)
|
66
|
-
relaton-bib (~> 0.3.0)
|
67
|
-
relaton-iso (0.6.10)
|
68
|
-
relaton-iec (~> 0.4.0)
|
69
|
-
relaton-iso-bib (~> 0.3.0)
|
70
|
-
relaton-iso-bib (0.3.12)
|
71
|
-
isoics (~> 0.1.6)
|
72
|
-
relaton-bib (~> 0.3.0)
|
73
|
-
ruby_deep_clone (~> 0.8.0)
|
74
|
-
relaton-itu (0.3.11)
|
75
|
-
relaton-iso-bib (~> 0.3.0)
|
76
|
-
relaton-nist (0.3.9)
|
77
|
-
relaton-bib (~> 0.3.0)
|
78
|
-
rubyzip
|
79
|
-
relaton-ogc (0.1.4)
|
80
|
-
faraday
|
81
|
-
relaton-iso-bib (~> 0.3.0)
|
82
|
-
rspec (3.8.0)
|
83
|
-
rspec-core (~> 3.8.0)
|
84
|
-
rspec-expectations (~> 3.8.0)
|
85
|
-
rspec-mocks (~> 3.8.0)
|
86
|
-
rspec-core (3.8.2)
|
87
|
-
rspec-support (~> 3.8.0)
|
88
|
-
rspec-expectations (3.8.4)
|
89
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
90
|
-
rspec-support (~> 3.8.0)
|
91
|
-
rspec-mocks (3.8.1)
|
92
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
93
|
-
rspec-support (~> 3.8.0)
|
94
|
-
rspec-support (3.8.2)
|
95
|
-
ruby-debug-ide (0.7.0)
|
96
|
-
rake (>= 0.8.1)
|
97
|
-
ruby_deep_clone (0.8.0)
|
98
|
-
rubyzip (2.0.0)
|
99
|
-
safe_yaml (1.0.5)
|
100
|
-
simplecov (0.17.0)
|
101
|
-
docile (~> 1.1)
|
102
|
-
json (>= 1.8, < 3)
|
103
|
-
simplecov-html (~> 0.10.0)
|
104
|
-
simplecov-html (0.10.2)
|
105
|
-
vcr (5.0.0)
|
106
|
-
webmock (3.7.2)
|
107
|
-
addressable (>= 2.3.6)
|
108
|
-
crack (>= 0.3.2)
|
109
|
-
hashdiff (>= 0.4.0, < 2.0.0)
|
110
|
-
|
111
|
-
PLATFORMS
|
112
|
-
ruby
|
113
|
-
|
114
|
-
DEPENDENCIES
|
115
|
-
bundler (~> 2.0)
|
116
|
-
debase
|
117
|
-
equivalent-xml (~> 0.6)
|
118
|
-
pry-byebug
|
119
|
-
rake (~> 10.0)
|
120
|
-
relaton-iev!
|
121
|
-
rspec (~> 3.0)
|
122
|
-
ruby-debug-ide
|
123
|
-
simplecov
|
124
|
-
vcr
|
125
|
-
webmock
|
126
|
-
|
127
|
-
BUNDLED WITH
|
128
|
-
2.0.2
|