relaton-nist 1.2.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 +130 -21
- data/grammars/nist.rng +19 -1
- data/lib/relaton_nist/comment_period.rb +11 -0
- data/lib/relaton_nist/document_relation.rb +5 -0
- data/lib/relaton_nist/hash_converter.rb +18 -0
- data/lib/relaton_nist/hit_collection.rb +15 -12
- data/lib/relaton_nist/nist_bibliographic_item.rb +9 -1
- data/lib/relaton_nist/nist_bibliography.rb +2 -1
- data/lib/relaton_nist/scrapper.rb +11 -8
- data/lib/relaton_nist/version.rb +1 -1
- data/lib/relaton_nist/xml_parser.rb +16 -13
- data/relaton_nist.gemspec +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3697bb0d3737e3f29c9b68d2395013762ed2d5b56b8003325f495f67f670532
|
4
|
+
data.tar.gz: 8e41e1180ea1fb3403546eb5493df7a7588b5fff934a453f33d9f60ed1730a7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42c02c151388863e207012f6cc2dae9fc796ef18abf5f6ebf73f9683b0e7322f35bde10471fe357515593c492db136a0b9514103fdb127fb53096b75c6197eea
|
7
|
+
data.tar.gz: d085edddc926b57e6e8613886c661e7296e23ab121861fe880e61044d0d25c1dd3ca9474da89356aa3861b5426a749d3f737ad8b4d20c95c5839d9ea284da85b
|
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
@@ -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/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"/>
|
@@ -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
|
@@ -26,6 +26,24 @@ module RelatonNist
|
|
26
26
|
|
27
27
|
ret[:commentperiod] = CommentPeriod.new ret[:commentperiod]
|
28
28
|
end
|
29
|
+
|
30
|
+
# @param ret [Hash]
|
31
|
+
def relations_hash_to_bib(ret)
|
32
|
+
super
|
33
|
+
return unless ret[:relation]
|
34
|
+
|
35
|
+
ret[:relation] = ret[:relation].map { |r| DocumentRelation.new r }
|
36
|
+
|
37
|
+
# ret[:relation] = array(ret[:relation])
|
38
|
+
# ret[:relation]&.each do |r|
|
39
|
+
# if r[:description]
|
40
|
+
# r[:description] = FormattedString.new r[:description]
|
41
|
+
# end
|
42
|
+
# relation_bibitem_hash_to_bib(r)
|
43
|
+
# relation_locality_hash_to_bib(r)
|
44
|
+
# relation_source_locality_hash_to_bib(r)
|
45
|
+
# end
|
46
|
+
end
|
29
47
|
end
|
30
48
|
end
|
31
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"
|
@@ -51,7 +51,7 @@ module RelatonNist
|
|
51
51
|
# @option abstract [String] :script
|
52
52
|
# @option abstract [String] :type
|
53
53
|
#
|
54
|
-
# @param relation [Array<Hash>]
|
54
|
+
# @param relation [Array<Hash, RelatonNist::DocumentRelation>]
|
55
55
|
# @option relation [String] :type
|
56
56
|
# @option relation [RelatonBib::BibliographicItem] :bibitem
|
57
57
|
# @option relation [Array<RelatonBib::BibItemLocality>] :bib_locality
|
@@ -83,5 +83,13 @@ module RelatonNist
|
|
83
83
|
hash["commentperiod"] = commentperiod.to_hash if commentperiod
|
84
84
|
hash
|
85
85
|
end
|
86
|
+
|
87
|
+
# @param prefix [String]
|
88
|
+
# @return [String]
|
89
|
+
def to_asciibib(prefix = "")
|
90
|
+
out = super
|
91
|
+
out += commentperiod.to_asciibib prefix if commentperiod
|
92
|
+
out
|
93
|
+
end
|
86
94
|
end
|
87
95
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "relaton_bib"
|
2
2
|
require "relaton_nist/nist_bibliographic_item"
|
3
|
+
require "relaton_nist/document_relation"
|
3
4
|
require "relaton_nist/scrapper"
|
4
5
|
require "relaton_nist/hit_collection"
|
5
6
|
require "relaton_nist/xml_parser"
|
@@ -120,7 +121,7 @@ module RelatonNist
|
|
120
121
|
end
|
121
122
|
|
122
123
|
def nistbib_search_filter(code, year, opts)
|
123
|
-
idregex = %r{[0-9-]{3,}}
|
124
|
+
idregex = %r{[0-9-]{3,}\w?}
|
124
125
|
docid = code.match(idregex).to_s
|
125
126
|
serie = code.match(%r{(FISP|SP|NISTIR)(?=\s)})
|
126
127
|
warn "[relaton-nist] (\"#{code}\") fetching..."
|
@@ -235,15 +235,18 @@ module RelatonNist
|
|
235
235
|
)
|
236
236
|
end
|
237
237
|
if contr["surname"]
|
238
|
-
affiliation =
|
238
|
+
affiliation = []
|
239
|
+
affiliation << RelatonBib::Affiliation.new(organization: org) if org
|
239
240
|
entity = RelatonBib::Person.new(
|
240
|
-
name: full_name(contr, lang, script), affiliation:
|
241
|
+
name: full_name(contr, lang, script), affiliation: affiliation,
|
241
242
|
)
|
242
|
-
|
243
|
+
elsif org
|
243
244
|
entity = org
|
244
245
|
end
|
245
|
-
|
246
|
-
|
246
|
+
if entity
|
247
|
+
RelatonBib::ContributionInfo.new entity: entity, role: [type: role]
|
248
|
+
end
|
249
|
+
end.compact
|
247
250
|
end
|
248
251
|
|
249
252
|
# rubocop:disable Metrics/CyclomaticComplexity
|
@@ -373,7 +376,7 @@ module RelatonNist
|
|
373
376
|
|
374
377
|
# Fetch relations.
|
375
378
|
# @param doc [Nokogiri::HTML::Document]
|
376
|
-
# @return [Array<
|
379
|
+
# @return [Array<RelatonNist::DocumentRelation>]
|
377
380
|
def fetch_relations(doc)
|
378
381
|
relations = doc.xpath('//span[@id="pub-supersedes-container"]/a').map do |r|
|
379
382
|
doc_relation "supersedes", r.text, DOMAIN + r[:href]
|
@@ -402,9 +405,9 @@ module RelatonNist
|
|
402
405
|
# @param type [String]
|
403
406
|
# @param ref [String]
|
404
407
|
# @param uri [String]
|
405
|
-
# @return [
|
408
|
+
# @return [RelatonNist::DocumentRelation]
|
406
409
|
def doc_relation(type, ref, uri, lang = "en", script = "Latn")
|
407
|
-
|
410
|
+
DocumentRelation.new(
|
408
411
|
type: type,
|
409
412
|
bibitem: RelatonBib::BibliographicItem.new(
|
410
413
|
formattedref: RelatonBib::FormattedRef.new(
|
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
|
@@ -43,6 +40,12 @@ module RelatonNist
|
|
43
40
|
extended: cp.at("extended")&.text
|
44
41
|
)
|
45
42
|
end
|
43
|
+
|
44
|
+
# @param item [Nokogiri::XML::Element]
|
45
|
+
# @return [Array<RelatonBib::DocumentRelation>]
|
46
|
+
def fetch_relations(item)
|
47
|
+
super item, DocumentRelation
|
48
|
+
end
|
46
49
|
end
|
47
50
|
end
|
48
51
|
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.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
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 1.
|
159
|
+
version: 1.4.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.4.0
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: rubyzip
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,6 +204,7 @@ files:
|
|
204
204
|
- grammars/reqt.rng
|
205
205
|
- lib/relaton_nist.rb
|
206
206
|
- lib/relaton_nist/comment_period.rb
|
207
|
+
- lib/relaton_nist/document_relation.rb
|
207
208
|
- lib/relaton_nist/document_status.rb
|
208
209
|
- lib/relaton_nist/hash_converter.rb
|
209
210
|
- lib/relaton_nist/hit.rb
|
@@ -219,7 +220,7 @@ homepage: https://github.com/metanorma/relaton-nist
|
|
219
220
|
licenses:
|
220
221
|
- MIT
|
221
222
|
metadata: {}
|
222
|
-
post_install_message:
|
223
|
+
post_install_message:
|
223
224
|
rdoc_options: []
|
224
225
|
require_paths:
|
225
226
|
- lib
|
@@ -235,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
235
236
|
version: '0'
|
236
237
|
requirements: []
|
237
238
|
rubygems_version: 3.0.6
|
238
|
-
signing_key:
|
239
|
+
signing_key:
|
239
240
|
specification_version: 4
|
240
241
|
summary: 'RelatonNist: retrive NIST standards.'
|
241
242
|
test_files: []
|