relaton-iso 1.13.3 → 1.13.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/relaton_iso/document_identifier.rb +1 -1
- data/lib/relaton_iso/iso_bibliography.rb +110 -39
- data/lib/relaton_iso/version.rb +1 -1
- data/relaton_iso.gemspec +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de7fd665ac31a6cb5ca7af1d56225ac315953981d93b4bb05dc68e19834e5986
|
4
|
+
data.tar.gz: a0ebeaf6c6455e4222cc9127eec9ab9eef75e3a1439f2dde392c7bda2c75c116
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 669b535e77c8ac8f0dcb488245d75a46820ec0bb68695212aa669c6eb18acb6a567f9f62c9cec28be7c04fde7a9518aafecb4cb564f4e2fc6a2975af89dd5bce
|
7
|
+
data.tar.gz: '019288a0aa8acb5ff2b2a5b6b4b4b485f1c9b9a0e703670f8c4a6005fb61ce944123d80ecd1caebe327d7cbe32ced2022e98f1a5e63267f75393874949119cd9'
|
@@ -40,6 +40,15 @@ module RelatonIso
|
|
40
40
|
|
41
41
|
resp = isobib_search_filter(query_pubid, opts)
|
42
42
|
|
43
|
+
# Try with ISO/IEC prefix if ISO not found
|
44
|
+
if resp[:hits].empty? &&
|
45
|
+
query_pubid.copublisher.nil? &&
|
46
|
+
query_pubid.publisher == "ISO"
|
47
|
+
|
48
|
+
resp_isoiec = retry_isoiec_prefix(query_pubid, opts)
|
49
|
+
resp = resp_isoiec unless resp_isoiec.nil?
|
50
|
+
end
|
51
|
+
|
43
52
|
# return only first one if not all_parts
|
44
53
|
ret = if !opts[:all_parts] || resp[:hits].size == 1
|
45
54
|
resp[:hits].any? && resp[:hits].first.fetch(opts[:lang])
|
@@ -47,17 +56,37 @@ module RelatonIso
|
|
47
56
|
resp[:hits].to_all_parts(opts[:lang])
|
48
57
|
end
|
49
58
|
|
50
|
-
|
51
|
-
warn "[relaton-iso] (\"#{query_pubid}\") found #{ret.docidentifier.first.id}"
|
52
|
-
else
|
53
|
-
return fetch_ref_err(query_pubid)
|
54
|
-
end
|
59
|
+
return fetch_ref_err(query_pubid) unless ret
|
55
60
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
61
|
+
# puts "xxxxx #{ret.docidentifier.first.id.inspect}"
|
62
|
+
response_docid = ret.docidentifier.first.id.sub(" (all parts)", "")
|
63
|
+
response_pubid = Pubid::Iso::Identifier.parse(response_docid)
|
64
|
+
|
65
|
+
puts "xxxxx query_pubid(#{query_pubid}) response_pubid(#{response_pubid})"
|
66
|
+
|
67
|
+
if query_pubid.to_s == response_pubid.to_s
|
68
|
+
warn "[relaton-iso] (\"#{query_pubid}\") Found exact match."
|
69
|
+
elsif matches_base?(query_pubid, response_pubid)
|
70
|
+
warn "[relaton-iso] (\"#{query_pubid}\") " \
|
71
|
+
"Found (\"#{response_pubid}\")."
|
72
|
+
elsif matches_base?(query_pubid, response_pubid, any_types_stages: true)
|
73
|
+
warn "[relaton-iso] (\"#{query_pubid}\") TIP: " \
|
74
|
+
"Found with different type/stage, " \
|
75
|
+
"please amend to (\"#{response_pubid}\")."
|
76
|
+
else
|
77
|
+
# when there are all parts
|
78
|
+
warn "[relaton-iso] (\"#{query_pubid}\") Found (\"#{response_pubid}\")."
|
60
79
|
end
|
80
|
+
|
81
|
+
get_all = (
|
82
|
+
(query_pubid.year && opts[:keep_year].nil?) ||
|
83
|
+
opts[:keep_year] ||
|
84
|
+
opts[:all_parts]
|
85
|
+
)
|
86
|
+
return ret if get_all
|
87
|
+
|
88
|
+
ret.to_most_recent_reference
|
89
|
+
|
61
90
|
rescue Pubid::Core::Errors::ParseError
|
62
91
|
warn "[relaton-iso] (\"#{code}\") is not recognized as a standards identifier."
|
63
92
|
end
|
@@ -67,12 +96,10 @@ module RelatonIso
|
|
67
96
|
# @param all_parts [Boolean] match with any parts when true
|
68
97
|
# @return [Boolean]
|
69
98
|
def matches_parts?(query_pubid, pubid, all_parts: false)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
query_pubid.part == pubid.part
|
75
|
-
end
|
99
|
+
# match only with documents with part number
|
100
|
+
return !pubid.part.nil? if all_parts
|
101
|
+
|
102
|
+
query_pubid.part == pubid.part
|
76
103
|
end
|
77
104
|
|
78
105
|
def matches_base?(query_pubid, pubid, any_types_stages: false) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics?PerceivedComplexity
|
@@ -111,22 +138,68 @@ module RelatonIso
|
|
111
138
|
|
112
139
|
private
|
113
140
|
|
141
|
+
# @param query_pubid [Pubid::Iso::Identifier] PubID with no results
|
114
142
|
def fetch_ref_err(query_pubid) # rubocop:disable Metrics/MethodLength
|
115
|
-
warn "[relaton-iso]
|
116
|
-
"
|
117
|
-
|
118
|
-
|
119
|
-
|
143
|
+
warn "[relaton-iso] (\"#{query_pubid}\") " \
|
144
|
+
"Not found. " \
|
145
|
+
"The identifier must be exactly as shown on the ISO website."
|
146
|
+
|
147
|
+
if query_pubid.part
|
148
|
+
warn "[relaton-iso] (\"#{query_pubid}\") TIP: " \
|
149
|
+
"If it cannot be found, the document may no longer be published in parts."
|
120
150
|
else
|
121
|
-
warn "[relaton-iso]
|
122
|
-
"the reference,
|
123
|
-
|
124
|
-
|
151
|
+
warn "[relaton-iso] (\"#{query_pubid}\") TIP: " \
|
152
|
+
"If you wish to cite all document parts for the reference, " \
|
153
|
+
"use (\"#{query_pubid.to_s(with_date: false)} (all parts)\")."
|
154
|
+
end
|
155
|
+
|
156
|
+
unless %w(TS TR PAS Guide).include?(query_pubid.type)
|
157
|
+
warn "[relaton-iso] (\"#{query_pubid}\") TIP: " \
|
158
|
+
"If the document is not an International Standard, use its " \
|
159
|
+
"deliverable type abbreviation (TS, TR, PAS, Guide)."
|
125
160
|
end
|
161
|
+
|
126
162
|
nil
|
127
163
|
end
|
128
164
|
|
129
|
-
#
|
165
|
+
# @param pubid [Pubid::Iso::Identifier]
|
166
|
+
# @param missed_years [Array<String>]
|
167
|
+
def warn_missing_years(pubid, missed_years)
|
168
|
+
warn "[relaton-iso] (\"#{pubid}\") TIP: " \
|
169
|
+
"No match for edition year #{pubid.year}, " \
|
170
|
+
"but matches exist for #{missed_years.uniq.join(', ')}."
|
171
|
+
end
|
172
|
+
|
173
|
+
# Search for hits using ISO/IEC prefix.
|
174
|
+
#
|
175
|
+
# @param old_pubid [Pubid::Iso::Identifier] reference with ISO prefix
|
176
|
+
# @param opts [Hash]
|
177
|
+
# @return [Array<RelatonIso::Hit>]
|
178
|
+
def retry_isoiec_prefix(old_pubid, opts)
|
179
|
+
return nil unless (
|
180
|
+
old_pubid.copublisher.nil? &&
|
181
|
+
old_pubid.publisher == "ISO"
|
182
|
+
)
|
183
|
+
|
184
|
+
pubid = old_pubid.dup
|
185
|
+
pubid.copublisher = "IEC"
|
186
|
+
warn "[relaton-iso] (\"#{old_pubid}\") Not found, " \
|
187
|
+
"trying with ISO/IEC prefix (\"#{pubid}\")..."
|
188
|
+
resp_isoiec = isobib_search_filter(pubid, opts)
|
189
|
+
|
190
|
+
if resp_isoiec[:hits].empty?
|
191
|
+
warn "[relaton-iso] (\"#{pubid}\") Not found. "
|
192
|
+
return nil
|
193
|
+
end
|
194
|
+
|
195
|
+
warn "[relaton-iso] (\"#{pubid}\") TIP: " \
|
196
|
+
"Found with ISO/IEC prefix, " \
|
197
|
+
"please amend to (\"#{pubid}\")."
|
198
|
+
|
199
|
+
resp_isoiec
|
200
|
+
end
|
201
|
+
|
202
|
+
# Search for hits. If no found then trying missed stages.
|
130
203
|
#
|
131
204
|
# @param query_pubid [Pubid::Iso::Identifier] reference without correction
|
132
205
|
# @param opts [Hash]
|
@@ -134,32 +207,29 @@ module RelatonIso
|
|
134
207
|
def isobib_search_filter(query_pubid, opts) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
135
208
|
missed_years = []
|
136
209
|
query_pubid.part = nil if opts[:all_parts]
|
137
|
-
warn "[relaton-iso] (\"#{query_pubid}\")
|
210
|
+
warn "[relaton-iso] (\"#{query_pubid}\") Fetching from ISO..."
|
211
|
+
|
138
212
|
# fetch hits collection
|
139
|
-
|
213
|
+
query_pubid_without_year = query_pubid.dup
|
214
|
+
# remove year for query
|
215
|
+
query_pubid_without_year.year = nil
|
216
|
+
hit_collection = search(query_pubid_without_year.to_s(with_date: false))
|
217
|
+
|
140
218
|
# filter only matching hits
|
141
219
|
res = filter_hits hit_collection, query_pubid, all_parts: opts[:all_parts]
|
142
220
|
return res unless res[:hits].empty?
|
143
|
-
|
144
221
|
missed_years += res[:missed_years]
|
222
|
+
|
145
223
|
# lookup for documents with stages when no match without stage
|
146
224
|
res = filter_hits hit_collection, query_pubid,
|
147
225
|
all_parts: opts[:all_parts], any_types_stages: true
|
148
226
|
return res unless res[:hits].empty?
|
149
|
-
|
150
227
|
missed_years += res[:missed_years]
|
151
|
-
# TODO: do this at pubid-iso
|
152
|
-
if query_pubid.publisher == "ISO" && query_pubid.copublisher.nil? # try ISO/IEC if ISO not found
|
153
|
-
warn "[relaton-iso] Attempting ISO/IEC retrieval"
|
154
|
-
query_pubid.copublisher = "IEC"
|
155
|
-
res = filter_hits hit_collection, query_pubid, all_parts: opts[:all_parts]
|
156
|
-
missed_years += res[:missed_years]
|
157
|
-
end
|
158
228
|
|
159
|
-
if
|
160
|
-
|
161
|
-
"were matches found for #{missed_years.uniq.join(', ')}.)"
|
229
|
+
if missed_years.any?
|
230
|
+
warn_missing_years(query_pubid, missed_years)
|
162
231
|
end
|
232
|
+
|
163
233
|
res
|
164
234
|
end
|
165
235
|
|
@@ -180,6 +250,7 @@ module RelatonIso
|
|
180
250
|
|
181
251
|
filter_hits_by_year(result, query_pubid.year)
|
182
252
|
end
|
253
|
+
|
183
254
|
end
|
184
255
|
end
|
185
256
|
end
|
data/lib/relaton_iso/version.rb
CHANGED
data/relaton_iso.gemspec
CHANGED
@@ -39,6 +39,6 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.add_development_dependency "webmock"
|
40
40
|
|
41
41
|
spec.add_dependency "algolia"
|
42
|
-
spec.add_dependency "pubid-iso", "0.
|
42
|
+
spec.add_dependency "pubid-iso", "~> 0.2.0"
|
43
43
|
spec.add_dependency "relaton-iso-bib", "~> 1.13.0"
|
44
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-iso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.13.
|
4
|
+
version: 1.13.4
|
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: 2022-
|
11
|
+
date: 2022-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -182,16 +182,16 @@ dependencies:
|
|
182
182
|
name: pubid-iso
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- -
|
185
|
+
- - "~>"
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version: 0.
|
187
|
+
version: 0.2.0
|
188
188
|
type: :runtime
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- -
|
192
|
+
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version: 0.
|
194
|
+
version: 0.2.0
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: relaton-iso-bib
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -259,7 +259,7 @@ homepage: https://github.com/relaton/relaton-iso
|
|
259
259
|
licenses:
|
260
260
|
- BSD-2-Clause
|
261
261
|
metadata: {}
|
262
|
-
post_install_message:
|
262
|
+
post_install_message:
|
263
263
|
rdoc_options: []
|
264
264
|
require_paths:
|
265
265
|
- lib
|
@@ -274,8 +274,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
274
274
|
- !ruby/object:Gem::Version
|
275
275
|
version: '0'
|
276
276
|
requirements: []
|
277
|
-
rubygems_version: 3.
|
278
|
-
signing_key:
|
277
|
+
rubygems_version: 3.1.6
|
278
|
+
signing_key:
|
279
279
|
specification_version: 4
|
280
280
|
summary: 'RelatonIso: retrieve ISO Standards for bibliographic use using the IsoBibliographicItem
|
281
281
|
model'
|