relaton-iso 1.12.1 → 1.12.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/hit_collection.rb +3 -3
- data/lib/relaton_iso/iso_bibliography.rb +30 -26
- data/lib/relaton_iso/version.rb +1 -1
- data/relaton_iso.gemspec +1 -4
- metadata +8 -8
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
|
@@ -11,15 +11,15 @@ module RelatonIso
|
|
11
11
|
# @param text [String] reference to search
|
12
12
|
def initialize(text)
|
13
13
|
super
|
14
|
-
@array = text.match?(/^ISO\s(?:TC\s184\/SC\s?4|IEC\sDIR\s(?:\d|IEC|JTC))/) ? fetch_github : fetch_iso
|
14
|
+
@array = text.match?(/^ISO[\s\/](?:TC\s184\/SC\s?4|IEC\sDIR\s(?:\d|IEC|JTC))/) ? fetch_github : fetch_iso
|
15
15
|
end
|
16
16
|
|
17
17
|
# @param lang [String, NilClass]
|
18
|
-
# @return [RelatonIsoBib::IsoBibliographicItem]
|
18
|
+
# @return [RelatonIsoBib::IsoBibliographicItem, nil]
|
19
19
|
def to_all_parts(lang = nil) # rubocop:disable Metrics/CyclomaticComplexity
|
20
20
|
# parts = @array.reject { |h| h.hit["docPart"]&.empty? }
|
21
21
|
hit = @array.min_by { |h| h.pubid.part }
|
22
|
-
return @array.first
|
22
|
+
return @array.first&.fetch lang unless hit
|
23
23
|
|
24
24
|
bibitem = hit.fetch(lang)
|
25
25
|
all_parts_item = bibitem.to_all_parts
|
@@ -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
|
@@ -168,11 +172,11 @@ module RelatonIso
|
|
168
172
|
hit_pubid = i.pubid
|
169
173
|
matches_base?(query_pubid, hit_pubid, any_types_stages: any_types_stages) &&
|
170
174
|
matches_parts?(query_pubid, hit_pubid, all_parts: all_parts) &&
|
171
|
-
query_pubid.
|
172
|
-
query_pubid.
|
175
|
+
query_pubid.corrigendums == hit_pubid.corrigendums &&
|
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
data/relaton_iso.gemspec
CHANGED
@@ -27,7 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
28
28
|
|
29
29
|
spec.add_development_dependency "byebug"
|
30
|
-
# spec.add_development_dependency "debase"
|
31
30
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
32
31
|
spec.add_development_dependency "pry-byebug"
|
33
32
|
spec.add_development_dependency "rake", "~> 13.0"
|
@@ -35,13 +34,11 @@ Gem::Specification.new do |spec|
|
|
35
34
|
spec.add_development_dependency "rubocop"
|
36
35
|
spec.add_development_dependency "rubocop-performance"
|
37
36
|
spec.add_development_dependency "rubocop-rails"
|
38
|
-
# spec.add_development_dependency "ruby-debug-ide"
|
39
37
|
spec.add_development_dependency "simplecov"
|
40
38
|
spec.add_development_dependency "vcr"
|
41
39
|
spec.add_development_dependency "webmock"
|
42
40
|
|
43
|
-
# spec.add_dependency "relaton-iec", "~> 1.8.0"
|
44
41
|
spec.add_dependency "algolia"
|
42
|
+
spec.add_dependency "pubid-iso", "~> 0.1.8"
|
45
43
|
spec.add_dependency "relaton-iso-bib", "~> 1.12.0"
|
46
|
-
spec.add_dependency "pubid-iso", "~> 0.1.7"
|
47
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.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
|
@@ -179,33 +179,33 @@ dependencies:
|
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
|
-
name:
|
182
|
+
name: pubid-iso
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
185
|
- - "~>"
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version: 1.
|
187
|
+
version: 0.1.8
|
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: 1.
|
194
|
+
version: 0.1.8
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
|
-
name:
|
196
|
+
name: relaton-iso-bib
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
199
|
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version:
|
201
|
+
version: 1.12.0
|
202
202
|
type: :runtime
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
208
|
+
version: 1.12.0
|
209
209
|
description: 'RelatonIso: retrieve ISO Standards for bibliographic use using the IsoBibliographicItem
|
210
210
|
model'
|
211
211
|
email:
|