relaton-nist 0.3.6 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/macos.yml +27 -0
- data/.github/workflows/ubuntu.yml +27 -0
- data/.github/workflows/windows.yml +30 -0
- data/Gemfile.lock +9 -5
- data/grammars/basicdoc.rng +1029 -0
- data/grammars/biblio.rng +1142 -0
- data/grammars/isodoc.rng +514 -0
- data/grammars/isostandard.rng +857 -0
- data/grammars/nist.rng +227 -0
- data/grammars/reqt.rng +165 -0
- data/lib/relaton_nist.rb +9 -0
- data/lib/relaton_nist/hit_collection.rb +3 -1
- data/lib/relaton_nist/nist_bibliographic_item.rb +1 -1
- data/lib/relaton_nist/nist_bibliography.rb +2 -0
- data/lib/relaton_nist/processor.rb +7 -1
- data/lib/relaton_nist/scrapper.rb +2 -2
- data/lib/relaton_nist/version.rb +1 -1
- data/relaton_nist.gemspec +2 -1
- metadata +28 -9
- data/.travis.yml +0 -18
- data/appveyor.yml +0 -37
- data/lib/relaton_nist/data/pubs-export.zip +0 -0
data/grammars/nist.rng
ADDED
@@ -0,0 +1,227 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
3
|
+
<!--
|
4
|
+
Currently we inherit from a namespaced grammar, isostandard. Until we inherit from isodoc,
|
5
|
+
we cannot have a new default namespace: we will end up with a grammar with two different
|
6
|
+
namespaces, one for isostandard and one for csand additions. And we do not want that.
|
7
|
+
-->
|
8
|
+
<include href="isostandard.rng">
|
9
|
+
<start>
|
10
|
+
<ref name="nist-standard"/>
|
11
|
+
</start>
|
12
|
+
<define name="figure">
|
13
|
+
<element name="figure">
|
14
|
+
<attribute name="id">
|
15
|
+
<data type="ID"/>
|
16
|
+
</attribute>
|
17
|
+
<optional>
|
18
|
+
<ref name="tname"/>
|
19
|
+
</optional>
|
20
|
+
<choice>
|
21
|
+
<ref name="image"/>
|
22
|
+
<ref name="pre"/>
|
23
|
+
<oneOrMore>
|
24
|
+
<ref name="subfigure"/>
|
25
|
+
</oneOrMore>
|
26
|
+
</choice>
|
27
|
+
<zeroOrMore>
|
28
|
+
<ref name="fn"/>
|
29
|
+
</zeroOrMore>
|
30
|
+
<optional>
|
31
|
+
<ref name="dl"/>
|
32
|
+
</optional>
|
33
|
+
<zeroOrMore>
|
34
|
+
<ref name="note"/>
|
35
|
+
</zeroOrMore>
|
36
|
+
</element>
|
37
|
+
</define>
|
38
|
+
<define name="subfigure">
|
39
|
+
<element name="figure">
|
40
|
+
<attribute name="id">
|
41
|
+
<data type="ID"/>
|
42
|
+
</attribute>
|
43
|
+
<optional>
|
44
|
+
<ref name="tname"/>
|
45
|
+
</optional>
|
46
|
+
<choice>
|
47
|
+
<ref name="image"/>
|
48
|
+
<ref name="pre"/>
|
49
|
+
</choice>
|
50
|
+
</element>
|
51
|
+
</define>
|
52
|
+
<define name="DocumentType">
|
53
|
+
<value>standard</value>
|
54
|
+
</define>
|
55
|
+
<define name="TitleType">
|
56
|
+
<choice>
|
57
|
+
<value>alternative</value>
|
58
|
+
<value>original</value>
|
59
|
+
<value>unofficial</value>
|
60
|
+
<value>subtitle</value>
|
61
|
+
<value>main</value>
|
62
|
+
</choice>
|
63
|
+
</define>
|
64
|
+
<!-- DocRelationType |= "obsoletedBy" | "supersedes" | "supersededBy" -->
|
65
|
+
<define name="DocRelationType">
|
66
|
+
<choice>
|
67
|
+
<value>obsoletes</value>
|
68
|
+
<value>updates</value>
|
69
|
+
<value>updatedBy</value>
|
70
|
+
<value>complements</value>
|
71
|
+
<value>derivedFrom</value>
|
72
|
+
<value>translatedFrom</value>
|
73
|
+
<value>adoptedFrom</value>
|
74
|
+
<value>equivalent</value>
|
75
|
+
<value>identical</value>
|
76
|
+
<value>nonequivalent</value>
|
77
|
+
<value>includedIn</value>
|
78
|
+
<value>includes</value>
|
79
|
+
<value>instance</value>
|
80
|
+
<value>partOf</value>
|
81
|
+
<value>hasDraft</value>
|
82
|
+
<value>obsoletedBy</value>
|
83
|
+
<value>supersedes</value>
|
84
|
+
<value>supersededBy</value>
|
85
|
+
</choice>
|
86
|
+
</define>
|
87
|
+
<!-- BibliographicDateType |= "abandoned" | "superseded" -->
|
88
|
+
<define name="BibliographicDateType">
|
89
|
+
<choice>
|
90
|
+
<value>published</value>
|
91
|
+
<value>accessed</value>
|
92
|
+
<value>created</value>
|
93
|
+
<value>implemented</value>
|
94
|
+
<value>obsoleted</value>
|
95
|
+
<value>confirmed</value>
|
96
|
+
<value>updated</value>
|
97
|
+
<value>issued</value>
|
98
|
+
<value>transmitted</value>
|
99
|
+
<value>copied</value>
|
100
|
+
<value>unchanged</value>
|
101
|
+
<value>circulated</value>
|
102
|
+
<value>abandoned</value>
|
103
|
+
<value>superseded</value>
|
104
|
+
</choice>
|
105
|
+
</define>
|
106
|
+
<define name="preface">
|
107
|
+
<element name="preface">
|
108
|
+
<optional>
|
109
|
+
<ref name="preface_abstract"/>
|
110
|
+
</optional>
|
111
|
+
<optional>
|
112
|
+
<ref name="foreword"/>
|
113
|
+
</optional>
|
114
|
+
<zeroOrMore>
|
115
|
+
<ref name="clause"/>
|
116
|
+
</zeroOrMore>
|
117
|
+
<optional>
|
118
|
+
<ref name="reviewernote"/>
|
119
|
+
</optional>
|
120
|
+
<optional>
|
121
|
+
<ref name="executivesummary"/>
|
122
|
+
</optional>
|
123
|
+
</element>
|
124
|
+
</define>
|
125
|
+
<define name="annex">
|
126
|
+
<element name="annex">
|
127
|
+
<optional>
|
128
|
+
<attribute name="id">
|
129
|
+
<data type="ID"/>
|
130
|
+
</attribute>
|
131
|
+
</optional>
|
132
|
+
<optional>
|
133
|
+
<attribute name="language"/>
|
134
|
+
</optional>
|
135
|
+
<optional>
|
136
|
+
<attribute name="script"/>
|
137
|
+
</optional>
|
138
|
+
<optional>
|
139
|
+
<attribute name="inline-header">
|
140
|
+
<data type="boolean"/>
|
141
|
+
</attribute>
|
142
|
+
</optional>
|
143
|
+
<optional>
|
144
|
+
<attribute name="obligation">
|
145
|
+
<choice>
|
146
|
+
<value>normative</value>
|
147
|
+
<value>informative</value>
|
148
|
+
</choice>
|
149
|
+
</attribute>
|
150
|
+
</optional>
|
151
|
+
<optional>
|
152
|
+
<ref name="section-title"/>
|
153
|
+
</optional>
|
154
|
+
<zeroOrMore>
|
155
|
+
<!--
|
156
|
+
allow hanging paragraps in annexes: they introduce lists
|
157
|
+
( paragraph-with-footnote | table | note | formula | admonition | ol | ul | dl | figure | quote | sourcecode | review | example )*,
|
158
|
+
-->
|
159
|
+
<ref name="BasicBlock"/>
|
160
|
+
</zeroOrMore>
|
161
|
+
<zeroOrMore>
|
162
|
+
<ref name="note"/>
|
163
|
+
</zeroOrMore>
|
164
|
+
<choice>
|
165
|
+
<zeroOrMore>
|
166
|
+
<ref name="clause-hanging-paragraph-with-footnote"/>
|
167
|
+
</zeroOrMore>
|
168
|
+
<ref name="terms"/>
|
169
|
+
</choice>
|
170
|
+
</element>
|
171
|
+
</define>
|
172
|
+
<define name="BibDataExtensionType">
|
173
|
+
<optional>
|
174
|
+
<ref name="doctype"/>
|
175
|
+
</optional>
|
176
|
+
<optional>
|
177
|
+
<ref name="commentperiod"/>
|
178
|
+
</optional>
|
179
|
+
</define>
|
180
|
+
</include>
|
181
|
+
<define name="commentperiod">
|
182
|
+
<element name="commentperiod">
|
183
|
+
<element name="from">
|
184
|
+
<ref name="ISO8601Date"/>
|
185
|
+
</element>
|
186
|
+
<optional>
|
187
|
+
<element name="to">
|
188
|
+
<ref name="ISO8601Date"/>
|
189
|
+
</element>
|
190
|
+
</optional>
|
191
|
+
<optional>
|
192
|
+
<element name="extended">
|
193
|
+
<ref name="ISO8601Date"/>
|
194
|
+
</element>
|
195
|
+
</optional>
|
196
|
+
</element>
|
197
|
+
</define>
|
198
|
+
<define name="reviewernote">
|
199
|
+
<element name="reviewernote">
|
200
|
+
<ref name="Basic-Section"/>
|
201
|
+
</element>
|
202
|
+
</define>
|
203
|
+
<define name="executivesummary">
|
204
|
+
<element name="executivesummary">
|
205
|
+
<ref name="Basic-Section"/>
|
206
|
+
</element>
|
207
|
+
</define>
|
208
|
+
<define name="nist-standard">
|
209
|
+
<element name="nist-standard">
|
210
|
+
<ref name="bibdata"/>
|
211
|
+
<zeroOrMore>
|
212
|
+
<ref name="termdocsource"/>
|
213
|
+
</zeroOrMore>
|
214
|
+
<optional>
|
215
|
+
<ref name="boilerplate"/>
|
216
|
+
</optional>
|
217
|
+
<ref name="preface"/>
|
218
|
+
<oneOrMore>
|
219
|
+
<ref name="sections"/>
|
220
|
+
</oneOrMore>
|
221
|
+
<zeroOrMore>
|
222
|
+
<ref name="annex"/>
|
223
|
+
</zeroOrMore>
|
224
|
+
<ref name="bibliography"/>
|
225
|
+
</element>
|
226
|
+
</define>
|
227
|
+
</grammar>
|
data/grammars/reqt.rng
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
3
|
+
<!--
|
4
|
+
Presupposes isodoc.rnc, is included in it
|
5
|
+
include "isodoc.rnc" { }
|
6
|
+
-->
|
7
|
+
<define name="requirement">
|
8
|
+
<element name="requirement">
|
9
|
+
<ref name="RequirementType"/>
|
10
|
+
</element>
|
11
|
+
</define>
|
12
|
+
<define name="recommendation">
|
13
|
+
<element name="recommendation">
|
14
|
+
<ref name="RequirementType"/>
|
15
|
+
</element>
|
16
|
+
</define>
|
17
|
+
<define name="permission">
|
18
|
+
<element name="permission">
|
19
|
+
<ref name="RequirementType"/>
|
20
|
+
</element>
|
21
|
+
</define>
|
22
|
+
<define name="RequirementType">
|
23
|
+
<optional>
|
24
|
+
<attribute name="obligation">
|
25
|
+
<ref name="ObligationType"/>
|
26
|
+
</attribute>
|
27
|
+
</optional>
|
28
|
+
<optional>
|
29
|
+
<attribute name="unnumbered">
|
30
|
+
<data type="boolean"/>
|
31
|
+
</attribute>
|
32
|
+
</optional>
|
33
|
+
<optional>
|
34
|
+
<attribute name="subsequence"/>
|
35
|
+
</optional>
|
36
|
+
<attribute name="id">
|
37
|
+
<data type="ID"/>
|
38
|
+
</attribute>
|
39
|
+
<optional>
|
40
|
+
<attribute name="filename"/>
|
41
|
+
</optional>
|
42
|
+
<optional>
|
43
|
+
<ref name="reqtitle"/>
|
44
|
+
</optional>
|
45
|
+
<optional>
|
46
|
+
<ref name="label"/>
|
47
|
+
</optional>
|
48
|
+
<optional>
|
49
|
+
<ref name="subject"/>
|
50
|
+
</optional>
|
51
|
+
<optional>
|
52
|
+
<ref name="reqinherit"/>
|
53
|
+
</optional>
|
54
|
+
<zeroOrMore>
|
55
|
+
<ref name="classification"/>
|
56
|
+
</zeroOrMore>
|
57
|
+
<zeroOrMore>
|
58
|
+
<choice>
|
59
|
+
<ref name="measurementtarget"/>
|
60
|
+
<ref name="specification"/>
|
61
|
+
<ref name="verification"/>
|
62
|
+
<ref name="import"/>
|
63
|
+
<ref name="description"/>
|
64
|
+
</choice>
|
65
|
+
</zeroOrMore>
|
66
|
+
<optional>
|
67
|
+
<ref name="reqt_references"/>
|
68
|
+
</optional>
|
69
|
+
<zeroOrMore>
|
70
|
+
<choice>
|
71
|
+
<ref name="requirement"/>
|
72
|
+
<ref name="recommendation"/>
|
73
|
+
<ref name="permission"/>
|
74
|
+
</choice>
|
75
|
+
</zeroOrMore>
|
76
|
+
</define>
|
77
|
+
<define name="reqtitle">
|
78
|
+
<element name="title">
|
79
|
+
<ref name="FormattedString"/>
|
80
|
+
</element>
|
81
|
+
</define>
|
82
|
+
<define name="label">
|
83
|
+
<element name="label">
|
84
|
+
<text/>
|
85
|
+
</element>
|
86
|
+
</define>
|
87
|
+
<define name="subject">
|
88
|
+
<element name="subject">
|
89
|
+
<text/>
|
90
|
+
</element>
|
91
|
+
</define>
|
92
|
+
<define name="reqinherit">
|
93
|
+
<element name="inherit">
|
94
|
+
<text/>
|
95
|
+
</element>
|
96
|
+
</define>
|
97
|
+
<define name="measurementtarget">
|
98
|
+
<element name="measurement-target">
|
99
|
+
<ref name="RequirementSubpart"/>
|
100
|
+
</element>
|
101
|
+
</define>
|
102
|
+
<define name="specification">
|
103
|
+
<element name="specification">
|
104
|
+
<ref name="RequirementSubpart"/>
|
105
|
+
</element>
|
106
|
+
</define>
|
107
|
+
<define name="verification">
|
108
|
+
<element name="verification">
|
109
|
+
<ref name="RequirementSubpart"/>
|
110
|
+
</element>
|
111
|
+
</define>
|
112
|
+
<define name="import">
|
113
|
+
<element name="import">
|
114
|
+
<ref name="RequirementSubpart"/>
|
115
|
+
</element>
|
116
|
+
</define>
|
117
|
+
<define name="description">
|
118
|
+
<element name="description">
|
119
|
+
<ref name="RequirementSubpart"/>
|
120
|
+
</element>
|
121
|
+
</define>
|
122
|
+
<define name="reqt_references">
|
123
|
+
<element name="references">
|
124
|
+
<oneOrMore>
|
125
|
+
<ref name="bibitem"/>
|
126
|
+
</oneOrMore>
|
127
|
+
</element>
|
128
|
+
</define>
|
129
|
+
<define name="RequirementSubpart">
|
130
|
+
<optional>
|
131
|
+
<attribute name="type"/>
|
132
|
+
</optional>
|
133
|
+
<optional>
|
134
|
+
<attribute name="exclude">
|
135
|
+
<data type="boolean"/>
|
136
|
+
</attribute>
|
137
|
+
</optional>
|
138
|
+
<oneOrMore>
|
139
|
+
<ref name="BasicBlock"/>
|
140
|
+
</oneOrMore>
|
141
|
+
</define>
|
142
|
+
<define name="ObligationType">
|
143
|
+
<choice>
|
144
|
+
<value>requirement</value>
|
145
|
+
<value>recommendation</value>
|
146
|
+
<value>permission</value>
|
147
|
+
</choice>
|
148
|
+
</define>
|
149
|
+
<define name="classification">
|
150
|
+
<element name="classification">
|
151
|
+
<ref name="classification_tag"/>
|
152
|
+
<ref name="classification_value"/>
|
153
|
+
</element>
|
154
|
+
</define>
|
155
|
+
<define name="classification_tag">
|
156
|
+
<element name="tag">
|
157
|
+
<text/>
|
158
|
+
</element>
|
159
|
+
</define>
|
160
|
+
<define name="classification_value">
|
161
|
+
<element name="value">
|
162
|
+
<text/>
|
163
|
+
</element>
|
164
|
+
</define>
|
165
|
+
</grammar>
|
data/lib/relaton_nist.rb
CHANGED
@@ -8,4 +8,13 @@ require "relaton_nist/nist_bibliography"
|
|
8
8
|
|
9
9
|
module RelatonNist
|
10
10
|
class Error < StandardError; end
|
11
|
+
|
12
|
+
# Returns hash of XML reammar
|
13
|
+
# @return [String]
|
14
|
+
def self.grammar_hash
|
15
|
+
gem_path = File.expand_path "..", __dir__
|
16
|
+
grammars_path = File.join gem_path, "grammars", "*"
|
17
|
+
grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
18
|
+
Digest::MD5.hexdigest grammars
|
19
|
+
end
|
11
20
|
end
|
@@ -10,7 +10,8 @@ module RelatonNist
|
|
10
10
|
# Page of hit collection.
|
11
11
|
class HitCollection < RelatonBib::HitCollection
|
12
12
|
DOMAIN = "https://csrc.nist.gov"
|
13
|
-
|
13
|
+
DATAFILEDIR = File.expand_path ".relaton/nist", Dir.home
|
14
|
+
DATAFILE = File.expand_path "pubs-export.zip", DATAFILEDIR
|
14
15
|
|
15
16
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
16
17
|
|
@@ -139,6 +140,7 @@ module RelatonNist
|
|
139
140
|
@data = nil
|
140
141
|
zip = OpenURI.open_uri "https://csrc.nist.gov/CSRC/media/feeds/metanorma/pubs-export.zip"
|
141
142
|
zip.close
|
143
|
+
FileUtils.mkdir_p DATAFILEDIR unless Dir.exist? DATAFILEDIR
|
142
144
|
FileUtils.mv zip.path, DATAFILE
|
143
145
|
end
|
144
146
|
end
|
@@ -29,6 +29,8 @@ module RelatonNist
|
|
29
29
|
#
|
30
30
|
# @return [String] Relaton XML serialisation of reference
|
31
31
|
def get(code, year = nil, opts = {})
|
32
|
+
return fetch_ref_err(code, year, []) if code =~ /\sEP$/
|
33
|
+
|
32
34
|
/^(?<code2>[^\(]+)(\((?<date2>\w+\s(\d{2},\s)?\d{4})\))?\s?\(?((?<=\()(?<stage>[^\)]+))?/ =~ code
|
33
35
|
if code2
|
34
36
|
code = code2.strip
|
@@ -5,7 +5,7 @@ module RelatonNist
|
|
5
5
|
def initialize
|
6
6
|
@short = :relaton_nist
|
7
7
|
@prefix = "NIST"
|
8
|
-
@defaultprefix = %r{^(NIST|NISTGCR|ITL Bulletin|JPCRD|NISTIR|CSRC)[
|
8
|
+
@defaultprefix = %r{^(NIST|NISTGCR|ITL Bulletin|JPCRD|NISTIR|CSRC|FIPS)(/[^\s])?\s}
|
9
9
|
@idtype = "NIST"
|
10
10
|
end
|
11
11
|
|
@@ -29,5 +29,11 @@ module RelatonNist
|
|
29
29
|
item_hash = ::RelatonNist::HashConverter.hash_to_bib(hash)
|
30
30
|
::RelatonNist::NistBibliographicItem.new item_hash
|
31
31
|
end
|
32
|
+
|
33
|
+
# Returns hash of XML grammar
|
34
|
+
# @return [String]
|
35
|
+
def grammar_hash
|
36
|
+
@grammar_hash ||= ::RelatonNist.grammar_hash
|
37
|
+
end
|
32
38
|
end
|
33
39
|
end
|