relaton-iec 1.14.3 → 1.16.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/rake.yml +1 -0
- data/.github/workflows/release.yml +5 -3
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/Gemfile +3 -0
- data/grammars/basicdoc.rng +0 -1
- data/grammars/biblio.rng +13 -3
- data/lib/relaton_iec/data_parser.rb +1 -1
- data/lib/relaton_iec/hit_collection.rb +2 -2
- data/lib/relaton_iec/iec_bibliographic_item.rb +3 -3
- data/lib/relaton_iec/iec_bibliography.rb +99 -28
- data/lib/relaton_iec/index.rb +1 -1
- data/lib/relaton_iec/processor.rb +7 -0
- data/lib/relaton_iec/version.rb +1 -1
- data/lib/relaton_iec/xml_parser.rb +1 -1
- data/relaton_iec.gemspec +3 -7
- metadata +11 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 407e0b683664d9b9e59bcbf2dadbbcc3b3289df9d16354cf7704b27529169020
|
4
|
+
data.tar.gz: dc55bf895de7f08f93f9430c348d562903567df12f5e93c1a7916082c4742ed5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4d1c322f0fd0d0f4a5d21c6cebd43f1f8556d34cd096f547da2c16e8f4a437294be845812b35fa1880c0d790092ae13926bd65fbb9d6a24d6c53263417fb3b4
|
7
|
+
data.tar.gz: ff11597b0da5425a9c402d2da4926200703636b7d88a305299e6d59897e0835f1f68ca2b65f01f94e8f6ff4950e726957bd52ce5624ec712ab67c8f2a794e229
|
data/.github/workflows/rake.yml
CHANGED
@@ -7,11 +7,13 @@ on:
|
|
7
7
|
inputs:
|
8
8
|
next_version:
|
9
9
|
description: |
|
10
|
-
Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
|
10
|
+
Next release version. Possible values: x.y.z, major, minor, patch (or pre|rc|etc).
|
11
|
+
Also, you can pass 'skip' to skip 'git tag' and do 'gem push' for the current version
|
11
12
|
required: true
|
12
13
|
default: 'skip'
|
13
|
-
|
14
|
-
|
14
|
+
repository_dispatch:
|
15
|
+
types: [ do-release ]
|
16
|
+
|
15
17
|
|
16
18
|
jobs:
|
17
19
|
release:
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
@@ -5,7 +5,10 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
|
5
5
|
# Specify your gem's dependencies in relaton_iec.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
+
gem "equivalent-xml", "~> 0.6"
|
8
9
|
gem "pry-byebug"
|
10
|
+
gem "rake", "~> 13.0"
|
11
|
+
gem "rspec", "~> 3.0"
|
9
12
|
gem "ruby-jing"
|
10
13
|
gem "simplecov"
|
11
14
|
gem "vcr"
|
data/grammars/basicdoc.rng
CHANGED
data/grammars/biblio.rng
CHANGED
@@ -216,6 +216,9 @@
|
|
216
216
|
<optional>
|
217
217
|
<ref name="fullname"/>
|
218
218
|
</optional>
|
219
|
+
<zeroOrMore>
|
220
|
+
<ref name="credential"/>
|
221
|
+
</zeroOrMore>
|
219
222
|
<zeroOrMore>
|
220
223
|
<ref name="affiliation"/>
|
221
224
|
</zeroOrMore>
|
@@ -232,6 +235,11 @@
|
|
232
235
|
<ref name="FullNameType"/>
|
233
236
|
</element>
|
234
237
|
</define>
|
238
|
+
<define name="credential">
|
239
|
+
<element name="credential">
|
240
|
+
<text/>
|
241
|
+
</element>
|
242
|
+
</define>
|
235
243
|
<define name="FullNameType">
|
236
244
|
<choice>
|
237
245
|
<group>
|
@@ -305,7 +313,9 @@
|
|
305
313
|
<zeroOrMore>
|
306
314
|
<ref name="affiliationdescription"/>
|
307
315
|
</zeroOrMore>
|
308
|
-
<
|
316
|
+
<optional>
|
317
|
+
<ref name="organization"/>
|
318
|
+
</optional>
|
309
319
|
</element>
|
310
320
|
</define>
|
311
321
|
<define name="affiliationname">
|
@@ -1273,7 +1283,7 @@
|
|
1273
1283
|
<value>mergedInto</value>
|
1274
1284
|
<value>splits</value>
|
1275
1285
|
<value>splitInto</value>
|
1276
|
-
<value>
|
1286
|
+
<value>instanceOf</value>
|
1277
1287
|
<value>hasInstance</value>
|
1278
1288
|
<value>exemplarOf</value>
|
1279
1289
|
<value>hasExemplar</value>
|
@@ -1316,7 +1326,7 @@
|
|
1316
1326
|
<value>commentaryOf</value>
|
1317
1327
|
<value>hasCommentary</value>
|
1318
1328
|
<value>related</value>
|
1319
|
-
<value>
|
1329
|
+
<value>hasComplement</value>
|
1320
1330
|
<value>complementOf</value>
|
1321
1331
|
<value>obsoletes</value>
|
1322
1332
|
<value>obsoletedBy</value>
|
@@ -238,7 +238,7 @@ module RelatonIec
|
|
238
238
|
when "TR" then "technical-report"
|
239
239
|
when "TS" then "technical-specification"
|
240
240
|
when "PAS" then "publicly-available-specification"
|
241
|
-
when "SRD" then "system-reference-
|
241
|
+
when "SRD" then "system-reference-deliverable"
|
242
242
|
else @pub["stdType"].downcase
|
243
243
|
end
|
244
244
|
end
|
@@ -8,13 +8,13 @@ module RelatonIec
|
|
8
8
|
class HitCollection < RelatonBib::HitCollection
|
9
9
|
def_delegators :@array, :detect, :map
|
10
10
|
|
11
|
-
|
11
|
+
INDEX_FILE = "index1.yaml"
|
12
12
|
|
13
13
|
# @param ref [String]
|
14
14
|
# @param year [String, nil]
|
15
15
|
def initialize(ref, year = nil)
|
16
16
|
super ref, year
|
17
|
-
@index = Relaton::Index.find_or_create :IEC, url: "#{Hit::GHURL}index1.zip" , file:
|
17
|
+
@index = Relaton::Index.find_or_create :IEC, url: "#{Hit::GHURL}index1.zip" , file: INDEX_FILE
|
18
18
|
@array = fetch_from_gh
|
19
19
|
end
|
20
20
|
|
@@ -6,7 +6,7 @@ module RelatonIec
|
|
6
6
|
guide industry-technical-agreement system-reference-deliverable
|
7
7
|
].freeze
|
8
8
|
|
9
|
-
|
9
|
+
SUBDOCTYPES = %w[specification method-of-test vocabulary code-of-practice].freeze
|
10
10
|
|
11
11
|
FUNCTION = %w[emc safety enviroment quality-assurance].freeze
|
12
12
|
|
@@ -39,9 +39,9 @@ module RelatonIec
|
|
39
39
|
end
|
40
40
|
if args[:updates_document_type] &&
|
41
41
|
!DOCTYPES.include?(args[:updates_document_type])
|
42
|
-
warn "[relaton-iec] WARNING: invalid updates_document_type "\
|
42
|
+
warn "[relaton-iec] WARNING: invalid updates_document_type " \
|
43
43
|
"\"#{args[:updates_document_type]}\""
|
44
|
-
warn "[relaton-iec] allowed updates_document_type values are: "\
|
44
|
+
warn "[relaton-iec] allowed updates_document_type values are: " \
|
45
45
|
"#{DOCTYPES.join(', ')}"
|
46
46
|
end
|
47
47
|
@function = args.delete :function
|
@@ -41,34 +41,97 @@ module RelatonIec
|
|
41
41
|
|
42
42
|
private
|
43
43
|
|
44
|
+
# @param pubid [String]
|
45
|
+
# @param year [String]
|
46
|
+
# @param missed_years [Array<String>]
|
47
|
+
def warn_missing_years(pubid, year, missed_years)
|
48
|
+
id = ref_with_year(pubid, year)
|
49
|
+
warn "[relaton-iec] (\"#{id}\") TIP: " \
|
50
|
+
"No match for edition year #{year}, " \
|
51
|
+
"but matches exist for #{missed_years.uniq.join(', ')}."
|
52
|
+
end
|
53
|
+
|
44
54
|
# @param code [String]
|
45
55
|
# @param year [String]
|
46
56
|
# @param missed_years [Array<String>]
|
47
57
|
def fetch_ref_err(code, year, missed_years) # rubocop:disable Metrics/MethodLength
|
48
|
-
id =
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
58
|
+
id = ref_with_year(code, year)
|
59
|
+
|
60
|
+
warn "[relaton-iec] (\"#{id}\") " \
|
61
|
+
"Not found. "\
|
62
|
+
"The identifier must be exactly as shown on the IEC Webstore."
|
63
|
+
|
64
|
+
if year && missed_years.any?
|
65
|
+
warn_missing_years(code, year, missed_years)
|
54
66
|
end
|
55
|
-
|
56
|
-
|
57
|
-
|
67
|
+
|
68
|
+
# TODO: change this to pubid-iec
|
69
|
+
has_part = /\d-\d/.match?(code)
|
70
|
+
if has_part
|
71
|
+
warn "[relaton-iec] (\"#{id}\") TIP: " \
|
72
|
+
"If it cannot be found, the document may no longer be published in parts."
|
73
|
+
|
58
74
|
else
|
59
|
-
warn "[relaton-iec]
|
60
|
-
"
|
61
|
-
"
|
62
|
-
|
75
|
+
warn "[relaton-iec] (\"#{id}\") TIP: " \
|
76
|
+
"If you wish to cite all document parts for the reference, " \
|
77
|
+
"use (\"#{code} (all parts)\")."
|
78
|
+
end
|
79
|
+
|
80
|
+
# TODO: streamline after integration with pubid-iec
|
81
|
+
doctypes = %w(TS TR PAS SRD TEC STTR WP Guide OD CS CA)
|
82
|
+
selected_doctype = doctypes.select do |t|
|
83
|
+
code.include?("#{t} ")
|
84
|
+
end
|
85
|
+
unless selected_doctype
|
86
|
+
warn "[relaton-iec] (\"#{id}\") TIP: " \
|
87
|
+
"If the document is not an International Standard, use its " \
|
88
|
+
"deliverable type abbreviation (#{doctypes.join(", ")})."
|
63
89
|
end
|
90
|
+
|
64
91
|
nil
|
65
92
|
end
|
66
93
|
|
67
94
|
# @param ref [String]
|
95
|
+
# @param year [String]
|
96
|
+
# @return [String]
|
97
|
+
def ref_with_year(ref, year)
|
98
|
+
year ? [ref, year].join(":") : ref
|
99
|
+
end
|
100
|
+
|
101
|
+
# @param ref [String]
|
102
|
+
# @param year [String, nil]
|
103
|
+
# @return [RelatonIec::HitCollection]
|
104
|
+
# def search_filter(ref, year) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
105
|
+
# rp1 = ref_parts ref.upcase
|
106
|
+
# year ||= rp1[:year]
|
107
|
+
# corr = rp1[:corr]&.sub " ", ""
|
108
|
+
# warn "[relaton-iec] (\"#{ref_with_year(ref, year)}\") Fetching from IEC..."
|
109
|
+
# result = search(rp1[:code], year)
|
110
|
+
# code = result.text.dup
|
111
|
+
# if result.empty? && /(?<=\d-)(?<part>[\w-]+)/ =~ rp1[:code]
|
112
|
+
# # try to search packaged standard
|
113
|
+
# result = search rp1[:code], year, part
|
114
|
+
# pkg_std = result.any?
|
115
|
+
# end
|
116
|
+
# result = search rp1[:code] if result.empty?
|
117
|
+
# if pkg_std
|
118
|
+
# code.sub!(/(?<=\d-)#{part}/, part[0])
|
119
|
+
# else
|
120
|
+
# code.sub!(/-[-\d]+/, "")
|
121
|
+
# end
|
122
|
+
# result.select do |i|
|
123
|
+
# rp2 = ref_parts i.hit[:code]
|
124
|
+
# code2 = if pkg_std
|
125
|
+
# rp2[:code].sub(/(?<=\d-\d)\d+/, "")
|
126
|
+
# else
|
127
|
+
# rp2[:code].sub(/-[-\d]+/, "")
|
128
|
+
# end
|
129
|
+
# code == code2 && rp1[:bundle] == rp2[:bundle] && corr == rp2[:corr]
|
130
|
+
# end
|
68
131
|
# @return [RelatonIec::HitCollection]
|
69
|
-
def search_filter(ref)
|
132
|
+
def search_filter(ref, year)
|
70
133
|
code = ref.split(":").first
|
71
|
-
warn "[relaton-iec] (\"#{ref}\")
|
134
|
+
warn "[relaton-iec] (\"#{ref_with_year(ref, year)}\") Fetching from IEC..."
|
72
135
|
search(code)
|
73
136
|
end
|
74
137
|
|
@@ -184,21 +247,29 @@ module RelatonIec
|
|
184
247
|
# @param year [String, nil]
|
185
248
|
# @param opts [Hash]
|
186
249
|
# @return [RelatonIec::IecBibliographicItem, nil]
|
187
|
-
def iecbib_get(
|
188
|
-
result = search_filter(
|
189
|
-
ret = results_filter(result,
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
ret[:ret]
|
250
|
+
def iecbib_get(code, year, opts) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
251
|
+
result = search_filter(code, year) || return
|
252
|
+
ret = results_filter(result, code, year, opts)
|
253
|
+
|
254
|
+
return fetch_ref_err(code, year, ret[:years]) unless ret[:ret]
|
255
|
+
|
256
|
+
id = ref_with_year(code, year)
|
257
|
+
docid = ret[:ret].docidentifier.first.id
|
258
|
+
|
259
|
+
if id == docid
|
260
|
+
warn "[relaton-iec] (\"#{id}\") Found exact match."
|
199
261
|
else
|
200
|
-
|
262
|
+
warn "[relaton-iec] (\"#{id}\") Found (\"#{docid}\")."
|
201
263
|
end
|
264
|
+
|
265
|
+
if ret[:missed_parts]
|
266
|
+
warn "[relaton-iec] (\"#{id}\") TIP: " \
|
267
|
+
"\"#{code}\" also contains other parts, " \
|
268
|
+
"if you want to cite all parts, use "\
|
269
|
+
"(\"#{code} (all parts)\")."
|
270
|
+
end
|
271
|
+
|
272
|
+
ret[:ret]
|
202
273
|
end
|
203
274
|
end
|
204
275
|
end
|
data/lib/relaton_iec/index.rb
CHANGED
@@ -53,5 +53,12 @@ module RelatonIec
|
|
53
53
|
def urn_to_code(code)
|
54
54
|
RelatonIec.urn_to_code code
|
55
55
|
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# Remove index file
|
59
|
+
#
|
60
|
+
def remove_index_file
|
61
|
+
Relaton::Index.find_or_create(:IEC, url: true, file: HitCollection::INDEX_FILE).remove_file
|
62
|
+
end
|
56
63
|
end
|
57
64
|
end
|
data/lib/relaton_iec/version.rb
CHANGED
data/relaton_iec.gemspec
CHANGED
@@ -21,14 +21,10 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.bindir = "exe"
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
25
|
-
|
26
|
-
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
27
|
-
spec.add_development_dependency "rake", "~> 13.0"
|
28
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
29
25
|
|
30
26
|
spec.add_dependency "addressable"
|
31
|
-
spec.add_dependency "relaton-index", "~> 0.
|
32
|
-
spec.add_dependency "relaton-iso-bib", "~> 1.
|
27
|
+
spec.add_dependency "relaton-index", "~> 0.2.0"
|
28
|
+
spec.add_dependency "relaton-iso-bib", "~> 1.16.0"
|
33
29
|
spec.add_dependency "rubyzip"
|
34
30
|
end
|
metadata
CHANGED
@@ -1,57 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-iec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.16.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: 2023-
|
11
|
+
date: 2023-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: equivalent-xml
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.6'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0.6'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '13.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '13.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.0'
|
55
13
|
- !ruby/object:Gem::Dependency
|
56
14
|
name: addressable
|
57
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,28 +30,28 @@ dependencies:
|
|
72
30
|
requirements:
|
73
31
|
- - "~>"
|
74
32
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
33
|
+
version: 0.2.0
|
76
34
|
type: :runtime
|
77
35
|
prerelease: false
|
78
36
|
version_requirements: !ruby/object:Gem::Requirement
|
79
37
|
requirements:
|
80
38
|
- - "~>"
|
81
39
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
40
|
+
version: 0.2.0
|
83
41
|
- !ruby/object:Gem::Dependency
|
84
42
|
name: relaton-iso-bib
|
85
43
|
requirement: !ruby/object:Gem::Requirement
|
86
44
|
requirements:
|
87
45
|
- - "~>"
|
88
46
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.
|
47
|
+
version: 1.16.0
|
90
48
|
type: :runtime
|
91
49
|
prerelease: false
|
92
50
|
version_requirements: !ruby/object:Gem::Requirement
|
93
51
|
requirements:
|
94
52
|
- - "~>"
|
95
53
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.
|
54
|
+
version: 1.16.0
|
97
55
|
- !ruby/object:Gem::Dependency
|
98
56
|
name: rubyzip
|
99
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,7 +127,7 @@ homepage: https://github.com/metanorma/relaton-iec
|
|
169
127
|
licenses:
|
170
128
|
- MIT
|
171
129
|
metadata: {}
|
172
|
-
post_install_message:
|
130
|
+
post_install_message:
|
173
131
|
rdoc_options: []
|
174
132
|
require_paths:
|
175
133
|
- lib
|
@@ -177,15 +135,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
135
|
requirements:
|
178
136
|
- - ">="
|
179
137
|
- !ruby/object:Gem::Version
|
180
|
-
version: 2.
|
138
|
+
version: 2.7.0
|
181
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
140
|
requirements:
|
183
141
|
- - ">="
|
184
142
|
- !ruby/object:Gem::Version
|
185
143
|
version: '0'
|
186
144
|
requirements: []
|
187
|
-
rubygems_version: 3.
|
188
|
-
signing_key:
|
145
|
+
rubygems_version: 3.3.26
|
146
|
+
signing_key:
|
189
147
|
specification_version: 4
|
190
148
|
summary: 'RelatonIec: retrieve IEC Standards for bibliographic use using the IecBibliographicItem
|
191
149
|
model'
|