relaton-iec 1.16.2 → 1.16.4

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: d3c632b6fb62b15fd360d801190ebac6742f05658b695e573304b5c4a7d38ed1
4
- data.tar.gz: 271d54825baa3cc59e59bcc926da577aecb172bb81466cb7b1dd5c4248746357
3
+ metadata.gz: 101c12e86e42473965841a2ba577d7ef661ad41cd3466ab5f3b4488675a8446a
4
+ data.tar.gz: be02f4aeeda35aab505380d35352b0f906b53efa680fbbf139364fcd90a8952b
5
5
  SHA512:
6
- metadata.gz: 283f22a20fceef3a4dbb3430f8bbdb69930b8286f5af0e00bc8c1648242c6024603b2a284efa7ae7fcdcf908db0f326f48533ba5fbad8389f3e534428a9059b6
7
- data.tar.gz: 8327e80d5c36f179d692966ebb280fc00c66e89145d1da741e3198b1219655df2a33ca45735870466c3b045ae7b3f8bce7ba663396af76e29b0bdbcf06b8359b
6
+ metadata.gz: 2cd438a1c74b7b79f7a2ac3a909543a15cecc20c96c36fe2a83223088cafee149e5e33c32bcabfa7fac8adc893bed21ac7cb2e561373b8c15d7c39f50979b303
7
+ data.tar.gz: 8e579abea1e3e46268999b9d68658761778ce10caee7f6a571d7286a0f86507e1649025ef4fd152a96c11075fd2b99cbc88e4e87df942447ae8c9d2cc26a8857
@@ -4,7 +4,7 @@ module RelatonIec
4
4
  end
5
5
 
6
6
  def self.method_missing(_method, *args)
7
- ReferenceFormat.new *args
7
+ ReferenceFormat.new(*args)
8
8
  end
9
9
 
10
10
  class ReferenceFormat
@@ -6,7 +6,7 @@ require "addressable/uri"
6
6
  module RelatonIec
7
7
  # Page of hit collection.
8
8
  class HitCollection < RelatonBib::HitCollection
9
- def_delegators :@array, :detect, :map
9
+ def_delegators :@array, :detect, :map, :last, :[], :max_by
10
10
 
11
11
  INDEX_FILE = "index1.yaml"
12
12
 
@@ -177,12 +177,12 @@ module RelatonIec
177
177
  # has a title (amendments do not).
178
178
  # If no match, returns any years which caused mismatch, for error reporting
179
179
  def results_filter(result, ref, year, opts)
180
- r_code, r_year, r_amd = code_year ref
180
+ r_code, r_year, r_amd, r_consv = code_year ref
181
181
  r_year ||= year
182
182
  if opts[:all_parts]
183
183
  ret = result.to_all_parts(r_year)
184
184
  else
185
- ret, missed_parts = match_result(result, r_code, r_year, r_amd)
185
+ ret, missed_parts = match_result(result, r_code, r_year, r_amd, r_consv)
186
186
  end
187
187
  { ret: ret, years: missed_years(result, r_year), missed_parts: missed_parts }
188
188
  end
@@ -198,23 +198,27 @@ module RelatonIec
198
198
  # @param [String] code code of the document
199
199
  # @param [String] year year of the document
200
200
  # @param [String] amd amendment of the document
201
+ # @param [String] consv consolidated version of the document
201
202
  #
202
203
  # @return [Array<RelatonIec::IecBibliographicItem, Array, nil>] result, missed parts
203
204
  #
204
- def match_result(result, code, year, amd) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
205
+ def match_result(result, code, year, amd, consv) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
205
206
  missed_parts = false
206
- ret = result.detect do |h|
207
- h_codes, h_years, h_amds = codes_years h.hit[:code]
207
+ res = result.select do |h|
208
+ h_codes, h_years, h_amds, h_consv = codes_years h.hit[:code]
208
209
  match_code = h_codes.include? code
209
210
  match_year = h_years.include?(year)
210
211
  missed_parts ||= !match_code
211
- match_code && (!year || match_year) && match_amd(amd, h_amds)
212
- end&.fetch
212
+ match_code && (!year || match_year) && match_amd(amd, h_amds) && h_consv.first == consv
213
+ end
214
+ hit = year ? res.first : res.max_by { |h| code_year(h.hit[:code])[1].to_i }
215
+ ret = hit&.fetch
213
216
  [ret, missed_parts]
214
217
  end
215
218
 
216
219
  def match_amd(amd, h_amds)
217
- (!amd && h_amds.empty?) || h_amds.include?(amd)
220
+ # (!amd && h_amds.empty?) || h_amds.include?(amd)
221
+ h_amds.first == amd
218
222
  end
219
223
 
220
224
  # @param ref [String]
@@ -225,8 +229,9 @@ module RelatonIec
225
229
  ^(?<code>\S+\s[^:/]+)
226
230
  (?::(?<year>\d{4}))?
227
231
  (?:/(?<amd>\w+)(?::\d{4})?)?
232
+ (?:\+(?<consv>\w+)(?::\d{4})?)?
228
233
  }x =~ ref
229
- [code, year, amd&.upcase]
234
+ [code, year, amd&.upcase, consv&.upcase]
230
235
  end
231
236
 
232
237
  # @param ref [String]
@@ -5,7 +5,7 @@ module RelatonIec
5
5
  def initialize
6
6
  @short = :relaton_iec
7
7
  @prefix = "IEC"
8
- @defaultprefix = %r{^IEC\s|^IEV($|\s)}
8
+ @defaultprefix = %r{^(IEC\s|CISPR\s|IEV($|\s))}
9
9
  @idtype = "IEC"
10
10
  @datasets = %w[iec-harmonized-all iec-harmonized-latest]
11
11
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonIec
2
- VERSION = "1.16.2".freeze
2
+ VERSION = "1.16.4".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-iec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.2
4
+ version: 1.16.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: 2023-10-14 00:00:00.000000000 Z
11
+ date: 2023-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable