relaton-iec 2.0.0.pre.alpha.3 → 2.0.0.pre.alpha.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/README.adoc +4 -4
- data/grammars/basicdoc.rng +14 -1
- data/grammars/biblio.rng +8 -8
- data/lib/relaton/iec/bibliography.rb +2 -2
- data/lib/relaton/iec/data_fetcher.rb +11 -6
- data/lib/relaton/iec/data_parser.rb +88 -25
- data/lib/relaton/iec/hit_collection.rb +2 -2
- data/lib/relaton/iec/model/docidentifier.rb +57 -22
- data/lib/relaton/iec/version.rb +1 -1
- data/relaton_iec.gemspec +3 -3
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ebeb05280a8fbd70863f0fbe6d73d9e8d0955680793374b75dfe11481d27ddf8
|
|
4
|
+
data.tar.gz: dabab87eabda78692f9dcd031731cc3c1e8a62a71ce1ebba498b25adbd8da484
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a04af9af473fc47d98cde3b47d4d941fdcc43641860ec1f6fb56132fd053007353d9fc67b617b3f856be18a4cb0af4523be1c2c78a3ea753523d4e0378dcca69
|
|
7
|
+
data.tar.gz: ff377cf623ba4806c34e78cc2c18e04b0a462ac2875d3daf76e9cf00aee037546c643c63290b18cbb82248f10cbdfdad98beb9ec0816aa3b727444bbef97f7f8
|
data/README.adoc
CHANGED
|
@@ -122,7 +122,7 @@ Possible options:
|
|
|
122
122
|
[source,ruby]
|
|
123
123
|
----
|
|
124
124
|
item.to_xml
|
|
125
|
-
=> "<bibitem id="IEC600501122010" type="standard" schema-version="v1.
|
|
125
|
+
=> "<bibitem id="IEC600501122010" type="standard" schema-version="v1.5.6">
|
|
126
126
|
<fetched>2026-02-02</fetched>
|
|
127
127
|
<title language="en" script="Latn" type="title-main">International Electrotechnical Vocabulary (IEV)</title>
|
|
128
128
|
<title language="en" script="Latn" type="title-part">Part 112: Quantities and units</title>
|
|
@@ -141,7 +141,7 @@ item.to_xml
|
|
|
141
141
|
</bibitem>"
|
|
142
142
|
|
|
143
143
|
item.to_xml bibdata: true
|
|
144
|
-
=> "<bibdata type="standard" schema-version="v1.
|
|
144
|
+
=> "<bibdata type="standard" schema-version="v1.5.6">
|
|
145
145
|
<fetched>2026-02-02</fetched>
|
|
146
146
|
<title language="en" script="Latn" type="title-main">International Electrotechnical Vocabulary (IEV)</title>
|
|
147
147
|
<title language="en" script="Latn" type="title-part">Part 112: Quantities and units</title>
|
|
@@ -157,14 +157,14 @@ item.to_xml bibdata: true
|
|
|
157
157
|
<docidentifier type="IEC" primary="true">IEC 60050-112:2010</docidentifier>
|
|
158
158
|
<docidentifier type="URN">urn:iec:std:iec:60050-112:2010-01:::</docidentifier>
|
|
159
159
|
...
|
|
160
|
-
<ext schema-version="v1.
|
|
160
|
+
<ext schema-version="v1.1.2">
|
|
161
161
|
<doctype>international-standard</doctype>
|
|
162
162
|
...
|
|
163
163
|
</ext>
|
|
164
164
|
</bibdata>"
|
|
165
165
|
|
|
166
166
|
item.to_xml note: [{ content: "Note", type: "note" }]
|
|
167
|
-
=> "<bibitem id="IEC600501122010" type="standard" schema-version="v1.
|
|
167
|
+
=> "<bibitem id="IEC600501122010" type="standard" schema-version="v1.5.6">
|
|
168
168
|
...
|
|
169
169
|
<note type="note">Note</note>
|
|
170
170
|
...
|
data/grammars/basicdoc.rng
CHANGED
|
@@ -187,6 +187,15 @@ Applicable to modify and delete</a:documentation>
|
|
|
187
187
|
<a:documentation>Optional caption of this block</a:documentation>
|
|
188
188
|
</attribute>
|
|
189
189
|
</optional>
|
|
190
|
+
<optional>
|
|
191
|
+
<attribute name="position">
|
|
192
|
+
<a:documentation>For an "add" change, whether the change is added before or after the location</a:documentation>
|
|
193
|
+
<choice>
|
|
194
|
+
<value>before</value>
|
|
195
|
+
<value>after</value>
|
|
196
|
+
</choice>
|
|
197
|
+
</attribute>
|
|
198
|
+
</optional>
|
|
190
199
|
<optional>
|
|
191
200
|
<element name="location">
|
|
192
201
|
<a:documentation>The location(s) in the original document which have undergone the change described in this block</a:documentation>
|
|
@@ -208,11 +217,15 @@ Applicable to modify and delete</a:documentation>
|
|
|
208
217
|
</zeroOrMore>
|
|
209
218
|
<optional>
|
|
210
219
|
<element name="newcontent">
|
|
211
|
-
<a:documentation>New content to be added to the document; applicable to add and modify
|
|
220
|
+
<a:documentation>New content to be added to the document; applicable to add and modify.
|
|
221
|
+
Can be blocks and/or sections</a:documentation>
|
|
212
222
|
<ref name="OptionalId"/>
|
|
213
223
|
<zeroOrMore>
|
|
214
224
|
<ref name="BasicBlock"/>
|
|
215
225
|
</zeroOrMore>
|
|
226
|
+
<zeroOrMore>
|
|
227
|
+
<ref name="section"/>
|
|
228
|
+
</zeroOrMore>
|
|
216
229
|
</element>
|
|
217
230
|
</optional>
|
|
218
231
|
<zeroOrMore>
|
data/grammars/biblio.rng
CHANGED
|
@@ -1142,11 +1142,11 @@ NOTE: This should preferably be encoded as a URI or short identifier, rather th
|
|
|
1142
1142
|
<a:documentation>Information about how long the current description of the bibliographic item is valid for</a:documentation>
|
|
1143
1143
|
</ref>
|
|
1144
1144
|
</optional>
|
|
1145
|
-
<
|
|
1145
|
+
<zeroOrMore>
|
|
1146
1146
|
<ref name="depiction">
|
|
1147
1147
|
<a:documentation>Depiction of the bibliographic item, typically an image</a:documentation>
|
|
1148
1148
|
</ref>
|
|
1149
|
-
</
|
|
1149
|
+
</zeroOrMore>
|
|
1150
1150
|
</define>
|
|
1151
1151
|
<define name="ReducedBibliographicItem">
|
|
1152
1152
|
<a:documentation>Reduced description of a bibliographic resource, without mandatory title and docidentifier, used for document relations
|
|
@@ -1939,10 +1939,10 @@ Detailed in https://www.relaton.org/model/relations/</a:documentation>
|
|
|
1939
1939
|
<value>hasAnnotation</value>
|
|
1940
1940
|
<value>draftOf</value>
|
|
1941
1941
|
<value>hasDraft</value>
|
|
1942
|
-
<value>
|
|
1943
|
-
<value>
|
|
1944
|
-
<value>
|
|
1945
|
-
<value>
|
|
1942
|
+
<value>predecessorDraftOf</value>
|
|
1943
|
+
<value>hasPredecessorDraft</value>
|
|
1944
|
+
<value>successorDraftOf</value>
|
|
1945
|
+
<value>hasSuccessorDraft</value>
|
|
1946
1946
|
<value>editionOf</value>
|
|
1947
1947
|
<value>hasEdition</value>
|
|
1948
1948
|
<value>updates</value>
|
|
@@ -2063,13 +2063,13 @@ provided that it is not the entire bibliographic item that is so related</a:docu
|
|
|
2063
2063
|
<ref name="LocalizedString"/>
|
|
2064
2064
|
</element>
|
|
2065
2065
|
</optional>
|
|
2066
|
-
<
|
|
2066
|
+
<zeroOrMore>
|
|
2067
2067
|
<element name="taxon">
|
|
2068
2068
|
<a:documentation>The keywords as a hierarchical taxonomy. For example, the sequence of `taxon` elements
|
|
2069
2069
|
`pump`, `centrifugal pump`, `line shaft pump` represents a taxonomic classification</a:documentation>
|
|
2070
2070
|
<ref name="LocalizedString"/>
|
|
2071
2071
|
</element>
|
|
2072
|
-
</
|
|
2072
|
+
</zeroOrMore>
|
|
2073
2073
|
<zeroOrMore>
|
|
2074
2074
|
<ref name="vocabid">
|
|
2075
2075
|
<a:documentation>Identifiers for the keyword as a controlled vocabulary</a:documentation>
|
|
@@ -34,7 +34,7 @@ module Relaton
|
|
|
34
34
|
ref = code.sub(/\s\(all parts\)/, "")
|
|
35
35
|
return iev if ref.casecmp("IEV").zero?
|
|
36
36
|
|
|
37
|
-
pubid = Pubid::Iec::Identifier.parse ref.upcase
|
|
37
|
+
pubid = ::Pubid::Iec::Identifier.parse ref.upcase
|
|
38
38
|
pubid.year = year.to_i if year
|
|
39
39
|
|
|
40
40
|
ret = iecbib_get(pubid, opts)
|
|
@@ -213,7 +213,7 @@ module Relaton
|
|
|
213
213
|
end
|
|
214
214
|
|
|
215
215
|
rel.bibitem.docidentifier&.each do |did|
|
|
216
|
-
year = did.
|
|
216
|
+
year = did.to_s[/:(\d{4})/, 1]&.to_i
|
|
217
217
|
next unless year&.positive?
|
|
218
218
|
|
|
219
219
|
return false if opts[:publication_date_before] && year >= opts[:publication_date_before].year
|
|
@@ -12,6 +12,10 @@ module Relaton
|
|
|
12
12
|
#
|
|
13
13
|
# Fetch data from IEC.
|
|
14
14
|
#
|
|
15
|
+
def log_error(msg)
|
|
16
|
+
Util.error msg
|
|
17
|
+
end
|
|
18
|
+
|
|
15
19
|
def fetch(source = "iec-harmonised-latest") # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
16
20
|
@all = source == "iec-harmonised-all"
|
|
17
21
|
|
|
@@ -23,6 +27,7 @@ module Relaton
|
|
|
23
27
|
fetch_all
|
|
24
28
|
index.save
|
|
25
29
|
save_last_change
|
|
30
|
+
report_errors
|
|
26
31
|
rescue StandardError => e
|
|
27
32
|
Util.error do
|
|
28
33
|
"#{e.message}\n#{e.backtrace.join("\n")}"
|
|
@@ -53,7 +58,7 @@ module Relaton
|
|
|
53
58
|
|
|
54
59
|
def index
|
|
55
60
|
@index ||= Relaton::Index.find_or_create(
|
|
56
|
-
:iec, file: "#{INDEXFILE}.yaml", pubid_class: Pubid::Iec::Identifier
|
|
61
|
+
:iec, file: "#{INDEXFILE}.yaml", pubid_class: ::Pubid::Iec::Identifier
|
|
57
62
|
)
|
|
58
63
|
end
|
|
59
64
|
|
|
@@ -81,7 +86,7 @@ module Relaton
|
|
|
81
86
|
did = find_primary_docidentifier item
|
|
82
87
|
return unless did
|
|
83
88
|
|
|
84
|
-
pubid = parse_pubid(did.
|
|
89
|
+
pubid = parse_pubid(did.to_s)
|
|
85
90
|
index.add_or_update pubid, file if pubid
|
|
86
91
|
rescue StandardError => e
|
|
87
92
|
Util.warn "Failed to index file `#{file}`: #{e.message}"
|
|
@@ -184,13 +189,13 @@ module Relaton
|
|
|
184
189
|
# @param [Hash] pub publication
|
|
185
190
|
#
|
|
186
191
|
def fetch_pub(pub) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
187
|
-
bib = DataParser.new(pub).parse
|
|
192
|
+
bib = DataParser.new(pub, @errors).parse
|
|
188
193
|
did = bib.docidentifier.detect(&:primary)
|
|
189
|
-
file = output_file(did.
|
|
194
|
+
file = output_file(did.to_s)
|
|
190
195
|
if @files.include? file then Util.warn "File #{file} exists."
|
|
191
196
|
else
|
|
192
197
|
@files << file
|
|
193
|
-
pubid = parse_pubid(did.
|
|
198
|
+
pubid = parse_pubid(did.to_s)
|
|
194
199
|
index.add_or_update pubid, file if pubid
|
|
195
200
|
end
|
|
196
201
|
@last_change_max = pub["lastChangeTimestamp"] if last_change_max < pub["lastChangeTimestamp"]
|
|
@@ -198,7 +203,7 @@ module Relaton
|
|
|
198
203
|
end
|
|
199
204
|
|
|
200
205
|
def parse_pubid(content)
|
|
201
|
-
Pubid::Iec::Identifier.parse(content)
|
|
206
|
+
::Pubid::Iec::Identifier.parse(content)
|
|
202
207
|
rescue StandardError => e
|
|
203
208
|
Util.warn "Failed to parse pubid `#{content}`: #{e.message}"
|
|
204
209
|
nil
|
|
@@ -31,8 +31,9 @@ module Relaton
|
|
|
31
31
|
#
|
|
32
32
|
# @param [Hash] pub document data
|
|
33
33
|
#
|
|
34
|
-
def initialize(pub)
|
|
34
|
+
def initialize(pub, errors = {})
|
|
35
35
|
@pub = pub
|
|
36
|
+
@errors = errors
|
|
36
37
|
end
|
|
37
38
|
|
|
38
39
|
#
|
|
@@ -55,10 +56,38 @@ module Relaton
|
|
|
55
56
|
# @return [Array<Relaton::Bib::Docidentifier>] document identifiers
|
|
56
57
|
#
|
|
57
58
|
def docidentifier
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
result = [iec_docid, urn_docid].compact
|
|
60
|
+
@errors[:docidentifier] &&= result.empty?
|
|
61
|
+
result
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def iec_docid
|
|
65
|
+
pubid = ::Pubid::Iec::Identifier.parse(@pub["reference"])
|
|
66
|
+
Docidentifier.new(content: pubid, type: "IEC", primary: true)
|
|
67
|
+
rescue StandardError => e
|
|
68
|
+
Util.warn "Failed to parse IEC identifier `#{@pub['reference']}`: #{e.message}"
|
|
69
|
+
Docidentifier.new(content: @pub["reference"], type: "IEC", primary: true)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def urn_docid
|
|
73
|
+
pubid = parse_urn_pubid
|
|
74
|
+
return unless pubid
|
|
75
|
+
|
|
76
|
+
Docidentifier.new(content: pubid, type: "URN")
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def parse_urn_pubid
|
|
80
|
+
if @pub["urnAlt"]&.first
|
|
81
|
+
urnid = "urn:#{@pub['urnAlt'][0]}"
|
|
82
|
+
begin
|
|
83
|
+
return ::Pubid::Iec::Identifier.parse(urnid)
|
|
84
|
+
rescue StandardError => e
|
|
85
|
+
Util.warn "Failed to parse URN `#{urnid}`: #{e.message}"
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
::Pubid::Iec::Identifier.parse(@pub["reference"])
|
|
89
|
+
rescue StandardError
|
|
90
|
+
nil
|
|
62
91
|
end
|
|
63
92
|
|
|
64
93
|
#
|
|
@@ -67,7 +96,9 @@ module Relaton
|
|
|
67
96
|
# @return [Array<String>] languages
|
|
68
97
|
#
|
|
69
98
|
def language
|
|
70
|
-
@pub["title"].map { |t| t["lang"] }.uniq
|
|
99
|
+
result = @pub["title"].map { |t| t["lang"] }.uniq
|
|
100
|
+
@errors[:language] &&= result.empty?
|
|
101
|
+
result
|
|
71
102
|
end
|
|
72
103
|
|
|
73
104
|
#
|
|
@@ -76,10 +107,12 @@ module Relaton
|
|
|
76
107
|
# @return [Array<String>] scripts
|
|
77
108
|
#
|
|
78
109
|
def script
|
|
79
|
-
language.each_with_object([]) do |l, s|
|
|
110
|
+
result = language.each_with_object([]) do |l, s|
|
|
80
111
|
scr = lang_to_script l
|
|
81
112
|
s << scr if scr && !s.include?(scr)
|
|
82
113
|
end
|
|
114
|
+
@errors[:script] &&= result.empty?
|
|
115
|
+
result
|
|
83
116
|
end
|
|
84
117
|
|
|
85
118
|
#
|
|
@@ -101,18 +134,26 @@ module Relaton
|
|
|
101
134
|
# @return [Array<Relaton::Bib::Title>] titles
|
|
102
135
|
#
|
|
103
136
|
def title
|
|
104
|
-
@pub["title"].reduce([]) do |acc, t|
|
|
137
|
+
result = @pub["title"].reduce([]) do |acc, t|
|
|
105
138
|
acc + Bib::Title.from_string(t["value"], t["lang"], lang_to_script(t["lang"]))
|
|
106
139
|
end
|
|
140
|
+
@errors[:title] &&= result.empty?
|
|
141
|
+
result
|
|
107
142
|
end
|
|
108
143
|
|
|
109
144
|
def status
|
|
110
|
-
|
|
111
|
-
|
|
145
|
+
result = begin
|
|
146
|
+
stage = Bib::Status::Stage.new content: @pub["status"]
|
|
147
|
+
Bib::Status.new stage: stage
|
|
148
|
+
end
|
|
149
|
+
@errors[:status] &&= result.nil?
|
|
150
|
+
result
|
|
112
151
|
end
|
|
113
152
|
|
|
114
153
|
def edition
|
|
115
|
-
Bib::Edition.new content: @pub["edition"]
|
|
154
|
+
result = Bib::Edition.new content: @pub["edition"]
|
|
155
|
+
@errors[:edition] &&= result.nil?
|
|
156
|
+
result
|
|
116
157
|
end
|
|
117
158
|
|
|
118
159
|
#
|
|
@@ -121,11 +162,13 @@ module Relaton
|
|
|
121
162
|
# @return [Array<Relaton::Bib::LocalizedMarkedUpString>] abstract
|
|
122
163
|
#
|
|
123
164
|
def abstract
|
|
124
|
-
@pub["abstract"]
|
|
125
|
-
Bib::
|
|
165
|
+
result = Array(@pub["abstract"]).map do |a|
|
|
166
|
+
Bib::Abstract.new(
|
|
126
167
|
content: a["content"], language: a["lang"], script: lang_to_script(a["lang"]),
|
|
127
168
|
)
|
|
128
169
|
end
|
|
170
|
+
@errors[:abstract] &&= result.empty?
|
|
171
|
+
result
|
|
129
172
|
end
|
|
130
173
|
|
|
131
174
|
# @return [Array<Relaton::Bib::Copyright>] copyright
|
|
@@ -143,7 +186,9 @@ module Relaton
|
|
|
143
186
|
org = Bib::Organization.new(name: [orgname], abbreviation: abbrev, uri: [uri])
|
|
144
187
|
Bib::ContributionInfo.new(organization: org)
|
|
145
188
|
end
|
|
146
|
-
[Bib::Copyright.new(owner: owner, from: from)]
|
|
189
|
+
result = [Bib::Copyright.new(owner: owner, from: from)]
|
|
190
|
+
@errors[:copyright] &&= result.empty?
|
|
191
|
+
result
|
|
147
192
|
end
|
|
148
193
|
|
|
149
194
|
#
|
|
@@ -152,7 +197,7 @@ module Relaton
|
|
|
152
197
|
# @return [Array<Relaton::Bib::Date>] dates
|
|
153
198
|
#
|
|
154
199
|
def date
|
|
155
|
-
{
|
|
200
|
+
result = {
|
|
156
201
|
"published" => "publicationDate",
|
|
157
202
|
"stable-until" => "stabilityDate",
|
|
158
203
|
"confirmed" => "confirmationDate",
|
|
@@ -162,6 +207,8 @@ module Relaton
|
|
|
162
207
|
|
|
163
208
|
a << Bib::Date.new(type: k, at: @pub[v])
|
|
164
209
|
end
|
|
210
|
+
@errors[:date] &&= result.empty?
|
|
211
|
+
result
|
|
165
212
|
end
|
|
166
213
|
|
|
167
214
|
#
|
|
@@ -179,7 +226,9 @@ module Relaton
|
|
|
179
226
|
role = Bib::Contributor::Role.new(type: "publisher")
|
|
180
227
|
Bib::Contributor.new(organization: org, role: [role])
|
|
181
228
|
end
|
|
182
|
-
contribs + editorialgroup_contributors
|
|
229
|
+
result = contribs + editorialgroup_contributors
|
|
230
|
+
@errors[:contributor] &&= result.empty?
|
|
231
|
+
result
|
|
183
232
|
end
|
|
184
233
|
|
|
185
234
|
#
|
|
@@ -216,12 +265,14 @@ module Relaton
|
|
|
216
265
|
def source
|
|
217
266
|
url = "#{DOMAIN}/publication/#{urn_id}"
|
|
218
267
|
l = [Bib::Uri.new(content: url, type: "src")]
|
|
219
|
-
array(@pub["releaseItems"]).each_with_object(l) do |r, a|
|
|
268
|
+
result = array(@pub["releaseItems"]).each_with_object(l) do |r, a|
|
|
220
269
|
next unless r["type"] == "PREVIEW"
|
|
221
270
|
|
|
222
271
|
url = "#{DOMAIN}/preview/#{r['contentRef']['fileName']}"
|
|
223
272
|
a << Bib::Uri.new(content: url, type: "obp")
|
|
224
273
|
end
|
|
274
|
+
@errors[:source] &&= result.empty?
|
|
275
|
+
result
|
|
225
276
|
end
|
|
226
277
|
|
|
227
278
|
#
|
|
@@ -240,7 +291,7 @@ module Relaton
|
|
|
240
291
|
#
|
|
241
292
|
def relation # rubocop:disable Metrics/MethodLength
|
|
242
293
|
try = 0
|
|
243
|
-
begin
|
|
294
|
+
result = begin
|
|
244
295
|
uri = URI "#{DOMAIN}/webstore/webstore.nsf/AjaxRequestXML?Openagent&url=#{urn_id}"
|
|
245
296
|
resp = Net::HTTP.get_response uri
|
|
246
297
|
doc = Nokogiri::XML resp.body
|
|
@@ -249,6 +300,8 @@ module Relaton
|
|
|
249
300
|
try += 1
|
|
250
301
|
try < 3 ? retry : raise(e)
|
|
251
302
|
end
|
|
303
|
+
@errors[:relation] &&= result.empty?
|
|
304
|
+
result
|
|
252
305
|
end
|
|
253
306
|
|
|
254
307
|
#
|
|
@@ -269,7 +322,7 @@ module Relaton
|
|
|
269
322
|
end
|
|
270
323
|
ref = r.at("FULL_NAME").text
|
|
271
324
|
docid = Docidentifier.new(content: ref, type: "IEC", primary: true)
|
|
272
|
-
bibitem = ItemData.new(formattedref: ref, docidentifier: [docid])
|
|
325
|
+
bibitem = ItemData.new(formattedref: Bib::Formattedref.new(content: ref), docidentifier: [docid])
|
|
273
326
|
Relation.new type: type, bibitem: bibitem
|
|
274
327
|
end
|
|
275
328
|
end
|
|
@@ -279,13 +332,15 @@ module Relaton
|
|
|
279
332
|
end
|
|
280
333
|
|
|
281
334
|
def ext
|
|
282
|
-
Ext.new(
|
|
335
|
+
result = Ext.new(
|
|
283
336
|
doctype: doctype,
|
|
284
337
|
structuredidentifier: structuredidentifier,
|
|
285
338
|
flavor: "iec",
|
|
286
339
|
ics: ics,
|
|
287
|
-
price_code: @pub
|
|
340
|
+
price_code: @pub.dig("priceInfo", "priceCode"),
|
|
288
341
|
)
|
|
342
|
+
@errors[:ext] &&= result.nil?
|
|
343
|
+
result
|
|
289
344
|
end
|
|
290
345
|
|
|
291
346
|
#
|
|
@@ -297,8 +352,12 @@ module Relaton
|
|
|
297
352
|
urn = @pub.dig("project", "urn")
|
|
298
353
|
return unless urn
|
|
299
354
|
|
|
300
|
-
|
|
301
|
-
|
|
355
|
+
result = begin
|
|
356
|
+
pnum = Iso::ProjectNumber.new(content: urn.split(":").last)
|
|
357
|
+
Iso::StructuredIdentifier.new(project_number: pnum, type: "IEC")
|
|
358
|
+
end
|
|
359
|
+
@errors[:structuredidentifier] &&= result.nil?
|
|
360
|
+
result
|
|
302
361
|
end
|
|
303
362
|
|
|
304
363
|
#
|
|
@@ -308,7 +367,9 @@ module Relaton
|
|
|
308
367
|
#
|
|
309
368
|
def doctype
|
|
310
369
|
type = DOCTYPES[@pub["stdType"]] || @pub["stdType"].downcase
|
|
311
|
-
Doctype.new content: type
|
|
370
|
+
result = Doctype.new content: type
|
|
371
|
+
@errors[:doctype] &&= result.nil?
|
|
372
|
+
result
|
|
312
373
|
end
|
|
313
374
|
|
|
314
375
|
#
|
|
@@ -319,9 +380,11 @@ module Relaton
|
|
|
319
380
|
def ics
|
|
320
381
|
return [] unless @pub["classifications"]
|
|
321
382
|
|
|
322
|
-
@pub["classifications"].select { |c| c["type"] == "ICS" }.map do |c|
|
|
383
|
+
result = @pub["classifications"].select { |c| c["type"] == "ICS" }.map do |c|
|
|
323
384
|
Bib::ICS.new(code: c["value"])
|
|
324
385
|
end
|
|
386
|
+
@errors[:ics] &&= result.empty?
|
|
387
|
+
result
|
|
325
388
|
end
|
|
326
389
|
end
|
|
327
390
|
end
|
|
@@ -29,7 +29,7 @@ module Relaton
|
|
|
29
29
|
parts.reject { |h| h.hit[:id] == hit.hit[:id] }.each do |hi|
|
|
30
30
|
code = hi.hit[:id].to_s
|
|
31
31
|
bib = ItemData.new(
|
|
32
|
-
formattedref: code,
|
|
32
|
+
formattedref: Bib::Formattedref.new(content: code),
|
|
33
33
|
docidentifier: [Docidentifier.new(content: code, type: "IEC", primary: true)],
|
|
34
34
|
)
|
|
35
35
|
all_parts_item.relation << Relation.new(type: "partOf", bibitem: bib)
|
|
@@ -49,7 +49,7 @@ module Relaton
|
|
|
49
49
|
url: "#{Hit::GHURL}#{INDEXFILE}.zip",
|
|
50
50
|
file: "#{INDEXFILE}.yaml",
|
|
51
51
|
id_keys: VALID_ID_KEYS,
|
|
52
|
-
pubid_class: Pubid::Iec::Identifier
|
|
52
|
+
pubid_class: ::Pubid::Iec::Identifier
|
|
53
53
|
)
|
|
54
54
|
end
|
|
55
55
|
|
|
@@ -1,40 +1,75 @@
|
|
|
1
1
|
module Relaton
|
|
2
2
|
module Iec
|
|
3
|
-
class
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
self.content = content.sub(/:\d{4}(?=\s|$)/, "")
|
|
3
|
+
class Pubid < Lutaml::Model::Type::Value
|
|
4
|
+
class << self
|
|
5
|
+
def cast(value)
|
|
6
|
+
value.is_a?(String) ? ::Pubid::Iec::Identifier.parse(value) : value
|
|
7
|
+
rescue StandardError
|
|
8
|
+
Util.warn "Failed to parse Pubid: #{value}"
|
|
9
|
+
value
|
|
11
10
|
end
|
|
12
11
|
end
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# URN format: urn:iec:std:iec:60050-102:2007:::
|
|
17
|
-
# Remove the part number(s) from the document number segment (4th segment)
|
|
18
|
-
self.content = content.sub(/^(urn:iec:std:[^:]+:[^:-]+)-\d+(?:-\d+)*/, '\1')
|
|
19
|
-
else
|
|
20
|
-
self.content = content.sub(/-\d+(?:-\d+)*/, "")
|
|
21
|
-
end
|
|
13
|
+
::Lutaml::Model::Config::AVAILABLE_FORMATS.each do |format|
|
|
14
|
+
define_method(:"to_#{format}") { value.to_s }
|
|
22
15
|
end
|
|
23
16
|
|
|
24
|
-
def
|
|
25
|
-
|
|
17
|
+
def to_h = value.to_h
|
|
18
|
+
def urn = value.urn
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class Docidentifier < Bib::Docidentifier
|
|
22
|
+
attribute :content, Pubid
|
|
23
|
+
|
|
24
|
+
def content_to_xml(model, parent, doc)
|
|
25
|
+
doc.add_xml_fragment parent, model.to_s
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def content_to_key_value(model, doc)
|
|
29
|
+
doc["content"] = model.to_s
|
|
26
30
|
end
|
|
27
31
|
|
|
28
32
|
def to_all_parts!
|
|
33
|
+
if content.is_a? String
|
|
34
|
+
Util.warn "Cannot convert String to all parts: #{content}"
|
|
35
|
+
return
|
|
36
|
+
end
|
|
37
|
+
|
|
29
38
|
remove_part!
|
|
30
39
|
remove_date!
|
|
31
40
|
remove_stage!
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
content.all_parts = true if content.respond_to?(:all_parts=)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def remove_stage!
|
|
45
|
+
remove_attr! :stage
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def remove_part!
|
|
49
|
+
remove_attr! :part
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def remove_date!
|
|
53
|
+
remove_attr! :year
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def to_s
|
|
57
|
+
return content if content.is_a? String
|
|
58
|
+
|
|
59
|
+
case type
|
|
60
|
+
when "URN" then content.urn
|
|
61
|
+
else content.to_s
|
|
36
62
|
end
|
|
37
63
|
end
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
|
|
67
|
+
def remove_attr!(attr)
|
|
68
|
+
return false if content.is_a? String
|
|
69
|
+
|
|
70
|
+
content.send(:"#{attr}=", nil)
|
|
71
|
+
true
|
|
72
|
+
end
|
|
38
73
|
end
|
|
39
74
|
end
|
|
40
75
|
end
|
data/lib/relaton/iec/version.rb
CHANGED
data/relaton_iec.gemspec
CHANGED
|
@@ -25,9 +25,9 @@ Gem::Specification.new do |spec|
|
|
|
25
25
|
|
|
26
26
|
spec.add_dependency "addressable"
|
|
27
27
|
spec.add_dependency "base64"
|
|
28
|
-
spec.add_dependency "pubid-iec", "~> 1.15.
|
|
29
|
-
spec.add_dependency "relaton-core", "~> 0.0.
|
|
28
|
+
spec.add_dependency "pubid-iec", "~> 1.15.11"
|
|
29
|
+
spec.add_dependency "relaton-core", "~> 0.0.13"
|
|
30
30
|
spec.add_dependency "relaton-index", "~> 0.2.20"
|
|
31
|
-
spec.add_dependency "relaton-iso", "~> 2.0.0-alpha.
|
|
31
|
+
spec.add_dependency "relaton-iso", "~> 2.0.0-alpha.7"
|
|
32
32
|
spec.add_dependency "rubyzip"
|
|
33
33
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: relaton-iec
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.0.pre.alpha.
|
|
4
|
+
version: 2.0.0.pre.alpha.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -43,28 +43,28 @@ dependencies:
|
|
|
43
43
|
requirements:
|
|
44
44
|
- - "~>"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 1.15.
|
|
46
|
+
version: 1.15.11
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - "~>"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: 1.15.
|
|
53
|
+
version: 1.15.11
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: relaton-core
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
|
58
58
|
- - "~>"
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: 0.0.
|
|
60
|
+
version: 0.0.13
|
|
61
61
|
type: :runtime
|
|
62
62
|
prerelease: false
|
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - "~>"
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: 0.0.
|
|
67
|
+
version: 0.0.13
|
|
68
68
|
- !ruby/object:Gem::Dependency
|
|
69
69
|
name: relaton-index
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -85,14 +85,14 @@ dependencies:
|
|
|
85
85
|
requirements:
|
|
86
86
|
- - "~>"
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: 2.0.0.pre.alpha.
|
|
88
|
+
version: 2.0.0.pre.alpha.7
|
|
89
89
|
type: :runtime
|
|
90
90
|
prerelease: false
|
|
91
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
92
92
|
requirements:
|
|
93
93
|
- - "~>"
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: 2.0.0.pre.alpha.
|
|
95
|
+
version: 2.0.0.pre.alpha.7
|
|
96
96
|
- !ruby/object:Gem::Dependency
|
|
97
97
|
name: rubyzip
|
|
98
98
|
requirement: !ruby/object:Gem::Requirement
|