relaton-iso 1.12.3 → 1.12.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/lib/relaton_iso/iso_bibliography.rb +28 -24
- data/lib/relaton_iso/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c89e5819f5ee242c8ff64f7d961a18f38af1b8652b8645fc41562b95fd8bd55d
|
4
|
+
data.tar.gz: 777ef30bd94bf5a782edc673d58377dc9c52a1a85a203d684d844a0784bafc64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83a023461e1f6c98748a23bae33e9aaa8c745e397ac7adbc741060b6e370a94ca5a6055193e0c1abe6a259a4eff3693a2d1b8de27331152695329a83821b9ef2
|
7
|
+
data.tar.gz: e58c71d35a9b23fd34a62c24b273eb104b7a577b6cf37315af3d46ef5dd1d1deb6a41c5f95fe543838f9a6dd9f2ebd30d3501ffd773647a8f98cf6ab2684056f
|
@@ -38,19 +38,19 @@ module RelatonIso
|
|
38
38
|
query_pubid = Pubid::Iso::Identifier.parse(code)
|
39
39
|
query_pubid.year = year if year
|
40
40
|
|
41
|
-
|
41
|
+
resp = isobib_search_filter(query_pubid, opts)
|
42
42
|
|
43
43
|
# return only first one if not all_parts
|
44
|
-
ret = if !opts[:all_parts] || hits.size == 1
|
45
|
-
hits.any? && hits.first.fetch(opts[:lang])
|
44
|
+
ret = if !opts[:all_parts] || resp[:hits].size == 1
|
45
|
+
resp[:hits].any? && resp[:hits].first.fetch(opts[:lang])
|
46
46
|
else
|
47
|
-
hits.to_all_parts(opts[:lang])
|
47
|
+
resp[:hits].to_all_parts(opts[:lang])
|
48
48
|
end
|
49
49
|
|
50
50
|
if ret
|
51
51
|
warn "[relaton-iso] (\"#{query_pubid}\") found #{ret.docidentifier.first.id}"
|
52
52
|
else
|
53
|
-
return fetch_ref_err(query_pubid
|
53
|
+
return fetch_ref_err(query_pubid)
|
54
54
|
end
|
55
55
|
|
56
56
|
if (query_pubid.year && opts[:keep_year].nil?) || opts[:keep_year] || opts[:all_parts]
|
@@ -86,6 +86,7 @@ module RelatonIso
|
|
86
86
|
# @return [RelatonIso::HitCollection]
|
87
87
|
def filter_hits_by_year(hit_collection, year) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
88
88
|
missed_years = []
|
89
|
+
return { hits: hit_collection, missed_years: missed_years } if year.nil?
|
89
90
|
|
90
91
|
# filter by year
|
91
92
|
hits = hit_collection.select do |hit|
|
@@ -103,27 +104,22 @@ module RelatonIso
|
|
103
104
|
end
|
104
105
|
end
|
105
106
|
|
106
|
-
|
107
|
-
warn "[relaton-iso] (There was no match for #{year}, though there "\
|
108
|
-
"were matches found for #{missed_years.join(', ')}.)"
|
109
|
-
end
|
110
|
-
hits
|
107
|
+
{ hits: hits, missed_years: missed_years }
|
111
108
|
end
|
112
109
|
|
113
110
|
private
|
114
111
|
|
115
|
-
def fetch_ref_err(query_pubid
|
116
|
-
|
117
|
-
warn "[relaton-iso] WARNING: no match found online for #{id}. "\
|
112
|
+
def fetch_ref_err(query_pubid) # rubocop:disable Metrics/MethodLength
|
113
|
+
warn "[relaton-iso] WARNING: no match found online for #{query_pubid}. " \
|
118
114
|
"The code must be exactly like it is on the standards website."
|
119
115
|
if /\d-\d/.match? query_pubid.to_s
|
120
|
-
warn "[relaton-iso] The provided document part may not exist, "\
|
116
|
+
warn "[relaton-iso] The provided document part may not exist, " \
|
121
117
|
"or the document may no longer be published in parts."
|
122
118
|
else
|
123
|
-
warn "[relaton-iso] If you wanted to cite all document parts for "\
|
124
|
-
"the reference, use \"#{query_pubid} (all parts)\"
|
125
|
-
|
126
|
-
"(TS, TR, PAS, Guide)."
|
119
|
+
warn "[relaton-iso] If you wanted to cite all document parts for " \
|
120
|
+
"the reference, use \"#{query_pubid} (all parts)\"."
|
121
|
+
warn "[relaton-iso] If the document is not a standard, use its " \
|
122
|
+
"document type abbreviation (TS, TR, PAS, Guide)."
|
127
123
|
end
|
128
124
|
nil
|
129
125
|
end
|
@@ -133,26 +129,34 @@ module RelatonIso
|
|
133
129
|
# @param query_pubid [Pubid::Iso::Identifier] reference without correction
|
134
130
|
# @param opts [Hash]
|
135
131
|
# @return [Array<RelatonIso::Hit>]
|
136
|
-
def isobib_search_filter(query_pubid, opts) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
132
|
+
def isobib_search_filter(query_pubid, opts) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
133
|
+
missed_years = []
|
137
134
|
query_pubid.part = nil if opts[:all_parts]
|
138
135
|
warn "[relaton-iso] (\"#{query_pubid}\") fetching..."
|
139
136
|
# fetch hits collection
|
140
137
|
hit_collection = search(query_pubid.to_s(with_date: false))
|
141
138
|
# filter only matching hits
|
142
|
-
res = filter_hits hit_collection, query_pubid,
|
143
|
-
|
144
|
-
return res unless res.empty?
|
139
|
+
res = filter_hits hit_collection, query_pubid, all_parts: opts[:all_parts]
|
140
|
+
return res unless res[:hits].empty?
|
145
141
|
|
142
|
+
missed_years += res[:missed_years]
|
146
143
|
# lookup for documents with stages when no match without stage
|
147
144
|
res = filter_hits hit_collection, query_pubid,
|
148
145
|
all_parts: opts[:all_parts], any_types_stages: true
|
149
|
-
return res unless res.empty?
|
146
|
+
return res unless res[:hits].empty?
|
150
147
|
|
148
|
+
missed_years += res[:missed_years]
|
151
149
|
# TODO: do this at pubid-iso
|
152
150
|
if query_pubid.publisher == "ISO" && query_pubid.copublisher.nil? # try ISO/IEC if ISO not found
|
153
151
|
warn "[relaton-iso] Attempting ISO/IEC retrieval"
|
154
152
|
query_pubid.copublisher = "IEC"
|
155
153
|
res = filter_hits hit_collection, query_pubid, all_parts: opts[:all_parts]
|
154
|
+
missed_years += res[:missed_years]
|
155
|
+
end
|
156
|
+
|
157
|
+
if res[:hits].empty? && missed_years.any?
|
158
|
+
warn "[relaton-iso] (There was no match for #{query_pubid.year}, though there "\
|
159
|
+
"were matches found for #{missed_years.uniq.join(', ')}.)"
|
156
160
|
end
|
157
161
|
res
|
158
162
|
end
|
@@ -172,7 +176,7 @@ module RelatonIso
|
|
172
176
|
query_pubid.amendments == hit_pubid.amendments
|
173
177
|
end
|
174
178
|
|
175
|
-
|
179
|
+
filter_hits_by_year(result, query_pubid.year)
|
176
180
|
end
|
177
181
|
end
|
178
182
|
end
|
data/lib/relaton_iso/version.rb
CHANGED
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.12.
|
4
|
+
version: 1.12.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: 2022-07
|
11
|
+
date: 2022-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|