relaton-iec 1.11.2 → 1.12.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: 6ac7a2b47a1a7b746f0a40a5ba93210ef38d6302e155d3b5c52d363e888de9c7
4
- data.tar.gz: 18253a34039c3b99ad516f0260f7b34c61df0a4a8dd0ed5a32f5bafabc72b7ad
3
+ metadata.gz: 7f1310013763840a81d03dcdb1e2f5356d347c86670f9f10c6a61fde7e12a5d0
4
+ data.tar.gz: f08a39955926ff2f638442d4d96f1dfef7d2c5a5e817ed98079e1fa1762304b5
5
5
  SHA512:
6
- metadata.gz: d7ade3ceccc427c5901b59fa90674d781430f9562ea4c64b6d575a538a58fb2c930eda46f790c2bbe9439e0e8c0dcfe92122bed97693560674dda66321778c50
7
- data.tar.gz: d47eba43051be57244e1985b2311848db19eb5225cdada484b69c4af745eb364e40ab3c0cd745808b9c16378b448049323169844a290fd0710383d7df8bae033
6
+ metadata.gz: b43bab7a4d22726a5110b2f6a1b98758298fe80e10f734a7399ec077a39109cb97bfd5a42e092dfbc5062709b543aa56933bf63b9cdda5979edfea832f21c299
7
+ data.tar.gz: bf6ea4c3124c5d93f94b9efd4aa4fcebe736983b68fec1e2eeb0192c08a18f48f7ed62c006f999884bd255c868a6b58c7811e24a821fe8b73ea63b2b45c7b41f
@@ -10,27 +10,4 @@ on:
10
10
 
11
11
  jobs:
12
12
  rake:
13
- name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
- runs-on: ${{ matrix.os }}
15
- continue-on-error: ${{ matrix.experimental }}
16
- strategy:
17
- fail-fast: false
18
- matrix:
19
- ruby: [ '3.0', '2.7', '2.6', '2.5' ]
20
- os: [ ubuntu-latest, windows-latest, macos-latest ]
21
- experimental: [ false ]
22
- steps:
23
- - uses: actions/checkout@v2
24
- with:
25
- submodules: true
26
-
27
- # https://github.com/ruby-debug/debase/issues/89#issuecomment-686827382
28
- - if: matrix.os == 'macos-latest' && matrix.ruby == '2.5'
29
- run: echo BUNDLE_BUILD__DEBASE="--with-cflags=\"-Wno-error=implicit-function-declaration\"" >> $GITHUB_ENV
30
-
31
- - uses: ruby/setup-ruby@v1
32
- with:
33
- ruby-version: ${{ matrix.ruby }}
34
- bundler-cache: true
35
-
36
- - run: bundle exec rake
13
+ uses: relaton/support/.github/workflows/rake.yml@master
data/grammars/biblio.rng CHANGED
@@ -527,7 +527,7 @@
527
527
  </define>
528
528
  <define name="LocalityType">
529
529
  <data type="string">
530
- <param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|list|example|volume|issue|time|anchor|locality:[a-zA-Z0-9_]+</param>
530
+ <param name="pattern">section|clause|part|paragraph|chapter|page|title|line|whole|table|annex|figure|note|list|example|volume|issue|time|anchor|locality:[a-zA-Z0-9_]+</param>
531
531
  </data>
532
532
  </define>
533
533
  <define name="referenceFrom">
@@ -614,12 +614,103 @@
614
614
  <optional>
615
615
  <ref name="fetched"/>
616
616
  </optional>
617
- <choice>
618
- <oneOrMore>
619
- <ref name="btitle"/>
620
- </oneOrMore>
617
+ <optional>
621
618
  <ref name="formattedref"/>
622
- </choice>
619
+ </optional>
620
+ <oneOrMore>
621
+ <ref name="btitle"/>
622
+ </oneOrMore>
623
+ <zeroOrMore>
624
+ <ref name="bsource"/>
625
+ </zeroOrMore>
626
+ <oneOrMore>
627
+ <ref name="docidentifier"/>
628
+ </oneOrMore>
629
+ <optional>
630
+ <ref name="docnumber"/>
631
+ </optional>
632
+ <zeroOrMore>
633
+ <ref name="bdate"/>
634
+ </zeroOrMore>
635
+ <zeroOrMore>
636
+ <ref name="contributor"/>
637
+ </zeroOrMore>
638
+ <optional>
639
+ <ref name="edition"/>
640
+ </optional>
641
+ <zeroOrMore>
642
+ <ref name="version"/>
643
+ </zeroOrMore>
644
+ <zeroOrMore>
645
+ <ref name="biblionote"/>
646
+ </zeroOrMore>
647
+ <zeroOrMore>
648
+ <ref name="language"/>
649
+ </zeroOrMore>
650
+ <zeroOrMore>
651
+ <ref name="script"/>
652
+ </zeroOrMore>
653
+ <zeroOrMore>
654
+ <ref name="bibabstract"/>
655
+ </zeroOrMore>
656
+ <optional>
657
+ <ref name="status"/>
658
+ </optional>
659
+ <zeroOrMore>
660
+ <ref name="copyright"/>
661
+ </zeroOrMore>
662
+ <zeroOrMore>
663
+ <ref name="docrelation"/>
664
+ </zeroOrMore>
665
+ <zeroOrMore>
666
+ <ref name="series"/>
667
+ </zeroOrMore>
668
+ <optional>
669
+ <ref name="medium"/>
670
+ </optional>
671
+ <zeroOrMore>
672
+ <ref name="bplace"/>
673
+ </zeroOrMore>
674
+ <zeroOrMore>
675
+ <ref name="bprice"/>
676
+ </zeroOrMore>
677
+ <zeroOrMore>
678
+ <ref name="extent"/>
679
+ </zeroOrMore>
680
+ <optional>
681
+ <ref name="bibliographic_size"/>
682
+ </optional>
683
+ <zeroOrMore>
684
+ <ref name="accesslocation"/>
685
+ </zeroOrMore>
686
+ <zeroOrMore>
687
+ <ref name="license"/>
688
+ </zeroOrMore>
689
+ <zeroOrMore>
690
+ <ref name="bclassification"/>
691
+ </zeroOrMore>
692
+ <zeroOrMore>
693
+ <ref name="bkeyword"/>
694
+ </zeroOrMore>
695
+ <optional>
696
+ <ref name="validity"/>
697
+ </optional>
698
+ </define>
699
+ <define name="ReducedBibliographicItem">
700
+ <optional>
701
+ <attribute name="type">
702
+ <ref name="BibItemType"/>
703
+ </attribute>
704
+ </optional>
705
+ <optional>
706
+ <ref name="fetched"/>
707
+ </optional>
708
+ <optional>
709
+ <ref name="formattedref"/>
710
+ </optional>
711
+ <zeroOrMore>
712
+ <ref name="btitle"/>
713
+ </zeroOrMore>
623
714
  <zeroOrMore>
624
715
  <ref name="bsource"/>
625
716
  </zeroOrMore>
@@ -638,9 +729,9 @@
638
729
  <optional>
639
730
  <ref name="edition"/>
640
731
  </optional>
641
- <optional>
732
+ <zeroOrMore>
642
733
  <ref name="version"/>
643
- </optional>
734
+ </zeroOrMore>
644
735
  <zeroOrMore>
645
736
  <ref name="biblionote"/>
646
737
  </zeroOrMore>
@@ -833,6 +924,12 @@
833
924
  <data type="boolean"/>
834
925
  </attribute>
835
926
  </optional>
927
+ <optional>
928
+ <attribute name="language"/>
929
+ </optional>
930
+ <optional>
931
+ <attribute name="script"/>
932
+ </optional>
836
933
  <text/>
837
934
  </element>
838
935
  </define>
@@ -851,17 +948,46 @@
851
948
  </define>
