relaton-iso 1.12.3 → 1.13.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2430abcb3feaf394c967b11c5fa17a0cc8160c6e0d94a35a190c15f299a088af
4
- data.tar.gz: 738eea32609469bf2b588b2a07046da5dd88597acbd7f190ec80b5a32c7a093a
3
+ metadata.gz: f7957abd3baa9506418de82f57fd7bdb8e007bd3db0319a8a4c3ce60620afab2
4
+ data.tar.gz: a8757774fbcd0925f911e2e981972304bbdf19fb8f7da18827538edc2c2a1f31
5
5
  SHA512:
6
- metadata.gz: 1469ca87aed02788972c9b48e967fdbfbbe690c68170f1cadea2b1575171e3cf61f4fc88ef18d3152cda69ea76057cc57e9de78eababf3dd7c9a6ffa3a8fdcda
7
- data.tar.gz: a9cdb6fb9db35dd96a1ced59f80474b6ce0323c9bd3c65bb9bc93e94db1f928a4ffd1e0128eb213603e67756d03d1489bc5c003d9c1f4f064bc9b6588b215ee9
6
+ metadata.gz: fe1eb0dc20bb16c7209d0339719ea7ea105e3942e6435231318f5791ebc404dd6aaede200296fbcc4ef545b561a5f9b993a1dd84dc7c6ee9e7e75b0b994a0715
7
+ data.tar.gz: 04d922e293b122a75a5d07b0093c62e2a6fde2024c4ce92188d6dbae1a131aafcd7900f897e32309348f1cf7b9ed7be1eefe249f250836b266f1887c5bb26ecd
@@ -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
- hits = isobib_search_filter(query_pubid, opts)
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, query_pubid.year)
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]
@@ -58,6 +58,8 @@ module RelatonIso
58
58
  else
59
59
  ret.to_most_recent_reference
60
60
  end
61
+ rescue Pubid::Core::Errors::ParseError
62
+ warn "[relaton-iso] (\"#{code}\") is not recognized as a standards identifier."
61
63
  end
62
64
 
63
65
  # @param query_pubid [Pubid::Iso::Identifier]
@@ -86,6 +88,7 @@ module RelatonIso
86
88
  # @return [RelatonIso::HitCollection]
87
89
  def filter_hits_by_year(hit_collection, year) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
88
90
  missed_years = []
91
+ return { hits: hit_collection, missed_years: missed_years } if year.nil?
89
92
 
90
93
  # filter by year
91
94
  hits = hit_collection.select do |hit|
@@ -103,27 +106,22 @@ module RelatonIso
103
106
  end
104
107
  end
105
108
 
106
- if hits.empty? && !missed_years.empty?
107
- warn "[relaton-iso] (There was no match for #{year}, though there "\
108
- "were matches found for #{missed_years.join(', ')}.)"
109
- end
110
- hits
109
+ { hits: hits, missed_years: missed_years }
111
110
  end
112
111
 
113
112
  private
114
113
 
115
- def fetch_ref_err(query_pubid, year) # rubocop:disable Metrics/MethodLength
116
- id = year ? "#{query_pubid}:#{year}" : query_pubid
117
- warn "[relaton-iso] WARNING: no match found online for #{id}. "\
114
+ def fetch_ref_err(query_pubid) # rubocop:disable Metrics/MethodLength
115
+ warn "[relaton-iso] WARNING: no match found online for #{query_pubid}. " \
118
116
  "The code must be exactly like it is on the standards website."
119
117
  if /\d-\d/.match? query_pubid.to_s
120
- warn "[relaton-iso] The provided document part may not exist, "\
118
+ warn "[relaton-iso] The provided document part may not exist, " \
121
119
  "or the document may no longer be published in parts."
122
120
  else
