relaton-nist 1.2.2 → 1.5.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/.github/workflows/ubuntu.yml +1 -0
- data/.rubocop.yml +2 -2
- data/README.adoc +9 -11
- data/grammars/isodoc.rng +136 -21
- data/grammars/nist.rng +26 -1
- data/lib/relaton_nist/comment_period.rb +11 -0
- data/lib/relaton_nist/hit_collection.rb +15 -12
- data/lib/relaton_nist/nist_bibliographic_item.rb +15 -4
- data/lib/relaton_nist/nist_bibliography.rb +1 -1
- data/lib/relaton_nist/scrapper.rb +5 -4
- data/lib/relaton_nist/version.rb +1 -1
- data/lib/relaton_nist/xml_parser.rb +11 -22
- data/relaton_nist.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: 6a289e3e9ea82fa2bd9ccc8a770574054fa95c1ead667c508944b9cd28507b47
|
|
4
|
+
data.tar.gz: ece039c83b057aacae628bfcdb6d3312944e2e22df23d8af8234808ebfbd082b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b4fb49e7c73127775ab613df4bc1f14e1e5cb9a011c8ba22894eba13db53508f53ceef9d50ee91423785614e1cb43a07c312a2c10f8a145690813cb9a8122832
|
|
7
|
+
data.tar.gz: 931f8ee54eb49df1ee295073b5f8ef0199554e4dda68174d8d0cdb4fc043caca9f22989e0a7ec7095b202bd70bb0d60708a2717d89b3310de1d62d788570cefc
|
data/.rubocop.yml
CHANGED
data/README.adoc
CHANGED
|
@@ -39,11 +39,10 @@ Or install it yourself as:
|
|
|
39
39
|
require 'relaton_nist'
|
|
40
40
|
|
|
41
41
|
hit_collection = RelatonNist::NistBibliography.search("8200")
|
|
42
|
-
=>
|
|
43
|
-
<RelatonNist::Hit:0x007f82b9b2a1e0 @text="8200" @fetched="false" @fullIdentifier="" @title="8200">]
|
|
42
|
+
=> <RelatonNist::HitCollection:0x007fc069d19da0 @ref=8200 @fetched=false>
|
|
44
43
|
|
|
45
44
|
item = hit_collection[1].fetch
|
|
46
|
-
|
|
45
|
+
=> #<RelatonNist::NistBibliographicItem:0x007fc049aa6778
|
|
47
46
|
...
|
|
48
47
|
----
|
|
49
48
|
|
|
@@ -71,9 +70,6 @@ item.to_xml bibdata: true
|
|
|
71
70
|
...
|
|
72
71
|
<ext>
|
|
73
72
|
<doctype>stadard</doctype>
|
|
74
|
-
<keyword>cybersecurity</keyword>
|
|
75
|
-
<keyword>cybersecurity objectives</keyword>
|
|
76
|
-
...
|
|
77
73
|
<commentperiod>
|
|
78
74
|
<from>2018-02-01</from>
|
|
79
75
|
<to>2018-04-18</to>
|
|
@@ -86,8 +82,9 @@ item.to_xml bibdata: true
|
|
|
86
82
|
[source,ruby]
|
|
87
83
|
----
|
|
88
84
|
RelatonNist::NistBibliography.get("8200", "2018", {})
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
[relaton-nist] ("8200") fetching...
|
|
86
|
+
[relaton-nist] ("8200") found NISTIR 8200
|
|
87
|
+
=> #<RelatonNist::NistBibliographicItem:0x007fc06aa2b480
|
|
91
88
|
...
|
|
92
89
|
----
|
|
93
90
|
|
|
@@ -110,9 +107,10 @@ NIST FIPS {docnumber}
|
|
|
110
107
|
----
|
|
111
108
|
[source,ruby]
|
|
112
109
|
----
|
|
113
|
-
RelatonNist::NistBibliography.get("
|
|
114
|
-
fetching
|
|
115
|
-
|
|
110
|
+
RelatonNist::NistBibliography.get("SP 800-205 (February 2019) (PD)")
|
|
111
|
+
[relaton-nist] ("SP 800-205") fetching...
|
|
112
|
+
[relaton-nist] ("SP 800-205") found SP 800-205 (Draft)
|
|
113
|
+
=> #<RelatonNist::NistBibliographicItem:0x007fc059934768
|
|
116
114
|
...
|
|
117
115
|
----
|
|
118
116
|
|
data/grammars/isodoc.rng
CHANGED
|
@@ -43,7 +43,9 @@
|
|
|
43
43
|
<define name="xref">
|
|
44
44
|
<element name="xref">
|
|
45
45
|
<attribute name="target">
|
|
46
|
-
<data type="
|
|
46
|
+
<data type="string">
|
|
47
|
+
<param name="pattern">\i\c*|\c+#\c+</param>
|
|
48
|
+
</data>
|
|
47
49
|
</attribute>
|
|
48
50
|
<optional>
|
|
49
51
|
<attribute name="type">
|
|
@@ -61,6 +63,11 @@
|
|
|
61
63
|
</choice>
|
|
62
64
|
</attribute>
|
|
63
65
|
</optional>
|
|
66
|
+
<optional>
|
|
67
|
+
<attribute name="droploc">
|
|
68
|
+
<data type="boolean"/>
|
|
69
|
+
</attribute>
|
|
70
|
+
</optional>
|
|
64
71
|
<text/>
|
|
65
72
|
</element>
|
|
66
73
|
</define>
|
|
@@ -578,6 +585,8 @@
|
|
|
578
585
|
<ref name="ol"/>
|
|
579
586
|
<ref name="dl"/>
|
|
580
587
|
<ref name="formula"/>
|
|
588
|
+
<ref name="quote"/>
|
|
589
|
+
<ref name="sourcecode"/>
|
|
581
590
|
</choice>
|
|
582
591
|
</oneOrMore>
|
|
583
592
|
</element>
|
|
@@ -661,6 +670,16 @@
|
|
|
661
670
|
</choice>
|
|
662
671
|
</attribute>
|
|
663
672
|
</optional>
|
|
673
|
+
<optional>
|
|
674
|
+
<attribute name="valign">
|
|
675
|
+
<choice>
|
|
676
|
+
<value>top</value>
|
|
677
|
+
<value>middle</value>
|
|
678
|
+
<value>bottom</value>
|
|
679
|
+
<value>baseline</value>
|
|
680
|
+
</choice>
|
|
681
|
+
</attribute>
|
|
682
|
+
</optional>
|
|
664
683
|
<choice>
|
|
665
684
|
<zeroOrMore>
|
|
666
685
|
<choice>
|
|
@@ -697,6 +716,16 @@
|
|
|
697
716
|
</choice>
|
|
698
717
|
</attribute>
|
|
699
718
|
</optional>
|
|
719
|
+
<optional>
|
|
720
|
+
<attribute name="valign">
|
|
721
|
+
<choice>
|
|
722
|
+
<value>top</value>
|
|
723
|
+
<value>middle</value>
|
|
724
|
+
<value>bottom</value>
|
|
725
|
+
<value>baseline</value>
|
|
726
|
+
</choice>
|
|
727
|
+
</attribute>
|
|
728
|
+
</optional>
|
|
700
729
|
<choice>
|
|
701
730
|
<zeroOrMore>
|
|
702
731
|
<choice>
|
|
@@ -834,6 +863,13 @@
|
|
|
834
863
|
</define>
|
|
835
864
|
<define name="standard-document">
|
|
836
865
|
<element name="standard-document">
|
|
866
|
+
<attribute name="version"/>
|
|
867
|
+
<attribute name="type">
|
|
868
|
+
<choice>
|
|
869
|
+
<value>semantic</value>
|
|
870
|
+
<value>presentation</value>
|
|
871
|
+
</choice>
|
|
872
|
+
</attribute>
|
|
837
873
|
<ref name="bibdata"/>
|
|
838
874
|
<optional>
|
|
839
875
|
<ref name="boilerplate"/>
|
|
@@ -855,7 +891,7 @@
|
|
|
855
891
|
<oneOrMore>
|
|
856
892
|
<choice>
|
|
857
893
|
<ref name="content"/>
|
|
858
|
-
<ref name="
|
|
894
|
+
<ref name="abstract"/>
|
|
859
895
|
<ref name="foreword"/>
|
|
860
896
|
<ref name="introduction"/>
|
|
861
897
|
<ref name="acknowledgements"/>
|
|
@@ -922,6 +958,9 @@
|
|
|
922
958
|
<optional>
|
|
923
959
|
<attribute name="script"/>
|
|
924
960
|
</optional>
|
|
961
|
+
<optional>
|
|
962
|
+
<attribute name="type"/>
|
|
963
|
+
</optional>
|
|
925
964
|
<optional>
|
|
926
965
|
<attribute name="obligation">
|
|
927
966
|
<choice>
|
|
@@ -961,9 +1000,6 @@
|
|
|
961
1000
|
</define>
|
|
962
1001
|
<define name="content-subsection">
|
|
963
1002
|
<element name="clause">
|
|
964
|
-
<optional>
|
|
965
|
-
<attribute name="type"/>
|
|
966
|
-
</optional>
|
|
967
1003
|
<ref name="Content-Section"/>
|
|
968
1004
|
</element>
|
|
969
1005
|
</define>
|
|
@@ -992,6 +1028,9 @@
|
|
|
992
1028
|
</choice>
|
|
993
1029
|
</attribute>
|
|
994
1030
|
</optional>
|
|
1031
|
+
<optional>
|
|
1032
|
+
<attribute name="type"/>
|
|
1033
|
+
</optional>
|
|
995
1034
|
<optional>
|
|
996
1035
|
<ref name="section-title"/>
|
|
997
1036
|
</optional>
|
|
@@ -1011,9 +1050,6 @@
|
|
|
1011
1050
|
</define>
|
|
1012
1051
|
<define name="clause">
|
|
1013
1052
|
<element name="clause">
|
|
1014
|
-
<optional>
|
|
1015
|
-
<attribute name="type"/>
|
|
1016
|
-
</optional>
|
|
1017
1053
|
<ref name="Clause-Section"/>
|
|
1018
1054
|
</element>
|
|
1019
1055
|
</define>
|
|
@@ -1042,18 +1078,24 @@
|
|
|
1042
1078
|
</choice>
|
|
1043
1079
|
</attribute>
|
|
1044
1080
|
</optional>
|
|
1081
|
+
<optional>
|
|
1082
|
+
<attribute name="type"/>
|
|
1083
|
+
</optional>
|
|
1045
1084
|
<optional>
|
|
1046
1085
|
<ref name="section-title"/>
|
|
1047
1086
|
</optional>
|
|
1048
1087
|
<group>
|
|
1049
|
-
<
|
|
1050
|
-
<
|
|
1051
|
-
<
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
<
|
|
1055
|
-
|
|
1056
|
-
|
|
1088
|
+
<choice>
|
|
1089
|
+
<group>
|
|
1090
|
+
<zeroOrMore>
|
|
1091
|
+
<ref name="BasicBlock"/>
|
|
1092
|
+
</zeroOrMore>
|
|
1093
|
+
<zeroOrMore>
|
|
1094
|
+
<ref name="note"/>
|
|
1095
|
+
</zeroOrMore>
|
|
1096
|
+
</group>
|
|
1097
|
+
<ref name="amend"/>
|
|
1098
|
+
</choice>
|
|
1057
1099
|
<zeroOrMore>
|
|
1058
1100
|
<choice>
|
|
1059
1101
|
<ref name="clause-subsection"/>
|
|
@@ -1180,6 +1222,9 @@
|
|
|
1180
1222
|
<optional>
|
|
1181
1223
|
<attribute name="script"/>
|
|
1182
1224
|
</optional>
|
|
1225
|
+
<optional>
|
|
1226
|
+
<attribute name="type"/>
|
|
1227
|
+
</optional>
|
|
1183
1228
|
<optional>
|
|
1184
1229
|
<attribute name="obligation">
|
|
1185
1230
|
<choice>
|
|
@@ -1447,11 +1492,6 @@
|
|
|
1447
1492
|
</optional>
|
|
1448
1493
|
</element>
|
|
1449
1494
|
</define>
|
|
1450
|
-
<define name="preface_abstract">
|
|
1451
|
-
<element name="abstract">
|
|
1452
|
-
<ref name="Basic-Section"/>
|
|
1453
|
-
</element>
|
|
1454
|
-
</define>
|
|
1455
1495
|
<define name="term-clause">
|
|
1456
1496
|
<element name="clause">
|
|
1457
1497
|
<optional>
|
|
@@ -1501,4 +1541,79 @@
|
|
|
1501
1541
|
<ref name="CitationType"/>
|
|
1502
1542
|
</element>
|
|
1503
1543
|
</define>
|
|
1544
|
+
<define name="amend">
|
|
1545
|
+
<element name="amend">
|
|
1546
|
+
<optional>
|
|
1547
|
+
<attribute name="id">
|
|
1548
|
+
<data type="ID"/>
|
|
1549
|
+
</attribute>
|
|
1550
|
+
</optional>
|
|
1551
|
+
<attribute name="change">
|
|
1552
|
+
<choice>
|
|
1553
|
+
<value>add</value>
|
|
1554
|
+
<value>modify</value>
|
|
1555
|
+
<value>delete</value>
|
|
1556
|
+
</choice>
|
|
1557
|
+
</attribute>
|
|
1558
|
+
<optional>
|
|
1559
|
+
<attribute name="path"/>
|
|
1560
|
+
</optional>
|
|
1561
|
+
<optional>
|
|
1562
|
+
<attribute name="path_end"/>
|
|
1563
|
+
</optional>
|
|
1564
|
+
<optional>
|
|
1565
|
+
<attribute name="title"/>
|
|
1566
|
+
</optional>
|
|
1567
|
+
<optional>
|
|
1568
|
+
<element name="location">
|
|
1569
|
+
<zeroOrMore>
|
|
1570
|
+
<ref name="locality"/>
|
|
1571
|
+
</zeroOrMore>
|
|
1572
|
+
</element>
|
|
1573
|
+
</optional>
|
|
1574
|
+
<zeroOrMore>
|
|
1575
|
+
<ref name="autonumber"/>
|
|
1576
|
+
</zeroOrMore>
|
|
1577
|
+
<optional>
|
|
1578
|
+
<element name="description">
|
|
1579
|
+
<zeroOrMore>
|
|
1580
|
+
<ref name="BasicBlock"/>
|
|
1581
|
+
</zeroOrMore>
|
|
1582
|
+
</element>
|
|
1583
|
+
</optional>
|
|
1584
|
+
<optional>
|
|
1585
|
+
<element name="newcontent">
|
|
1586
|
+
<zeroOrMore>
|
|
1587
|
+
<ref name="BasicBlock"/>
|
|
1588
|
+
</zeroOrMore>
|
|
1589
|
+
</element>
|
|
1590
|
+
</optional>
|
|
1591
|
+
<optional>
|
|
1592
|
+
<element name="description">
|
|
1593
|
+
<zeroOrMore>
|
|
1594
|
+
<ref name="BasicBlock"/>
|
|
1595
|
+
</zeroOrMore>
|
|
1596
|
+
</element>
|
|
1597
|
+
</optional>
|
|
1598
|
+
</element>
|
|
1599
|
+
</define>
|
|
1600
|
+
<define name="autonumber">
|
|
1601
|
+
<element name="autonumber">
|
|
1602
|
+
<attribute name="type">
|
|
1603
|
+
<choice>
|
|
1604
|
+
<value>requirement</value>
|
|
1605
|
+
<value>recommendation</value>
|
|
1606
|
+
<value>permission</value>
|
|
1607
|
+
<value>table</value>
|
|
1608
|
+
<value>figure</value>
|
|
1609
|
+
<value>admonition</value>
|
|
1610
|
+
<value>formula</value>
|
|
1611
|
+
<value>sourcecode</value>
|
|
1612
|
+
<value>example</value>
|
|
1613
|
+
<value>note</value>
|
|
1614
|
+
</choice>
|
|
1615
|
+
</attribute>
|
|
1616
|
+
<text/>
|
|
1617
|
+
</element>
|
|
1618
|
+
</define>
|
|
1504
1619
|
</grammar>
|
data/grammars/nist.rng
CHANGED
|
@@ -9,6 +9,24 @@
|
|
|
9
9
|
<start>
|
|
10
10
|
<ref name="nist-standard"/>
|
|
11
11
|
</start>
|
|
12
|
+
<define name="ol">
|
|
13
|
+
<element name="ol">
|
|
14
|
+
<attribute name="id">
|
|
15
|
+
<data type="ID"/>
|
|
16
|
+
</attribute>
|
|
17
|
+
<optional>
|
|
18
|
+
<attribute name="class">
|
|
19
|
+
<value>steps</value>
|
|
20
|
+
</attribute>
|
|
21
|
+
</optional>
|
|
22
|
+
<oneOrMore>
|
|
23
|
+
<ref name="li"/>
|
|
24
|
+
</oneOrMore>
|
|
25
|
+
<zeroOrMore>
|
|
26
|
+
<ref name="note"/>
|
|
27
|
+
</zeroOrMore>
|
|
28
|
+
</element>
|
|
29
|
+
</define>
|
|
12
30
|
<define name="DocumentType">
|
|
13
31
|
<value>standard</value>
|
|
14
32
|
</define>
|
|
@@ -16,7 +34,7 @@
|
|
|
16
34
|
<define name="preface">
|
|
17
35
|
<element name="preface">
|
|
18
36
|
<optional>
|
|
19
|
-
<ref name="
|
|
37
|
+
<ref name="abstract"/>
|
|
20
38
|
</optional>
|
|
21
39
|
<optional>
|
|
22
40
|
<ref name="foreword"/>
|
|
@@ -164,6 +182,13 @@
|
|
|
164
182
|
</define>
|
|
165
183
|
<define name="nist-standard">
|
|
166
184
|
<element name="nist-standard">
|
|
185
|
+
<attribute name="version"/>
|
|
186
|
+
<attribute name="type">
|
|
187
|
+
<choice>
|
|
188
|
+
<value>semantic</value>
|
|
189
|
+
<value>presentation</value>
|
|
190
|
+
</choice>
|
|
191
|
+
</attribute>
|
|
167
192
|
<ref name="bibdata"/>
|
|
168
193
|
<zeroOrMore>
|
|
169
194
|
<ref name="termdocsource"/>
|
|
@@ -34,5 +34,16 @@ module RelatonNist
|
|
|
34
34
|
hash["extended"] = extended.to_s if extended
|
|
35
35
|
hash
|
|
36
36
|
end
|
|
37
|
+
|
|
38
|
+
# @param prefix [String]
|
|
39
|
+
# @return [String]
|
|
40
|
+
def to_asciibib(prefix)
|
|
41
|
+
pref = prefix.empty? ? prefix : prefix + "."
|
|
42
|
+
pref += "commentperiod"
|
|
43
|
+
out = "#{pref}.from:: #{from}\n"
|
|
44
|
+
out += "#{pref}.to:: #{to}\n" if to
|
|
45
|
+
out += "#{pref}.extended:: #{extended}\n" if extended
|
|
46
|
+
out
|
|
47
|
+
end
|
|
37
48
|
end
|
|
38
49
|
end
|
|
@@ -17,10 +17,10 @@ module RelatonNist
|
|
|
17
17
|
# @param year [String]
|
|
18
18
|
# @param opts [Hash]
|
|
19
19
|
# @option opts [String] :stage
|
|
20
|
-
def initialize(ref_nbr, year = nil, opts = {})
|
|
20
|
+
def initialize(ref_nbr, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize
|
|
21
21
|
super ref_nbr, year
|
|
22
22
|
|
|
23
|
-
/(?<docid>(SP|FIPS)\s[0-9-]
|
|
23
|
+
/(?<docid>(SP|FIPS)\s[0-9-]+\w?)/ =~ text
|
|
24
24
|
@array = docid ? from_json(docid, **opts) : from_csrc(**opts)
|
|
25
25
|
|
|
26
26
|
@array.sort! do |a, b|
|
|
@@ -45,28 +45,28 @@ module RelatonNist
|
|
|
45
45
|
from = d.strftime "%m/%d/%Y"
|
|
46
46
|
to = d.next_year.prev_day.strftime "%m/%d/%Y"
|
|
47
47
|
end
|
|
48
|
-
url
|
|
48
|
+
url = "#{DOMAIN}/publications/search?keywords-lg=#{text}"
|
|
49
49
|
url += "&dateFrom-lg=#{from}" if from
|
|
50
50
|
url += "&dateTo-lg=#{to}" if to
|
|
51
|
-
url += if /PD
|
|
51
|
+
url += if /PD/.match? opts[:stage]
|
|
52
52
|
"&status-lg=Draft,Retired Draft,Withdrawn"
|
|
53
53
|
else
|
|
54
54
|
"&status-lg=Final,Withdrawn"
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
doc
|
|
57
|
+
doc = Nokogiri::HTML OpenURI.open_uri(::Addressable::URI.parse(url).normalize)
|
|
58
58
|
doc.css("table.publications-table > tbody > tr").map do |h|
|
|
59
59
|
link = h.at("td/div/strong/a")
|
|
60
60
|
serie = h.at("td[1]").text.strip
|
|
61
61
|
code = h.at("td[2]").text.strip
|
|
62
62
|
title = link.text
|
|
63
|
-
doc_url
|
|
63
|
+
doc_url = DOMAIN + link[:href]
|
|
64
64
|
status = h.at("td[4]").text.strip.downcase
|
|
65
65
|
release_date = Date.strptime h.at("td[5]").text.strip, "%m/%d/%Y"
|
|
66
66
|
Hit.new(
|
|
67
67
|
{
|
|
68
|
-
code: code, serie: serie, title: title, url: doc_url,
|
|
69
|
-
release_date: release_date
|
|
68
|
+
code: code, serie: serie, title: title, url: doc_url,
|
|
69
|
+
status: status, release_date: release_date
|
|
70
70
|
}, self
|
|
71
71
|
)
|
|
72
72
|
end
|
|
@@ -91,17 +91,18 @@ module RelatonNist
|
|
|
91
91
|
# @param docid [String]
|
|
92
92
|
# @param stage [String]
|
|
93
93
|
# @return [Array<Hach>]
|
|
94
|
-
def select_data(docid, **opts)
|
|
94
|
+
def select_data(docid, **opts) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength,Metrics/PerceivedComplexity
|
|
95
95
|
d = Date.strptime year, "%Y" if year
|
|
96
|
+
didrx = Regexp.new(docid)
|
|
96
97
|
data.select do |doc|
|
|
97
98
|
next unless match_year?(doc, d)
|
|
98
99
|
|
|
99
|
-
if /PD
|
|
100
|
+
if /PD/.match? opts[:stage]
|
|
100
101
|
next unless %w[draft-public draft-prelim].include? doc["status"]
|
|
101
102
|
else
|
|
102
103
|
next unless doc["status"] == "final"
|
|
103
104
|
end
|
|
104
|
-
doc["docidentifier"] =~
|
|
105
|
+
doc["docidentifier"] =~ didrx
|
|
105
106
|
end
|
|
106
107
|
end
|
|
107
108
|
|
|
@@ -129,7 +130,9 @@ module RelatonNist
|
|
|
129
130
|
#
|
|
130
131
|
# @prarm ctime [Time, NilClass]
|
|
131
132
|
def fetch_data(ctime)
|
|
132
|
-
resp = OpenURI.open_uri(
|
|
133
|
+
resp = OpenURI.open_uri(
|
|
134
|
+
"https://csrc.nist.gov/CSRC/media/feeds/metanorma/pubs-export.meta"
|
|
135
|
+
)
|
|
133
136
|
if !ctime || ctime < resp.last_modified
|
|
134
137
|
@data = nil
|
|
135
138
|
zip = OpenURI.open_uri "https://csrc.nist.gov/CSRC/media/feeds/metanorma/pubs-export.zip"
|
|
@@ -63,13 +63,16 @@ module RelatonNist
|
|
|
63
63
|
super
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
# @param
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
# @param opts [Hash]
|
|
67
|
+
# @option opts [Nokogiri::XML::Builder] :builder XML builder
|
|
68
|
+
# @option opts [Boolean] :bibdata
|
|
69
|
+
# @option opts [String] :lang language
|
|
70
|
+
# @return [String] XML
|
|
71
|
+
def to_xml(**opts)
|
|
72
|
+
super date_format: :short, **opts do |b|
|
|
69
73
|
if opts[:bibdata]
|
|
70
74
|
b.ext do
|
|
71
75
|
b.doctype doctype if doctype
|
|
72
|
-
# keyword.each { |kw| b.keyword { kw.to_xml b } }
|
|
73
76
|
commentperiod&.to_xml b
|
|
74
77
|
end
|
|
75
78
|
end
|
|
@@ -83,5 +86,13 @@ module RelatonNist
|
|
|
83
86
|
hash["commentperiod"] = commentperiod.to_hash if commentperiod
|
|
84
87
|
hash
|
|
85
88
|
end
|
|
89
|
+
|
|
90
|
+
# @param prefix [String]
|
|
91
|
+
# @return [String]
|
|
92
|
+
def to_asciibib(prefix = "")
|
|
93
|
+
out = super
|
|
94
|
+
out += commentperiod.to_asciibib prefix if commentperiod
|
|
95
|
+
out
|
|
96
|
+
end
|
|
86
97
|
end
|
|
87
98
|
end
|
|
@@ -121,7 +121,7 @@ module RelatonNist
|
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
def nistbib_search_filter(code, year, opts)
|
|
124
|
-
idregex = %r{[0-9-]{3,}}
|
|
124
|
+
idregex = %r{[0-9-]{3,}\w?}
|
|
125
125
|
docid = code.match(idregex).to_s
|
|
126
126
|
serie = code.match(%r{(FISP|SP|NISTIR)(?=\s)})
|
|
127
127
|
warn "[relaton-nist] (\"#{code}\") fetching..."
|
|
@@ -18,10 +18,10 @@ module RelatonNist
|
|
|
18
18
|
end
|
|
19
19
|
# doctype = "standard"
|
|
20
20
|
titles = fetch_titles(hit_data)
|
|
21
|
-
unless /^(SP|NISTIR|FIPS)
|
|
21
|
+
unless /^(SP|NISTIR|FIPS) /.match? item_data[:docid][0].id
|
|
22
22
|
# doctype = id_cleanup(item_data[:docid][0].id)
|
|
23
23
|
item_data[:docid][0] = RelatonBib::DocumentIdentifier.new(
|
|
24
|
-
id: titles[0][:content].upcase, type: "NIST"
|
|
24
|
+
id: titles[0][:content].upcase, type: "NIST"
|
|
25
25
|
)
|
|
26
26
|
end
|
|
27
27
|
item_data[:fetched] = Date.today.to_s
|
|
@@ -172,14 +172,15 @@ module RelatonNist
|
|
|
172
172
|
# @param hit_data [Hash]
|
|
173
173
|
# @return [Array<Hash>]
|
|
174
174
|
def fetch_titles(hit_data)
|
|
175
|
-
[{ content: hit_data[:title], language: "en", script: "Latn",
|
|
175
|
+
[{ content: hit_data[:title], language: "en", script: "Latn",
|
|
176
|
+
format: "text/plain" }]
|
|
176
177
|
end
|
|
177
178
|
|
|
178
179
|
# Fetch dates
|
|
179
180
|
# @param doc [Nokogiri::HTML::Document]
|
|
180
181
|
# @param release_date [Date]
|
|
181
182
|
# @return [Array<Hash>]
|
|
182
|
-
def fetch_dates(doc, release_date)
|
|
183
|
+
def fetch_dates(doc, release_date) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
183
184
|
dates = [{ type: "published", on: release_date.to_s }]
|
|
184
185
|
|
|
185
186
|
if doc.is_a? Hash
|
data/lib/relaton_nist/version.rb
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
module RelatonNist
|
|
2
2
|
class XMLParser < RelatonBib::XMLParser
|
|
3
3
|
class << self
|
|
4
|
-
def from_xml(xml)
|
|
5
|
-
doc = Nokogiri::XML xml
|
|
6
|
-
doc.remove_namespaces!
|
|
7
|
-
nistitem = doc.at("/bibitem|/bibdata")
|
|
8
|
-
if nistitem
|
|
9
|
-
NistBibliographicItem.new(item_data(nistitem))
|
|
10
|
-
elsif
|
|
11
|
-
warn "[relaton-nist] can't find bibitem or bibdata element in the XML"
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
4
|
private
|
|
16
5
|
|
|
17
|
-
|
|
6
|
+
# @param intem [Nokogiri::XML::Document]
|
|
7
|
+
# @return [Hash]
|
|
8
|
+
def item_data(item)
|
|
18
9
|
data = super
|
|
19
|
-
ext =
|
|
10
|
+
ext = item.at "./ext"
|
|
20
11
|
return data unless ext
|
|
21
12
|
|
|
22
13
|
data[:commentperiod] = fetch_commentperiod(ext)
|
|
23
14
|
data
|
|
24
15
|
end
|
|
25
16
|
|
|
17
|
+
# @param item_hash [Hash]
|
|
18
|
+
# @return [RelatonNist::NistBibliographicItem]
|
|
19
|
+
def bib_item(item_hash)
|
|
20
|
+
NistBibliographicItem.new item_hash
|
|
21
|
+
end
|
|
22
|
+
|
|
26
23
|
def fetch_status(item)
|
|
27
24
|
status = item.at "./status"
|
|
28
25
|
return unless status
|
|
@@ -47,15 +44,7 @@ module RelatonNist
|
|
|
47
44
|
# @param item [Nokogiri::XML::Element]
|
|
48
45
|
# @return [Array<RelatonBib::DocumentRelation>]
|
|
49
46
|
def fetch_relations(item)
|
|
50
|
-
item
|
|
51
|
-
DocumentRelation.new(
|
|
52
|
-
type: rel[:type]&.empty? ? nil : rel[:type],
|
|
53
|
-
description: relation_description(rel),
|
|
54
|
-
bibitem: bib_item(item_data(rel.at("./bibitem"))),
|
|
55
|
-
locality: localities(rel),
|
|
56
|
-
source_locality: source_localities(rel),
|
|
57
|
-
)
|
|
58
|
-
end
|
|
47
|
+
super item, DocumentRelation
|
|
59
48
|
end
|
|
60
49
|
end
|
|
61
50
|
end
|
data/relaton_nist.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: relaton-nist
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.5.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-10-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: debase
|
|
@@ -156,14 +156,14 @@ dependencies:
|
|
|
156
156
|
requirements:
|
|
157
157
|
- - "~>"
|
|
158
158
|
- !ruby/object:Gem::Version
|
|
159
|
-
version: 1.
|
|
159
|
+
version: 1.5.0
|
|
160
160
|
type: :runtime
|
|
161
161
|
prerelease: false
|
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
|
163
163
|
requirements:
|
|
164
164
|
- - "~>"
|
|
165
165
|
- !ruby/object:Gem::Version
|
|
166
|
-
version: 1.
|
|
166
|
+
version: 1.5.0
|
|
167
167
|
- !ruby/object:Gem::Dependency
|
|
168
168
|
name: rubyzip
|
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -220,7 +220,7 @@ homepage: https://github.com/metanorma/relaton-nist
|
|
|
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: 'RelatonNist: retrive NIST standards.'
|
|
242
242
|
test_files: []
|