852
949
  <define name="bplace">
853
950
  <element name="place">
854
- <optional>
855
- <attribute name="uri">
856
- <data type="anyURI"/>
857
- </attribute>
858
- </optional>
859
- <optional>
860
- <attribute name="region"/>
861
- </optional>
951
+ <choice>
952
+ <text/>
953
+ <group>
954
+ <ref name="bibliocity"/>
955
+ <zeroOrMore>
956
+ <ref name="biblioregion"/>
957
+ </zeroOrMore>
958
+ <zeroOrMore>
959
+ <ref name="bibliocountry"/>
960
+ </zeroOrMore>
961
+ </group>
962
+ </choice>
963
+ </element>
964
+ </define>
965
+ <define name="bibliocity">
966
+ <element name="city">
862
967
  <text/>
863
968
  </element>
864
969
  </define>
970
+ <define name="biblioregion">
971
+ <element name="region">
972
+ <ref name="RegionType"/>
973
+ </element>
974
+ </define>
975
+ <define name="bibliocountry">
976
+ <element name="country">
977
+ <ref name="RegionType"/>
978
+ </element>
979
+ </define>
980
+ <define name="RegionType">
981
+ <optional>
982
+ <attribute name="iso"/>
983
+ </optional>
984
+ <optional>
985
+ <attribute name="recommended">
986
+ <data type="boolean"/>
987
+ </attribute>
988
+ </optional>
989
+ <text/>
990
+ </define>
865
991
  <define name="bprice">
866
992
  <element name="price">
867
993
  <attribute name="currency"/>
@@ -957,36 +1083,34 @@
957
1083
  <ref name="SeriesType"/>
958
1084
  </attribute>
959
1085
  </optional>
960
- <choice>
1086
+ <optional>
961
1087
  <ref name="formattedref"/>
962
- <group>
963
- <ref name="btitle"/>
964
- <optional>
965
- <ref name="bplace"/>
966
- </optional>
967
- <optional>
968
- <ref name="seriesorganization"/>
969
- </optional>
970
- <optional>
971
- <ref name="abbreviation"/>
972
- </optional>
973
- <optional>
974
- <ref name="seriesfrom"/>
975
- </optional>
976
- <optional>
977
- <ref name="seriesto"/>
978
- </optional>
979
- <optional>
980
- <ref name="seriesnumber"/>
981
- </optional>
982
- <optional>
983
- <ref name="seriespartnumber"/>
984
- </optional>
985
- <optional>
986
- <ref name="seriesrun"/>
987
- </optional>
988
- </group>
989
- </choice>
1088
+ </optional>
1089
+ <ref name="btitle"/>
1090
+ <optional>
1091
+ <ref name="bplace"/>
1092
+ </optional>
1093
+ <optional>
1094
+ <ref name="seriesorganization"/>
1095
+ </optional>
1096
+ <optional>
1097
+ <ref name="abbreviation"/>
1098
+ </optional>
1099
+ <optional>
1100
+ <ref name="seriesfrom"/>
1101
+ </optional>
1102
+ <optional>
1103
+ <ref name="seriesto"/>
1104
+ </optional>
1105
+ <optional>
1106
+ <ref name="seriesnumber"/>
1107
+ </optional>
1108
+ <optional>
1109
+ <ref name="seriespartnumber"/>
1110
+ </optional>
1111
+ <optional>
1112
+ <ref name="seriesrun"/>
1113
+ </optional>
990
1114
  </element>
991
1115
  </define>
992
1116
  <define name="SeriesType">
@@ -1145,7 +1269,7 @@
1145
1269
  </element>
1146
1270
  </optional>
1147
1271
  <element name="bibitem">
1148
- <ref name="BibliographicItem"/>
1272
+ <ref name="ReducedBibliographicItem"/>
1149
1273
  </element>
1150
1274
  <choice>
1151
1275
  <zeroOrMore>
@@ -1170,9 +1294,9 @@
1170
1294
  <optional>
1171
1295
  <ref name="revision-date"/>
1172
1296
  </optional>
1173
- <zeroOrMore>
1297
+ <optional>
1174
1298
  <ref name="draft"/>
1175
- </zeroOrMore>
1299
+ </optional>
1176
1300
  </element>
1177
1301
  </define>
1178
1302
  <define name="vedition">
data/grammars/iec.rng CHANGED
@@ -14,6 +14,7 @@
14
14
  <value>international-workshop-agreement</value>
15
15
  <value>guide</value>
16
16
  <value>industry-technical-agreement</value>
17
+ <value>system-reference-delivrabble</value>
17
18
  </choice>
18
19
  </define>
19
20
  <define name="BibDataExtensionType">
data/grammars/isodoc.rng CHANGED
@@ -32,6 +32,43 @@
32
32
  <ref name="DocumentType"/>
33
33
  </element>
34
34
  </define>
35
+ <define name="admonition">
36
+ <element name="admonition">
37
+ <attribute name="type">
38
+ <ref name="AdmonitionType"/>
39
+ </attribute>
40
+ <optional>
41
+ <attribute name="class"/>
42
+ </optional>
43
+ <attribute name="id">
44
+ <data type="ID"/>
45
+ </attribute>
46
+ <optional>
47
+ <attribute name="uri">
48
+ <data type="anyURI"/>
49
+ </attribute>
50
+ </optional>
51
+ <optional>
52
+ <attribute name="coverpage">
53
+ <data type="boolean"/>
54
+ </attribute>
55
+ </optional>
56
+ <optional>
57
+ <attribute name="notag">
58
+ <data type="boolean"/>
59
+ </attribute>
60
+ </optional>
61
+ <optional>
62
+ <ref name="tname"/>
63
+ </optional>
64
+ <zeroOrMore>
65
+ <ref name="paragraph-with-footnote"/>
66
+ </zeroOrMore>
67
+ <zeroOrMore>
68
+ <ref name="note"/>
69
+ </zeroOrMore>
70
+ </element>
71
+ </define>
35
72
  <define name="index">
36
73
  <element name="index">
37
74
  <optional>
@@ -79,6 +116,11 @@
79
116
  <data type="boolean"/>
80
117
  </attribute>
81
118
  </optional>
119
+ <optional>
120
+ <attribute name="suppress_identifier">
121
+ <data type="boolean"/>
122
+ </attribute>
123
+ </optional>
82
124
  <ref name="BibliographicItem"/>
83
125
  </element>
84
126
  </define>
@@ -245,6 +287,9 @@
245
287
  <ref name="MultilingualRenderingType"/>
246
288
  </attribute>
247
289
  </optional>
290
+ <optional>
291
+ <ref name="tname"/>
292
+ </optional>
248
293
  <oneOrMore>
249
294
  <ref name="ul_li"/>
250
295
  </oneOrMore>
@@ -287,6 +332,9 @@
287
332
  </choice>
288
333
  </attribute>
289
334
  </optional>
335
+ <optional>
336
+ <ref name="tname"/>
337
+ </optional>
290
338
  <oneOrMore>
291
339
  <ref name="li"/>
292
340
  </oneOrMore>
@@ -323,6 +371,9 @@
323
371
  <ref name="MultilingualRenderingType"/>
324
372
  </attribute>
325
373
  </optional>
374
+ <optional>
375
+ <ref name="tname"/>
376
+ </optional>
326
377
  <oneOrMore>
327
378
  <ref name="dt"/>
328
379
  <ref name="dd"/>
@@ -657,6 +708,9 @@
657
708
  <optional>
658
709
  <attribute name="tag"/>
659
710
  </optional>
711
+ <optional>
712
+ <attribute name="type"/>
713
+ </optional>
660
714
  <optional>
661
715
  <attribute name="multilingual-rendering">
662
716
  <ref name="MultilingualRenderingType"/>
@@ -692,6 +746,9 @@
692
746
  <optional>
693
747
  <attribute name="tag"/>
694
748
  </optional>
749
+ <optional>
750
+ <attribute name="type"/>
751
+ </optional>
695
752
  <optional>
696
753
  <attribute name="multilingual-rendering">
697
754
  <ref name="MultilingualRenderingType"/>
@@ -851,6 +908,16 @@
851
908
  <ref name="MultilingualRenderingType"/>
852
909
  </attribute>
853
910
  </optional>
911
+ <optional>
912
+ <attribute name="coverpage">
913
+ <data type="boolean"/>
914
+ </attribute>
915
+ </optional>
916
+ <optional>
917
+ <attribute name="notag">
918
+ <data type="boolean"/>
919
+ </attribute>
920
+ </optional>
854
921
  <oneOrMore>
855
922
  <choice>
856
923
  <ref name="paragraph"/>
@@ -1178,6 +1245,7 @@
1178
1245
  <ref name="concept"/>
1179
1246
  <ref name="add"/>
1180
1247
  <ref name="del"/>
1248
+ <ref name="span"/>
1181
1249
  </choice>
1182
1250
  </define>
1183
1251
  <define name="add">
@@ -1204,6 +1272,14 @@
1204
1272
  </choice>
1205
1273
  </element>
1206
1274
  </define>
1275
+ <define name="span">
1276
+ <element name="span">
1277
+ <attribute name="class"/>
1278
+ <oneOrMore>
1279
+ <ref name="TextElement"/>
1280
+ </oneOrMore>
1281
+ </element>
1282
+ </define>
1207
1283
  <define name="concept">
1208
1284
  <element name="concept">
1209
1285
  <optional>
@@ -1994,6 +2070,7 @@
1994
2070
  <value>compare</value>
1995
2071
  <value>contrast</value>
1996
2072
  <value>see</value>
2073
+ <value>seealso</value>
1997
2074
  </choice>
1998
2075
  </define>
1999
2076
  <define name="deprecates">
@@ -45,6 +45,9 @@
45
45
  <ref name="horizontal"/>
46
46
  </optional>
47
47
  <ref name="editorialgroup"/>
48
+ <optional>
49
+ <ref name="approvalgroup"/>
50
+ </optional>
48
51
  <zeroOrMore>
49
52
  <ref name="ics"/>
50
53
  </zeroOrMore>
@@ -249,6 +252,7 @@
249
252
  <value>warning</value>
250
253
  <value>important</value>
251
254
  <value>safety precautions</value>
255
+ <value>editorial</value>
252
256
  </choice>
253
257
  </define>
254
258
  <define name="preface">
@@ -308,18 +312,7 @@
308
312
  </define>
309
313
  <define name="editorialgroup">
310
314
  <element name="editorialgroup">
311
- <oneOrMore>
312
- <ref name="technical-committee"/>
313
- </oneOrMore>
314
- <zeroOrMore>
315
- <ref name="subcommittee"/>
316
- </zeroOrMore>
317
- <zeroOrMore>
318
- <ref name="workgroup"/>
319
- </zeroOrMore>
320
- <optional>
321
- <ref name="secretariat"/>
322
- </optional>
315
+ <ref name="ISOProjectGroup"/>
323
316
  </element>
324
317
  </define>
325
318
  <define name="Content-Section">
@@ -367,6 +360,33 @@
367
360
  </define>
368
361
  </include>
369
362
  <!-- end overrides -->
363
+ <define name="ISOProjectGroup">
364
+ <zeroOrMore>
365
+ <ref name="agency"/>
366
+ </zeroOrMore>
367
+ <oneOrMore>
368
+ <ref name="technical-committee"/>
369
+ </oneOrMore>
370
+ <zeroOrMore>
371
+ <ref name="subcommittee"/>
372
+ </zeroOrMore>
373
+ <zeroOrMore>
374
+ <ref name="workgroup"/>
375
+ </zeroOrMore>
376
+ <optional>
377
+ <ref name="secretariat"/>
378
+ </optional>
379
+ </define>
380
+ <define name="approvalgroup">
381
+ <element name="approvalgroup">
382
+ <ref name="ISOProjectGroup"/>
383
+ </element>
384
+ </define>
385
+ <define name="agency">
386
+ <element name="agency">
387
+ <text/>
388
+ </element>
389
+ </define>
370
390
  <!--
371
391
  We display the Normative References between scope and terms; but to keep the
372
392
  grammar simple, we keep the references together
@@ -3,6 +3,8 @@
3
3
  module RelatonIec
4
4
  # Hit.
5
5
  class Hit < RelatonBib::Hit
6
+ attr_writer :fetch
7
+
6
8
  # Parse page.
7
9
  # @return [RelatonIec::IecBibliographicItem]
8
10
  def fetch
@@ -32,6 +32,7 @@ module RelatonIec
32
32
  parts.reject { |h| h.hit[:code] == hit.hit[:code] }.each do |hi|
33
33
  isobib = RelatonIec::IecBibliographicItem.new(
34
34
  formattedref: RelatonBib::FormattedRef.new(content: hi.hit[:code]),
35
+ docid: [RelatonBib::DocumentIdentifier.new(id: hi.hit[:code], type: "IEC", primary: true)],
35
36
  )
36
37
  all_parts_item.relation << RelatonBib::DocumentRelation.new(type: "partOf", bibitem: isobib)
37
38
  end
@@ -43,13 +44,35 @@ module RelatonIec
43
44
  # @param ref [String]
44
45
  # @param year [String, nil]
45
46
  # @return [Array<RelatonIec::Hit>]
46
- def hits(ref, year)
47
- from, to = nil
48
- if year
49
- from = Date.strptime year, "%Y"
50
- to = from.next_year.prev_day
47
+ def hits(ref, year) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
48
+ if /61360-4\sDB|ISO[\s\/]IEC\sDIR/.match?(ref)
49
+ fetch_from_gh ref
50
+ else
51
+ from, to = nil
52
+ if year
53
+ from = Date.strptime year, "%Y"
54
+ to = from.next_year.prev_day
55
+ end
56
+ get_results ref, from, to
51
57
  end
52
- get_results ref, from, to
58
+ # file = "../data/#{ref.sub(/^IEC\s/, '').gsub(/[\s\/]/, '_').upcase}.yaml"
59
+ # path = File.expand_path file, __dir__
60
+ # if File.exist? path
61
+ # hash = YAML.safe_load File.read(path, encoding: "utf-8")
62
+ # hit = Hit.new({ code: ref }, self)
63
+ # hit.fetch = IecBibliographicItem.from_hash hash
64
+ # return [hit]
65
+ # end
66
+ end
67
+
68
+ def fetch_from_gh(ref)
69
+ file = ref.sub(/^IEC\s/, "").gsub(/[\s\/]/, "_").upcase
70
+ url = "https://raw.githubusercontent.com/relaton/relaton-data-iec/main/data/#{file}.yaml"
71
+ resp = Net::HTTP.get URI(url)
72
+ hash = YAML.safe_load resp
73
+ hit = Hit.new({ code: ref }, self)
74
+ hit.fetch = IecBibliographicItem.from_hash hash
75
+ [hit]
53
76
  end
54
77
 
55
78
  # @param ref [String]
@@ -43,7 +43,7 @@ module RelatonIec
43
43
  # @return [RelatonIsoBib::IecBibliographicItem]
44
44
  def self.from_hash(hash)
45
45
  item_hash = ::RelatonIec::HashConverter.hash_to_bib(hash)
46
- new **item_hash
46
+ new(**item_hash)
47
47
  end
48
48
 
49
49
  # @param opts [Hash]
@@ -52,7 +52,7 @@ module RelatonIec
52
52
  # @option opts [String] :lang language
53
53
  # @return [String] XML
54
54
  def to_xml(**opts) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
55
- super **opts do |b|
55
+ super(**opts) do |b|
56
56
  if opts[:bibdata]