123
- warn "[relaton-iso] If you wanted to cite all document parts for "\
124
- "the reference, use \"#{query_pubid} (all parts)\".\nIf the document "\
125
- "is not a standard, use its document type abbreviation "\
126
- "(TS, TR, PAS, Guide)."
121
+ warn "[relaton-iso] If you wanted to cite all document parts for " \
122
+ "the reference, use \"#{query_pubid} (all parts)\"."
123
+ warn "[relaton-iso] If the document is not a standard, use its " \
124
+ "document type abbreviation (TS, TR, PAS, Guide)."
127
125
  end
128
126
  nil
129
127
  end
@@ -133,26 +131,34 @@ module RelatonIso
133
131
  # @param query_pubid [Pubid::Iso::Identifier] reference without correction
134
132
  # @param opts [Hash]
135
133
  # @return [Array<RelatonIso::Hit>]
136
- def isobib_search_filter(query_pubid, opts) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
134
+ def isobib_search_filter(query_pubid, opts) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
135
+ missed_years = []
137
136
  query_pubid.part = nil if opts[:all_parts]
138
137
  warn "[relaton-iso] (\"#{query_pubid}\") fetching..."
139
138
  # fetch hits collection
140
139
  hit_collection = search(query_pubid.to_s(with_date: false))
141
140
  # filter only matching hits
142
- res = filter_hits hit_collection, query_pubid,
143
- all_parts: opts[:all_parts]
144
- return res unless res.empty?
141
+ res = filter_hits hit_collection, query_pubid, all_parts: opts[:all_parts]
142
+ return res unless res[:hits].empty?
145
143
 
144
+ missed_years += res[:missed_years]
146
145
  # lookup for documents with stages when no match without stage
147
146
  res = filter_hits hit_collection, query_pubid,
148
147
  all_parts: opts[:all_parts], any_types_stages: true
149
- return res unless res.empty?
148
+ return res unless res[:hits].empty?
150
149
 
150
+ missed_years += res[:missed_years]
151
151
  # TODO: do this at pubid-iso
152
152
  if query_pubid.publisher == "ISO" && query_pubid.copublisher.nil? # try ISO/IEC if ISO not found
153
153
  warn "[relaton-iso] Attempting ISO/IEC retrieval"
154
154
  query_pubid.copublisher = "IEC"
155
155
  res = filter_hits hit_collection, query_pubid, all_parts: opts[:all_parts]
156
+ missed_years += res[:missed_years]
157
+ end
158
+
159
+ if res[:hits].empty? && missed_years.any?
160
+ warn "[relaton-iso] (There was no match for #{query_pubid.year}, though there "\
161
+ "were matches found for #{missed_years.uniq.join(', ')}.)"
156
162
  end
157
163
  res
158
164
  end
@@ -172,7 +178,7 @@ module RelatonIso
172
178
  query_pubid.amendments == hit_pubid.amendments
173
179
  end
174
180
 
175
- query_pubid.year ? filter_hits_by_year(result, query_pubid.year) : result
181
+ filter_hits_by_year(result, query_pubid.year)
176
182
  end
177
183
  end
178
184
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonIso
4
- VERSION = "1.12.3"
4
+ VERSION = "1.13.1"
5
5
  end
data/relaton_iso.gemspec CHANGED
@@ -40,5 +40,5 @@ Gem::Specification.new do |spec|
40
40
 
41
41
  spec.add_dependency "algolia"
42
42
  spec.add_dependency "pubid-iso", "~> 0.1.8"
43
- spec.add_dependency "relaton-iso-bib", "~> 1.12.0"
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.12.3
4
+ version: 1.13.1
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-29 00:00:00.000000000 Z
11
+ date: 2022-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -198,14 +198,14 @@ dependencies:
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: 1.12.0
201
+ version: 1.13.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: 1.12.0
208
+ version: 1.13.0
209
209
  description: 'RelatonIso: retrieve ISO Standards for bibliographic use using the IsoBibliographicItem
210
210
  model'
211
211
  email: