relaton-iec 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.adoc +1 -1
- data/grammars/isodoc.rng +130 -21
- data/grammars/isostandard.rng +1 -1
- data/lib/relaton_iec/iec_bibliography.rb +56 -47
- data/lib/relaton_iec/scrapper.rb +49 -14
- data/lib/relaton_iec/version.rb +1 -1
- data/relaton_iec.gemspec +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 65fa43b33e0cdb77a7d1a5b1676bcd0faba83a9db12e2783f496720293c7ae27
|
|
4
|
+
data.tar.gz: d332ff1d57ba0361de302fda88728d8de4ee6db846113a347b3527487ce41240
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8353ba28d571539340b1a63847775e1fb7aa3024627e1dc4989d5d6f54ca3b4a78d839a7ff402799aa021fec22e9af88c701271a34ac1b0d0ec449590ad51c66
|
|
7
|
+
data.tar.gz: 3dda62a896d79eeed6b64fecca9eb45487d7fd430b9c257b1c9c2f414efda8e420ba018ba1613711559d6daec67cf61215e2c105337d11d2f1b3b7f058909aa6
|
data/README.adoc
CHANGED
|
@@ -31,7 +31,7 @@ Or install it yourself as:
|
|
|
31
31
|
|
|
32
32
|
== Usage
|
|
33
33
|
|
|
34
|
-
Refer to https://github.com/
|
|
34
|
+
Refer to https://github.com/relaton/relaton-iso/blob/master/README.adoc the usage interface is identical.
|
|
35
35
|
|
|
36
36
|
== Development
|
|
37
37
|
|
data/grammars/isodoc.rng
CHANGED
|
@@ -42,8 +42,11 @@
|
|
|
42
42
|
</define>
|
|
43
43
|
<define name="xref">
|
|
44
44
|
<element name="xref">
|
|
45
|
+
<!-- attribute target { xsd:IDREF }, -->
|
|
45
46
|
<attribute name="target">
|
|
46
|
-
<data type="
|
|
47
|
+
<data type="string">
|
|
48
|
+
<param name="pattern">\i\c*|\c+#\c+</param>
|
|
49
|
+
</data>
|
|
47
50
|
</attribute>
|
|
48
51
|
<optional>
|
|
49
52
|
<attribute name="type">
|
|
@@ -61,6 +64,11 @@
|
|
|
61
64
|
</choice>
|
|
62
65
|
</attribute>
|
|
63
66
|
</optional>
|
|
67
|
+
<optional>
|
|
68
|
+
<attribute name="droploc">
|
|
69
|
+
<data type="boolean"/>
|
|
70
|
+
</attribute>
|
|
71
|
+
</optional>
|
|
64
72
|
<text/>
|
|
65
73
|
</element>
|
|
66
74
|
</define>
|
|
@@ -578,6 +586,8 @@
|
|
|
578
586
|
<ref name="ol"/>
|
|
579
587
|
<ref name="dl"/>
|
|
580
588
|
<ref name="formula"/>
|
|
589
|
+
<ref name="quote"/>
|
|
590
|
+
<ref name="sourcecode"/>
|
|
581
591
|
</choice>
|
|
582
592
|
</oneOrMore>
|
|
583
593
|
</element>
|
|
@@ -661,6 +671,16 @@
|
|
|
661
671
|
</choice>
|
|
662
672
|
</attribute>
|
|
663
673
|
</optional>
|
|
674
|
+
<optional>
|
|
675
|
+
<attribute name="valign">
|
|
676
|
+
<choice>
|
|
677
|
+
<value>top</value>
|
|
678
|
+
<value>middle</value>
|
|
679
|
+
<value>bottom</value>
|
|
680
|
+
<value>baseline</value>
|
|
681
|
+
</choice>
|
|
682
|
+
</attribute>
|
|
683
|
+
</optional>
|
|
664
684
|
<choice>
|
|
665
685
|
<zeroOrMore>
|
|
666
686
|
<choice>
|
|
@@ -697,6 +717,16 @@
|
|
|
697
717
|
</choice>
|
|
698
718
|
</attribute>
|
|
699
719
|
</optional>
|
|
720
|
+
<optional>
|
|
721
|
+
<attribute name="valign">
|
|
722
|
+
<choice>
|
|
723
|
+
<value>top</value>
|
|
724
|
+
<value>middle</value>
|
|
725
|
+
<value>bottom</value>
|
|
726
|
+
<value>baseline</value>
|
|
727
|
+
</choice>
|
|
728
|
+
</attribute>
|
|
729
|
+
</optional>
|
|
700
730
|
<choice>
|
|
701
731
|
<zeroOrMore>
|
|
702
732
|
<choice>
|
|
@@ -855,7 +885,7 @@
|
|
|
855
885
|
<oneOrMore>
|
|
856
886
|
<choice>
|
|
857
887
|
<ref name="content"/>
|
|
858
|
-
<ref name="
|
|
888
|
+
<ref name="abstract"/>
|
|
859
889
|
<ref name="foreword"/>
|
|
860
890
|
<ref name="introduction"/>
|
|
861
891
|
<ref name="acknowledgements"/>
|
|
@@ -922,6 +952,9 @@
|
|
|
922
952
|
<optional>
|
|
923
953
|
<attribute name="script"/>
|
|
924
954
|
</optional>
|
|
955
|
+
<optional>
|
|
956
|
+
<attribute name="type"/>
|
|
957
|
+
</optional>
|
|
925
958
|
<optional>
|
|
926
959
|
<attribute name="obligation">
|
|
927
960
|
<choice>
|
|
@@ -961,9 +994,6 @@
|
|
|
961
994
|
</define>
|
|
962
995
|
<define name="content-subsection">
|
|
963
996
|
<element name="clause">
|
|
964
|
-
<optional>
|
|
965
|
-
<attribute name="type"/>
|
|
966
|
-
</optional>
|
|
967
997
|
<ref name="Content-Section"/>
|
|
968
998
|
</element>
|
|
969
999
|
</define>
|
|
@@ -992,6 +1022,9 @@
|
|
|
992
1022
|
</choice>
|
|
993
1023
|
</attribute>
|
|
994
1024
|
</optional>
|
|
1025
|
+
<optional>
|
|
1026
|
+
<attribute name="type"/>
|
|
1027
|
+
</optional>
|
|
995
1028
|
<optional>
|
|
996
1029
|
<ref name="section-title"/>
|
|
997
1030
|
</optional>
|
|
@@ -1011,9 +1044,6 @@
|
|
|
1011
1044
|
</define>
|
|
1012
1045
|
<define name="clause">
|
|
1013
1046
|
<element name="clause">
|
|
1014
|
-
<optional>
|
|
1015
|
-
<attribute name="type"/>
|
|
1016
|
-
</optional>
|
|
1017
1047
|
<ref name="Clause-Section"/>
|
|
1018
1048
|
</element>
|
|
1019
1049
|
</define>
|
|
@@ -1042,18 +1072,24 @@
|
|
|
1042
1072
|
</choice>
|
|
1043
1073
|
</attribute>
|
|
1044
1074
|
</optional>
|
|
1075
|
+
<optional>
|
|
1076
|
+
<attribute name="type"/>
|
|
1077
|
+
</optional>
|
|
1045
1078
|
<optional>
|
|
1046
1079
|
<ref name="section-title"/>
|
|
1047
1080
|
</optional>
|
|
1048
1081
|
<group>
|
|
1049
|
-
<
|
|
1050
|
-
<
|
|
1051
|
-
<
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
<
|
|
1055
|
-
|
|
1056
|
-
|
|
1082
|
+
<choice>
|
|
1083
|
+
<group>
|
|
1084
|
+
<zeroOrMore>
|
|
1085
|
+
<ref name="BasicBlock"/>
|
|
1086
|
+
</zeroOrMore>
|
|
1087
|
+
<zeroOrMore>
|
|
1088
|
+
<ref name="note"/>
|
|
1089
|
+
</zeroOrMore>
|
|
1090
|
+
</group>
|
|
1091
|
+
<ref name="amend"/>
|
|
1092
|
+
</choice>
|
|
1057
1093
|
<zeroOrMore>
|
|
1058
1094
|
<choice>
|
|
1059
1095
|
<ref name="clause-subsection"/>
|
|
@@ -1180,6 +1216,9 @@
|
|
|
1180
1216
|
<optional>
|
|
1181
1217
|
<attribute name="script"/>
|
|
1182
1218
|
</optional>
|
|
1219
|
+
<optional>
|
|
1220
|
+
<attribute name="type"/>
|
|
1221
|
+
</optional>
|
|
1183
1222
|
<optional>
|
|
1184
1223
|
<attribute name="obligation">
|
|
1185
1224
|
<choice>
|
|
@@ -1447,11 +1486,6 @@
|
|
|
1447
1486
|
</optional>
|
|
1448
1487
|
</element>
|
|
1449
1488
|
</define>
|
|
1450
|
-
<define name="preface_abstract">
|
|
1451
|
-
<element name="abstract">
|
|
1452
|
-
<ref name="Basic-Section"/>
|
|
1453
|
-
</element>
|
|
1454
|
-
</define>
|
|
1455
1489
|
<define name="term-clause">
|
|
1456
1490
|
<element name="clause">
|
|
1457
1491
|
<optional>
|
|
@@ -1501,4 +1535,79 @@
|
|
|
1501
1535
|
<ref name="CitationType"/>
|
|
1502
1536
|
</element>
|
|
1503
1537
|
</define>
|
|
1538
|
+
<define name="amend">
|
|
1539
|
+
<element name="amend">
|
|
1540
|
+
<optional>
|
|
1541
|
+
<attribute name="id">
|
|
1542
|
+
<data type="ID"/>
|
|
1543
|
+
</attribute>
|
|
1544
|
+
</optional>
|
|
1545
|
+
<attribute name="change">
|
|
1546
|
+
<choice>
|
|
1547
|
+
<value>add</value>
|
|
1548
|
+
<value>modify</value>
|
|
1549
|
+
<value>delete</value>
|
|
1550
|
+
</choice>
|
|
1551
|
+
</attribute>
|
|
1552
|
+
<optional>
|
|
1553
|
+
<attribute name="path"/>
|
|
1554
|
+
</optional>
|
|
1555
|
+
<optional>
|
|
1556
|
+
<attribute name="path_end"/>
|
|
1557
|
+
</optional>
|
|
1558
|
+
<optional>
|
|
1559
|
+
<attribute name="title"/>
|
|
1560
|
+
</optional>
|
|
1561
|
+
<optional>
|
|
1562
|
+
<element name="location">
|
|
1563
|
+
<zeroOrMore>
|
|
1564
|
+
<ref name="locality"/>
|
|
1565
|
+
</zeroOrMore>
|
|
1566
|
+
</element>
|
|
1567
|
+
</optional>
|
|
1568
|
+
<zeroOrMore>
|
|
1569
|
+
<ref name="autonumber"/>
|
|
1570
|
+
</zeroOrMore>
|
|
1571
|
+
<optional>
|
|
1572
|
+
<element name="description">
|
|
1573
|
+
<zeroOrMore>
|
|
1574
|
+
<ref name="BasicBlock"/>
|
|
1575
|
+
</zeroOrMore>
|
|
1576
|
+
</element>
|
|
1577
|
+
</optional>
|
|
1578
|
+
<optional>
|
|
1579
|
+
<element name="newcontent">
|
|
1580
|
+
<zeroOrMore>
|
|
1581
|
+
<ref name="BasicBlock"/>
|
|
1582
|
+
</zeroOrMore>
|
|
1583
|
+
</element>
|
|
1584
|
+
</optional>
|
|
1585
|
+
<optional>
|
|
1586
|
+
<element name="description">
|
|
1587
|
+
<zeroOrMore>
|
|
1588
|
+
<ref name="BasicBlock"/>
|
|
1589
|
+
</zeroOrMore>
|
|
1590
|
+
</element>
|
|
1591
|
+
</optional>
|
|
1592
|
+
</element>
|
|
1593
|
+
</define>
|
|
1594
|
+
<define name="autonumber">
|
|
1595
|
+
<element name="autonumber">
|
|
1596
|
+
<attribute name="type">
|
|
1597
|
+
<choice>
|
|
1598
|
+
<value>requirement</value>
|
|
1599
|
+
<value>recommendation</value>
|
|
1600
|
+
<value>permission</value>
|
|
1601
|
+
<value>table</value>
|
|
1602
|
+
<value>figure</value>
|
|
1603
|
+
<value>admonition</value>
|
|
1604
|
+
<value>formula</value>
|
|
1605
|
+
<value>sourcecode</value>
|
|
1606
|
+
<value>example</value>
|
|
1607
|
+
<value>note</value>
|
|
1608
|
+
</choice>
|
|
1609
|
+
</attribute>
|
|
1610
|
+
<text/>
|
|
1611
|
+
</element>
|
|
1612
|
+
</define>
|
|
1504
1613
|
</grammar>
|
data/grammars/isostandard.rng
CHANGED
|
@@ -22,7 +22,7 @@ module RelatonIec
|
|
|
22
22
|
# @param opts [Hash] options; restricted to :all_parts if all-parts
|
|
23
23
|
# reference is required
|
|
24
24
|
# @return [String] Relaton XML serialisation of reference
|
|
25
|
-
def get(code, year = nil, opts = {})
|
|
25
|
+
def get(code, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
|
26
26
|
if year.nil?
|
|
27
27
|
/^(?<code1>[^:]+):(?<year1>[^:]+)/ =~ code
|
|
28
28
|
unless code1.nil?
|
|
@@ -45,27 +45,33 @@ module RelatonIec
|
|
|
45
45
|
|
|
46
46
|
private
|
|
47
47
|
|
|
48
|
-
def fetch_ref_err(code, year, missed_years)
|
|
48
|
+
def fetch_ref_err(code, year, missed_years) # rubocop:disable Metrics/MethodLength
|
|
49
49
|
id = year ? "#{code}:#{year}" : code
|
|
50
50
|
warn "[relaton-iec] WARNING: no match found online for #{id}. "\
|
|
51
51
|
"The code must be exactly like it is on the standards website."
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
unless missed_years.empty?
|
|
53
|
+
warn "[relaton-iec] (There was no match for #{year}, though there "\
|
|
54
|
+
"were matches found for #{missed_years.join(', ')}.)"
|
|
55
|
+
end
|
|
56
|
+
if /\d-\d/.match? code
|
|
57
|
+
warn "[relaton-iec] The provided document part may not exist, or "\
|
|
58
|
+
"the document may no longer be published in parts."
|
|
57
59
|
else
|
|
58
|
-
warn "[relaton-iec] If you wanted to cite all document parts for
|
|
59
|
-
"use \"#{code} (all parts)\".\nIf the document is
|
|
60
|
-
"use its document type abbreviation (TS, TR, PAS,
|
|
60
|
+
warn "[relaton-iec] If you wanted to cite all document parts for "\
|
|
61
|
+
"the reference, use \"#{code} (all parts)\".\nIf the document is "\
|
|
62
|
+
"not a standard, use its document type abbreviation (TS, TR, PAS, "\
|
|
63
|
+
"Guide)."
|
|
61
64
|
end
|
|
62
65
|
nil
|
|
63
66
|
end
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
# @param hits [Array<RelatonIec::Hit>]
|
|
69
|
+
# @param threads [Integer]
|
|
70
|
+
# @return [Array<RelatonIec::Hit>]
|
|
71
|
+
def fetch_pages(hits, threads)
|
|
72
|
+
workers = RelatonBib::WorkersPool.new threads
|
|
67
73
|
workers.worker { |w| { i: w[:i], hit: w[:hit].fetch } }
|
|
68
|
-
|
|
74
|
+
hits.each_with_index { |hit, i| workers << { i: i, hit: hit } }
|
|
69
75
|
workers.end
|
|
70
76
|
workers.result.sort_by { |a| a[:i] }.map { |x| x[:hit] }
|
|
71
77
|
end
|
|
@@ -83,45 +89,47 @@ module RelatonIec
|
|
|
83
89
|
end
|
|
84
90
|
|
|
85
91
|
def iev(code = "IEC 60050")
|
|
86
|
-
RelatonIsoBib::XMLParser.from_xml(<<~"
|
|
87
|
-
<bibitem>
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
</bibitem>
|
|
115
|
-
|
|
92
|
+
RelatonIsoBib::XMLParser.from_xml(<<~"XML")
|
|
93
|
+
<bibitem>
|
|
94
|
+
<fetched>#{Date.today}</fetched>
|
|
95
|
+
<title format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary</title>
|
|
96
|
+
<link type="src">http://www.electropedia.org</link>
|
|
97
|
+
<docidentifier>#{code}:2011</docidentifier>
|
|
98
|
+
<date type="published"><on>2011</on></date>
|
|
99
|
+
<contributor>
|
|
100
|
+
<role type="publisher"/>
|
|
101
|
+
<organization>
|
|
102
|
+
<name>International Electrotechnical Commission</name>
|
|
103
|
+
<abbreviation>IEC</abbreviation>
|
|
104
|
+
<uri>www.iec.ch</uri>
|
|
105
|
+
</organization>
|
|
106
|
+
</contributor>
|
|
107
|
+
<language>en</language> <language>fr</language>
|
|
108
|
+
<script>Latn</script>
|
|
109
|
+
<status> <stage>60</stage> </status>
|
|
110
|
+
<copyright>
|
|
111
|
+
<from>2018</from>
|
|
112
|
+
<owner>
|
|
113
|
+
<organization>
|
|
114
|
+
<name>International Electrotechnical Commission</name>
|
|
115
|
+
<abbreviation>IEC</abbreviation>
|
|
116
|
+
<uri>www.iec.ch</uri>
|
|
117
|
+
</organization>
|
|
118
|
+
</owner>
|
|
119
|
+
</copyright>
|
|
120
|
+
</bibitem>
|
|
121
|
+
XML
|
|
116
122
|
end
|
|
117
123
|
|
|
118
124
|
# Sort through the results from Isobib, fetching them three at a time,
|
|
119
125
|
# and return the first result that matches the code,
|
|
120
|
-
# matches the year (if provided), and which
|
|
126
|
+
# matches the year (if provided), and which
|
|
127
|
+
# has a title (amendments do not).
|
|
121
128
|
# Only expects the first page of results to be populated.
|
|
122
129
|
# Does not match corrigenda etc (e.g. ISO 3166-1:2006/Cor 1:2007)
|
|
123
|
-
# If no match, returns any years which caused mismatch, for error
|
|
124
|
-
|
|
130
|
+
# If no match, returns any years which caused mismatch, for error
|
|
131
|
+
# reporting
|
|
132
|
+
def isobib_results_filter(result, year) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
|
|
125
133
|
missed_years = []
|
|
126
134
|
result.each_slice(3) do |s| # ISO website only allows 3 connections
|
|
127
135
|
fetch_pages(s, 3).each_with_index do |r, _i|
|
|
@@ -143,7 +151,8 @@ module RelatonIec
|
|
|
143
151
|
result = isobib_search_filter(code) || return
|
|
144
152
|
ret = isobib_results_filter(result, year)
|
|
145
153
|
if ret[:ret]
|
|
146
|
-
warn "[relaton-iec] (\"#{code}\") found
|
|
154
|
+
warn "[relaton-iec] (\"#{code}\") found "\
|
|
155
|
+
"#{ret[:ret].docidentifier.first.id}"
|
|
147
156
|
ret[:ret]
|
|
148
157
|
else
|
|
149
158
|
fetch_ref_err(code, year, ret[:years])
|
data/lib/relaton_iec/scrapper.rb
CHANGED
|
@@ -29,21 +29,21 @@ module RelatonIec
|
|
|
29
29
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
30
30
|
|
|
31
31
|
# Parse page.
|
|
32
|
-
# @param
|
|
32
|
+
# @param hit_data [Hash]
|
|
33
33
|
# @return [Hash]
|
|
34
34
|
def parse_page(hit_data)
|
|
35
35
|
doc = get_page hit_data[:url]
|
|
36
36
|
|
|
37
37
|
# Fetch edition.
|
|
38
38
|
edition = doc.at(
|
|
39
|
-
"//th[contains(., 'Edition')]/following-sibling::td/span"
|
|
39
|
+
"//th[contains(., 'Edition')]/following-sibling::td/span"
|
|
40
40
|
).text
|
|
41
41
|
|
|
42
42
|
status, relations = fetch_status_relations hit_data[:url]
|
|
43
43
|
|
|
44
44
|
IecBibliographicItem.new(
|
|
45
45
|
fetched: Date.today.to_s,
|
|
46
|
-
docid:
|
|
46
|
+
docid: fetch_docid(hit_data),
|
|
47
47
|
structuredidentifier: fetch_structuredidentifier(doc),
|
|
48
48
|
edition: edition,
|
|
49
49
|
language: ["en"],
|
|
@@ -59,13 +59,48 @@ module RelatonIec
|
|
|
59
59
|
copyright: fetch_copyright(hit_data[:code], doc),
|
|
60
60
|
link: fetch_link(doc, hit_data[:url]),
|
|
61
61
|
relation: relations,
|
|
62
|
-
place: ["Geneva"]
|
|
62
|
+
place: ["Geneva"]
|
|
63
63
|
)
|
|
64
64
|
end
|
|
65
65
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
|
66
66
|
|
|
67
67
|
private
|
|
68
68
|
|
|
69
|
+
# @param hit [Hash]
|
|
70
|
+
# @return [Array<RelatonBib::DocumentIdentifier>]
|
|
71
|
+
def fetch_docid(hit)
|
|
72
|
+
rest = hit[:code].downcase.sub(%r{
|
|
73
|
+
(?<head>[^\s]+)\s
|
|
74
|
+
(?<type>is|ts|tr|pas|srd|guide|tec|wp)?(?(<type>)\s)
|
|
75
|
+
(?<pnum>[\d-]+)\s?
|
|
76
|
+
(?<_dd>:)?(?(<_dd>)(?<date>[\d-]+)\s?)
|
|
77
|
+
}x, "")
|
|
78
|
+
m = $~
|
|
79
|
+
deliv = /cmv|csv|exv|prv|rlv|ser/.match(hit[:code].downcase).to_s
|
|
80
|
+
urn = ["urn", "iec", "std", m[:head].split("/").join("-"), m[:pnum],
|
|
81
|
+
m[:date], m[:type], deliv, "en"]
|
|
82
|
+
urn += fetch_ajunct(rest)
|
|
83
|
+
[
|
|
84
|
+
RelatonBib::DocumentIdentifier.new(id: hit[:code], type: "IEC"),
|
|
85
|
+
RelatonBib::DocumentIdentifier.new(id: urn.join(":"), type: "URN"),
|
|
86
|
+
]
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# @param rest [String]
|
|
90
|
+
# @return [Array<String, nil>]
|
|
91
|
+
def fetch_ajunct(rest)
|
|
92
|
+
r = rest.sub(%r{
|
|
93
|
+
(?<_pl>\+)(?(<_pl>)(?<adjunct>amd)(?<adjnum>\d+)\s?)
|
|
94
|
+
(?<_d2>:)?(?(<_d2>)(?<adjdt>[\d-]+)\s?)
|
|
95
|
+
}x, "")
|
|
96
|
+
m = $~ || {}
|
|
97
|
+
return [] unless m[:adjunct]
|
|
98
|
+
|
|
99
|
+
plus = m[:adjunct] && "plus"
|
|
100
|
+
urn = [plus, m[:adjunct], m[:adjnum], m[:adjdt]]
|
|
101
|
+
urn + fetch_ajunct(r)
|
|
102
|
+
end
|
|
103
|
+
|
|
69
104
|
# Fetch abstracts.
|
|
70
105
|
# @param doc [Nokigiri::HTML::Document]
|
|
71
106
|
# @return [Array<Array>]
|
|
@@ -111,12 +146,12 @@ module RelatonIec
|
|
|
111
146
|
item_ref = doc.at("//span[@itemprop='productID']")
|
|
112
147
|
unless item_ref
|
|
113
148
|
return RelatonIsoBib::StructuredIdentifier.new(
|
|
114
|
-
project_number: "?", part_number: "", prefix: nil, id: "?"
|
|
149
|
+
project_number: "?", part_number: "", prefix: nil, id: "?"
|
|
115
150
|
)
|
|
116
151
|
end
|
|
117
152
|
|
|
118
153
|
m = item_ref.text.match(
|
|
119
|
-
/(?<=\s)(?<project>\d+)-?(?<part>(?<=-)\d+|)-?(?<subpart>(?<=-)\d+|)
|
|
154
|
+
/(?<=\s)(?<project>\d+)-?(?<part>(?<=-)\d+|)-?(?<subpart>(?<=-)\d+|)/
|
|
120
155
|
)
|
|
121
156
|
RelatonIsoBib::StructuredIdentifier.new(
|
|
122
157
|
project_number: m[:project],
|
|
@@ -124,7 +159,7 @@ module RelatonIec
|
|
|
124
159
|
subpart_number: m[:subpart],
|
|
125
160
|
prefix: nil,
|
|
126
161
|
type: "IEC",
|
|
127
|
-
id: item_ref.text
|
|
162
|
+
id: item_ref.text
|
|
128
163
|
)
|
|
129
164
|
end
|
|
130
165
|
|
|
@@ -168,8 +203,8 @@ module RelatonIec
|
|
|
168
203
|
# @return [Array<Hash>]
|
|
169
204
|
# rubocop:disable Metrics/MethodLength
|
|
170
205
|
def fetch_relations(doc)
|
|
171
|
-
doc.xpath('//ROW[STATUS[.!="PREPARING"]][STATUS[.!="PUBLISHED"]]')
|
|
172
|
-
map do |r|
|
|
206
|
+
doc.xpath('//ROW[STATUS[.!="PREPARING"]][STATUS[.!="PUBLISHED"]]')
|
|
207
|
+
.map do |r|
|
|
173
208
|
r_type = r.at("STATUS").text.downcase
|
|
174
209
|
type = case r_type
|
|
175
210
|
# when 'published' then 'obsoletes' # Valid
|
|
@@ -178,7 +213,7 @@ module RelatonIec
|
|
|
178
213
|
else r_type
|
|
179
214
|
end
|
|
180
215
|
fref = RelatonBib::FormattedRef.new(
|
|
181
|
-
content: r.at("FULL_NAME").text, format: "text/plain"
|
|
216
|
+
content: r.at("FULL_NAME").text, format: "text/plain"
|
|
182
217
|
)
|
|
183
218
|
bibitem = IecBibliographicItem.new(formattedref: fref)
|
|
184
219
|
{ type: type, bibitem: bibitem }
|
|
@@ -203,7 +238,7 @@ module RelatonIec
|
|
|
203
238
|
# @return [String]
|
|
204
239
|
def fetch_type(doc)
|
|
205
240
|
doc.at(
|
|
206
|
-
'//th[contains(., "Publication type")]/following-sibling::td/span'
|
|
241
|
+
'//th[contains(., "Publication type")]/following-sibling::td/span'
|
|
207
242
|
).text.downcase.tr " ", "-"
|
|
208
243
|
end
|
|
209
244
|
|
|
@@ -249,7 +284,7 @@ module RelatonIec
|
|
|
249
284
|
# @return [Array<Hash>]
|
|
250
285
|
def fetch_ics(doc)
|
|
251
286
|
doc.xpath(
|
|
252
|
-
'//th[contains(text(), "ICS")]/following-sibling::td/a'
|
|
287
|
+
'//th[contains(text(), "ICS")]/following-sibling::td/a'
|
|
253
288
|
).map do |i|
|
|
254
289
|
code = i.text.match(/[\d\.]+/).to_s.split "."
|
|
255
290
|
{ field: code[0], group: code[1], subgroup: code[2] }
|
|
@@ -281,8 +316,8 @@ module RelatonIec
|
|
|
281
316
|
end
|
|
282
317
|
from = code.match(/(?<=:)\d{4}/).to_s
|
|
283
318
|
if from.empty?
|
|
284
|
-
from = doc.xpath("//span[@itemprop='releaseDate']").text
|
|
285
|
-
match(/\d{4}/).to_s
|
|
319
|
+
from = doc.xpath("//span[@itemprop='releaseDate']").text
|
|
320
|
+
.match(/\d{4}/).to_s
|
|
286
321
|
end
|
|
287
322
|
[{
|
|
288
323
|
owner: [{ name: name, abbreviation: abbreviation, url: url }],
|
data/lib/relaton_iec/version.rb
CHANGED
data/relaton_iec.gemspec
CHANGED
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.
|
|
4
|
+
version: 1.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-09-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: debase
|
|
@@ -170,14 +170,14 @@ dependencies:
|
|
|
170
170
|
requirements:
|
|
171
171
|
- - "~>"
|
|
172
172
|
- !ruby/object:Gem::Version
|
|
173
|
-
version: 1.
|
|
173
|
+
version: 1.4.0
|
|
174
174
|
type: :runtime
|
|
175
175
|
prerelease: false
|
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
|
177
177
|
requirements:
|
|
178
178
|
- - "~>"
|
|
179
179
|
- !ruby/object:Gem::Version
|
|
180
|
-
version: 1.
|
|
180
|
+
version: 1.4.0
|
|
181
181
|
description: 'RelatonIec: retrieve IEC Standards for bibliographic use using the IecBibliographicItem
|
|
182
182
|
model'
|
|
183
183
|
email:
|
|
@@ -220,7 +220,7 @@ homepage: https://github.com/metanorma/relaton-iec
|
|
|
220
220
|
licenses:
|
|
221
221
|
- MIT
|
|
222
222
|
metadata: {}
|
|
223
|
-
post_install_message:
|
|
223
|
+
post_install_message:
|
|
224
224
|
rdoc_options: []
|
|
225
225
|
require_paths:
|
|
226
226
|
- lib
|
|
@@ -236,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
236
236
|
version: '0'
|
|
237
237
|
requirements: []
|
|
238
238
|
rubygems_version: 3.0.6
|
|
239
|
-
signing_key:
|
|
239
|
+
signing_key:
|
|
240
240
|
specification_version: 4
|
|
241
241
|
summary: 'RelatonIec: retrieve IEC Standards for bibliographic use using the IecBibliographicItem
|
|
242
242
|
model'
|