57
57
  b.ext do
58
58
  b.doctype doctype if doctype
@@ -63,16 +63,16 @@ module RelatonIec
63
63
  structuredidentifier&.to_xml b
64
64
  b.stagename stagename if stagename
65
65
  if updates_document_type
66
- b.send("updates-document-type", updates_document_type)
66
+ b.send(:"updates-document-type", updates_document_type)
67
67
  end
68
68
  unless accessibility_color_inside.nil?
69
- b.send("accessibility-color-inside", accessibility_color_inside)
69
+ b.send(:"accessibility-color-inside", accessibility_color_inside)
70
70
  end
71
- b.send("price-code", price_code) if price_code
72
- b.send("cen-processing", cen_processing) unless cen_processing.nil?
71
+ b.send(:"price-code", price_code) if price_code
72
+ b.send(:"cen-processing", cen_processing) unless cen_processing.nil?
73
73
  b.secretary secretary if secretary
74
74
  if interest_to_committees
75
- b.send("interest-to-committees", interest_to_committees)
75
+ b.send(:"interest-to-committees", interest_to_committees)
76
76
  end
77
77
  end
78
78
  end
@@ -58,19 +58,19 @@ module RelatonIec
58
58
  def fetch_ref_err(code, year, missed_years) # rubocop:disable Metrics/MethodLength
59
59
  id = year ? "#{code}:#{year}" : code
60
60
  warn "[relaton-iec] WARNING: no match found online for #{id}. "\
61
- "The code must be exactly like it is on the standards website."
61
+ "The code must be exactly like it is on the standards website."
62
62
  unless missed_years.empty?
63
63
  warn "[relaton-iec] (There was no match for #{year}, though there "\
64
- "were matches found for #{missed_years.join(', ')}.)"
64
+ "were matches found for #{missed_years.join(', ')}.)"
65
65
  end
66
66
  if /\d-\d/.match? code
67
67
  warn "[relaton-iec] The provided document part may not exist, or "\
68
- "the document may no longer be published in parts."
68
+ "the document may no longer be published in parts."
69
69
  else
70
70
  warn "[relaton-iec] If you wanted to cite all document parts for "\
71
- "the reference, use \"#{code} (all parts)\".\nIf the document is "\
72
- "not a standard, use its document type abbreviation (TS, TR, PAS, "\
73
- "Guide)."
71
+ "the reference, use \"#{code} (all parts)\".\nIf the document "\
72
+ "is not a standard, use its document type abbreviation (TS, "\
73
+ "TR, PAS, Guide)."
74
74
  end
75
75
  nil
76
76
  end
@@ -90,33 +90,43 @@ module RelatonIec
90
90
  # @param year [String, nil]
91
91
  # @return [RelatonIec::HitCollection]
92
92
  def search_filter(ref, year) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
93
- %r{
94
- ^(?<code>\S+[^\d]*\s\d+(?:-\w+)*)
95
- (?::(?<year1>\d{4}))?
96
- (?<bundle>\+[^\s/]+)?
97
- (?:/(?<corr>AMD\s\d+))?
98
- }x =~ ref.upcase
99
- year ||= year1
100
- corr&.sub! " ", ""
93
+ rp1 = ref_parts ref.upcase
94
+ year ||= rp1[:year]
95
+ corr = rp1[:corr]&.sub " ", ""
101
96
  warn "[relaton-iec] (\"#{ref}\") fetching..."
102
- result = search(code, year)
103
- if result.empty? && /(?<=-)(?<part>[\w-]+)/ =~ code
97
+ result = search(rp1[:code], year)
98
+ code = result.text.dup
99
+ if result.empty? && /(?<=\d-)(?<part>[\w-]+)/ =~ rp1[:code]
104
100
  # try to search packaged standard
