relaton-nist 1.3.1 → 1.6.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +2 -0
- data/README.adoc +9 -11
- data/grammars/isodoc.rng +136 -21
- data/grammars/nist.rng +26 -1
- data/lib/relaton_nist/hit_collection.rb +8 -9
- data/lib/relaton_nist/nist_bibliographic_item.rb +7 -4
- data/lib/relaton_nist/nist_bibliography.rb +8 -4
- data/lib/relaton_nist/scrapper.rb +18 -16
- data/lib/relaton_nist/version.rb +1 -1
- data/relaton_nist.gemspec +1 -1
- data/resp.html +665 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83911e87d23d384599e9d311ced2568d538e38adb7782a01396ae5db599b9c9e
|
4
|
+
data.tar.gz: dd9b9df50f61fe10efa8ba323598c261f13224065301b4914e1a9ff2a2ec2393
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 533c2c283684bf285c6221baecc36eee7068ef1d2c478f5e474b028b4fa5f599ff7efdb2117000c2fae452686c5577db32c7492051c74ae1cce321efa9b25f48
|
7
|
+
data.tar.gz: caee23be7c38f9ed33fa1adc48fc4610b0716eca1aadee6f0d66be8d08f33b8f02fb86cb8b199bd6979e8e7bb6ac5fc6c549a2c8dd86deaf598ee6d347f68ccb
|
data/.github/workflows/macos.yml
CHANGED
@@ -26,6 +26,8 @@ jobs:
|
|
26
26
|
- name: Update gems
|
27
27
|
run: |
|
28
28
|
sudo gem install bundler --force
|
29
|
+
ruby -v | grep 2.5 && bundle config set build.debase --with-cflags="-Wno-error=implicit-function-declaration"
|
30
|
+
ruby -v | grep 2.5 && bundle config set build.ruby-debug-ide --with-cflags="-Wno-error=implicit-function-declaration"
|
29
31
|
bundle install --jobs 4 --retry 3
|
30
32
|
- name: Run specs
|
31
33
|
run: |
|
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"/>
|
@@ -10,6 +10,7 @@ module RelatonNist
|
|
10
10
|
# Page of hit collection.
|
11
11
|
class HitCollection < RelatonBib::HitCollection
|
12
12
|
DOMAIN = "https://csrc.nist.gov"
|
13
|
+
PUBS_EXPORT = URI.join(DOMAIN, "/CSRC/media/feeds/metanorma/pubs-export")
|
13
14
|
DATAFILEDIR = File.expand_path ".relaton/nist", Dir.home
|
14
15
|
DATAFILE = File.expand_path "pubs-export.zip", DATAFILEDIR
|
15
16
|
|
@@ -45,7 +46,8 @@ module RelatonNist
|
|
45
46
|
from = d.strftime "%m/%d/%Y"
|
46
47
|
to = d.next_year.prev_day.strftime "%m/%d/%Y"
|
47
48
|
end
|
48
|
-
url = "#{DOMAIN}/publications/search?keywords-lg=#{text}"
|
49
|
+
url = "#{DOMAIN}/publications/search?keywords-lg=#{text}"\
|
50
|
+
"&sortBy-lg=relevence"
|
49
51
|
url += "&dateFrom-lg=#{from}" if from
|
50
52
|
url += "&dateTo-lg=#{to}" if to
|
51
53
|
url += if /PD/.match? opts[:stage]
|
@@ -81,7 +83,7 @@ module RelatonNist
|
|
81
83
|
select_data(docid, **opts).map do |h|
|
82
84
|
/(?<serie>(?<=-)\w+$)/ =~ h["series"]
|
83
85
|
title = [h["title-main"], h["title-sub"]].compact.join " - "
|
84
|
-
release_date = RelatonBib.parse_date h["published-date"]
|
86
|
+
release_date = RelatonBib.parse_date h["published-date"], false
|
85
87
|
Hit.new({ code: h["docidentifier"], serie: serie.upcase, title: title,
|
86
88
|
url: h["uri"], status: h["status"],
|
87
89
|
release_date: release_date, json: h }, self)
|
@@ -112,7 +114,7 @@ module RelatonNist
|
|
112
114
|
def match_year?(doc, date)
|
113
115
|
return true unless year
|
114
116
|
|
115
|
-
idate = RelatonBib.parse_date doc["issued-date"]
|
117
|
+
idate = RelatonBib.parse_date doc["issued-date"], false
|
116
118
|
idate.between? date, date.next_year.prev_day
|
117
119
|
end
|
118
120
|
|
@@ -130,15 +132,12 @@ module RelatonNist
|
|
130
132
|
#
|
131
133
|
# @prarm ctime [Time, NilClass]
|
132
134
|
def fetch_data(ctime)
|
133
|
-
resp = OpenURI.open_uri(
|
134
|
-
"https://csrc.nist.gov/CSRC/media/feeds/metanorma/pubs-export.meta"
|
135
|
-
)
|
135
|
+
resp = OpenURI.open_uri("#{PUBS_EXPORT}.meta")
|
136
136
|
if !ctime || ctime < resp.last_modified
|
137
137
|
@data = nil
|
138
|
-
|
139
|
-
zip.close
|
138
|
+
uri_open = URI.method(:open) || Kernel.method(:open)
|
140
139
|
FileUtils.mkdir_p DATAFILEDIR unless Dir.exist? DATAFILEDIR
|
141
|
-
|
140
|
+
IO.copy_stream(uri_open.call("#{PUBS_EXPORT}.zip"), DATAFILE)
|
142
141
|
end
|
143
142
|
end
|
144
143
|
|
@@ -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
|