relaton-iec 1.16.3 → 1.17.0

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: f56f331501e59dbf8da01e6444c93abf2bb7df8ec1dc2ed7ce12d2db4499ffbe
4
- data.tar.gz: 6a2f4faf1ebddfa0c6909816eb6f4876fc57c2fdefec52e2a1fb9250706eebbd
3
+ metadata.gz: 2781711712e741e20c857da5cbd0c7f7f62eaf85fc671c016899beeb0e817af8
4
+ data.tar.gz: 13e84464bcaa91c46b9ce1565dc2b2a4ce061f525cb5daaa39fcbe9fa4b32fe0
5
5
  SHA512:
6
- metadata.gz: ada90e3aabddb40bc0e780d4959b7182f13b560741cf8058a000c1e372813d0023366f5835217a54afd4ef8149bf913e12c3084f2818031ca6eaa8fdf096f457
7
- data.tar.gz: e1386d61a2525dee63591cb02abbcc728ad28d9d4f87758ec2f39aba6aedf37be1f05ecd9ab09af2c487481ca8025ae2d4d8b37a027bccad82a44f8017317435
6
+ metadata.gz: 7bd673ddef434b3b2e5eadff79a8412cc9134ccae892c13a318777cff1658d07172bedf6c1c5644b88c89808a2de40a0b025b98777d2d517bf82ca13113e2e26
7
+ data.tar.gz: d26ed19cacb261f11de2863d244db709fe0e118251535460fdfeb8a1bfbeeb3e9ac97686f5664db45b79d1440e7292be0b8bb94512b684ea666149e63f31b391
@@ -346,6 +346,8 @@
346
346
  <ref name="keyword"/>
347
347
  <ref name="xref"/>
348
348
  <ref name="hyperlink"/>
349
+ <ref name="index"/>
350
+ <ref name="index-xref"/>
349
351
  </choice>
350
352
  </oneOrMore>
351
353
  </element>
@@ -623,6 +625,8 @@
623
625
  <ref name="eref"/>
624
626
  <ref name="xref"/>
625
627
  <ref name="hyperlink"/>
628
+ <ref name="index"/>
629
+ <ref name="index-xref"/>
626
630
  </choice>
627
631
  </zeroOrMore>
628
632
  </element>
@@ -636,6 +640,8 @@
636
640
  <ref name="eref"/>
637
641
  <ref name="xref"/>
638
642
  <ref name="hyperlink"/>
643
+ <ref name="index"/>
644
+ <ref name="index-xref"/>
639
645
  </choice>
640
646
  </zeroOrMore>
641
647
  </element>
@@ -648,6 +654,8 @@
648
654
  <ref name="eref"/>
649
655
  <ref name="xref"/>
650
656
  <ref name="hyperlink"/>
657
+ <ref name="index"/>
658
+ <ref name="index-xref"/>
651
659
  </choice>
652
660
  </zeroOrMore>
653
661
  </element>
@@ -655,7 +663,11 @@
655
663
  <define name="keyword">
656
664
  <element name="keyword">
657
665
  <zeroOrMore>
658
- <ref name="PureTextElement"/>
666
+ <choice>
667
+ <ref name="PureTextElement"/>
668
+ <ref name="index"/>
669
+ <ref name="index-xref"/>
670
+ </choice>
659
671
  </zeroOrMore>
660
672
  </element>
661
673
  </define>
@@ -676,7 +688,11 @@
676
688
  <define name="strike">
677
689
  <element name="strike">
678
690
  <zeroOrMore>
679
- <ref name="PureTextElement"/>
691
+ <choice>
692
+ <ref name="PureTextElement"/>
693
+ <ref name="index"/>
694
+ <ref name="index-xref"/>
695
+ </choice>
680
696
  </zeroOrMore>
681
697
  </element>
682
698
  </define>
data/grammars/biblio.rng CHANGED
@@ -942,6 +942,7 @@
942
942
  <value>obsoleted</value>
943
943
  <value>confirmed</value>
944
944
  <value>updated</value>
945
+ <value>corrected</value>
945
946
  <value>issued</value>
946
947
  <value>transmitted</value>
947
948
  <value>copied</value>
@@ -15,6 +15,14 @@ module RelatonIec
15
15
  "CISPR" => ["International special committee on radio interference", "www.iec.ch"],
16
16
  }.freeze
17
17
 
18
+ DOCTYPES = {
19
+ "IS" => "international-standard",
20
+ "TR" => "technical-report",
21
+ "TS" => "technical-specification",
22
+ "PAS" => "publicly-available-specification",
23
+ "SRD" => "system-reference-deliverable",
24
+ }
25
+
18
26
  #
19
27
  # Initialize new instance.
20
28
  #
@@ -233,14 +241,8 @@ module RelatonIec
233
241
  # @return [String] document type
234
242
  #
235
243
  def doctype
236
- case @pub["stdType"]
237
- when "IS" then "international-standard"
238
- when "TR" then "technical-report"
239
- when "TS" then "technical-specification"
240
- when "PAS" then "publicly-available-specification"
241
- when "SRD" then "system-reference-deliverable"
242
- else @pub["stdType"].downcase
243
- end
244
+ type = DOCTYPES[@pub["stdType"]] || @pub["stdType"].downcase
245
+ DocumentType.new type: type
244
246
  end
245
247
 
246
248
  #
@@ -0,0 +1,20 @@
1
+ module RelatonIec
2
+ class DocumentType < RelatonBib::DocumentType
3
+ DOCTYPES = %w[
4
+ international-standard technical-specification technical-report
5
+ publicly-available-specification international-workshop-agreement
6
+ guide industry-technical-agreement system-reference-deliverable
7
+ ].freeze
8
+
9
+ def initialize(type:, abbreviation: nil)
10
+ check_type type
11
+ super
12
+ end
13
+
14
+ def check_type(type)
15
+ unless DOCTYPES.include? type
16
+ Util.warn "WARNING: Invalid doctype: `#{type}`"
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,14 +1,15 @@
1
1
  module RelatonIec
2
- class HashConverter < RelatonIsoBib::HashConverter
3
- class << self
4
- #
5
- # Ovverides superclass's method
6
- #
7
- # @param item [Hash]
8
- # @retirn [RelatonIec::IecBibliographicItem]
9
- def bib_item(item)
10
- IecBibliographicItem.new(**item)
11
- end
2
+ module HashConverter
3
+ include RelatonIsoBib::HashConverter
4
+ extend self
5
+
6
+ #
7
+ # Ovverides superclass's method
8
+ #
9
+ # @param item [Hash]
10
+ # @retirn [RelatonIec::IecBibliographicItem]
11
+ def bib_item(item)
12
+ IecBibliographicItem.new(**item)
12
13
  end
13
14
  end
14
15
  end
@@ -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
 
@@ -1,11 +1,5 @@
1
1
  module RelatonIec
2
2
  class IecBibliographicItem < RelatonIsoBib::IsoBibliographicItem
3
- DOCTYPES = %w[
4
- international-standard technical-specification technical-report
5
- publicly-available-specification international-workshop-agreement
6
- guide industry-technical-agreement system-reference-deliverable
7
- ].freeze
8
-
9
3
  SUBDOCTYPES = %w[specification method-of-test vocabulary code-of-practice].freeze
10
4
 
11
5
  FUNCTION = %w[emc safety enviroment quality-assurance].freeze
@@ -38,9 +32,9 @@ module RelatonIec
38
32
  Util.warn "Allowed function values are: `#{FUNCTION.join('`, `')}`"
39
33
  end
40
34
  if args[:updates_document_type] &&
41
- !DOCTYPES.include?(args[:updates_document_type])
35
+ !DocumentType::DOCTYPES.include?(args[:updates_document_type])
42
36
  Util.warn "WARNING: Invalid updates_document_type: `#{args[:updates_document_type]}`"
43
- Util.warn "Allowed updates_document_type values are: `#{DOCTYPES.join('`, `')}`"
37
+ Util.warn "Allowed updates_document_type values are: `#{DocumentType::DOCTYPES.join('`, `')}`"
44
38
  end
45
39
  @function = args.delete :function
46
40
  @updates_document_type = args.delete :updates_document_type
@@ -77,7 +71,7 @@ module RelatonIec
77
71
  super(**opts) do |b|
78
72
  if opts[:bibdata]
79
73
  ext = b.ext do
80
- b.doctype doctype if doctype
74
+ doctype&.to_xml b
81
75
  b.horizontal horizontal unless horizontal.nil?
82
76
  b.function function if function
83
77
  editorialgroup&.to_xml b
@@ -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]
@@ -1,3 +1,3 @@
1
1
  module RelatonIec
2
- VERSION = "1.16.3".freeze
2
+ VERSION = "1.17.0".freeze
3
3
  end
data/lib/relaton_iec.rb CHANGED
@@ -9,6 +9,7 @@ require "relaton_iec/hit"
9
9
  require "relaton_iec/version"
10
10
  require "relaton_iec/config"
11
11
  require "relaton_iec/util"
12
+ require "relaton_iec/document_type"
12
13
  require "relaton_iec/iec_bibliography"
13
14
  require "relaton_iec/iec_bibliographic_item"
14
15
  require "relaton_iec/xml_parser"
data/relaton_iec.gemspec CHANGED
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_dependency "addressable"
27
27
  spec.add_dependency "relaton-index", "~> 0.2.0"
28
- spec.add_dependency "relaton-iso-bib", "~> 1.16.0"
28
+ spec.add_dependency "relaton-iso-bib", "~> 1.17.0"
29
29
  spec.add_dependency "rubyzip"
30
30
  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.3
4
+ version: 1.17.0
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-11-01 00:00:00.000000000 Z
11
+ date: 2023-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.16.0
47
+ version: 1.17.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.16.0
54
+ version: 1.17.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubyzip
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -112,6 +112,7 @@ files:
112
112
  - lib/relaton_iec/config.rb
113
113
  - lib/relaton_iec/data_fetcher.rb
114
114
  - lib/relaton_iec/data_parser.rb
115
+ - lib/relaton_iec/document_type.rb
115
116
  - lib/relaton_iec/hash_converter.rb
116
117
  - lib/relaton_iec/hit.rb
117
118
  - lib/relaton_iec/hit_collection.rb