105
- result = search code, year, part
101
+ result = search rp1[:code], year, part
102
+ pkg_std = result.any?
103
+ end
104
+ result = search rp1[:code] if result.empty?
105
+ if pkg_std
106
+ code.sub!(/(?<=\d-)#{part}/, part[0])
107
+ else
108
+ code.sub!(/-[-\d]+/, "")
106
109
  end
107
- result = search code if result.empty?
108
- code = result.text.dup
109
- code&.sub!(/((?:-\w+)+)/, "")
110
110
  result.select do |i|
111
- %r{
112
- ^(?<code2>\S+[^\d]*\s\d+)(?:-\w+)*(?::\d{4})?
113
- (?<bundle2>\+[^\s/]+)?
114
- (?:/(?<corr2>AMD\d+))?
115
- }x =~ i.hit[:code]
116
- code == code2 && bundle == bundle2 && corr == corr2
111
+ rp2 = ref_parts i.hit[:code]
112
+ code2 = if pkg_std
113
+ rp2[:code].sub(/(?<=\d-\d)\d+/, "")
114
+ else
115
+ rp2[:code].sub(/-[-\d]+/, "")
116
+ end
117
+ code == code2 && rp1[:bundle] == rp2[:bundle] && corr == rp2[:corr]
117
118
  end
118
119
  end
119
120
 
121
+ def ref_parts(ref)
122
+ %r{
123
+ ^(?<code>[^\d]+(?:\d+(?:-\w+)*)?(?:\s?[A-Z]+)?(?:\sSUP)?)
124
+ (?::(?<year>\d{4}))?
125
+ (?<bundle>\+[^\s/]+)?
126
+ (?:/(?<corr>AMD\s?\d+))?
127
+ }x.match ref
128
+ end
129
+
120
130
  def iev(code = "IEC 60050")
121
131
  RelatonIsoBib::XMLParser.from_xml(<<~"XML")
122
132
  <bibitem>
@@ -191,8 +201,8 @@ module RelatonIec
191
201
  # @return [Array<String, nil>]
192
202
  def code_year(ref, part)
193
203
  %r{
194
- ^(?<code>\S+[^\d]*\s\d+((?:-\w+)+)?)
195
- (:(?<year>\d{4}))?
204
+ ^(?<code>\S+[^\d]*\s\d+(?:-\w+)*)
205
+ (?::(?<year>\d{4}))?
196
206
  }x =~ ref
197
207
  code.sub!(/-\d+/, "") if part
198
208
  [code, year]
@@ -195,10 +195,12 @@ module RelatonIec
195
195
  when "withdrawn" then "obsoletes"
196
196
  else r_type
197
197
  end
198
- fref = RelatonBib::FormattedRef.new(
199
- content: r.at("FULL_NAME").text, format: "text/plain",
198
+ ref = r.at("FULL_NAME").text
199
+ fref = RelatonBib::FormattedRef.new content: ref, format: "text/plain"
200
+ bibitem = IecBibliographicItem.new(
201
+ formattedref: fref,
202
+ docid: [RelatonBib::DocumentIdentifier.new(id: ref, type: "IEC", primary: true)],
200
203
  )
201
- bibitem = IecBibliographicItem.new(formattedref: fref)
202
204
  { type: type, bibitem: bibitem }
203
205
  end
204
206
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonIec
2
- VERSION = "1.11.2".freeze
2
+ VERSION = "1.12.0".freeze
3
3
  end
data/relaton_iec.gemspec CHANGED
@@ -33,5 +33,5 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "webmock"
34
34
 
35
35
  spec.add_dependency "addressable"
36
- spec.add_dependency "relaton-iso-bib", "~> 1.11.0"
36
+ spec.add_dependency "relaton-iso-bib", "~> 1.12.0"
37
37
  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.11.2
4
+ version: 1.12.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: 2022-04-25 00:00:00.000000000 Z
11
+ date: 2022-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.11.0
145
+ version: 1.12.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.11.0
152
+ version: 1.12.0
153
153
  description: 'RelatonIec: retrieve IEC Standards for bibliographic use using the IecBibliographicItem
154
154
  model'
155
155
  email: