relaton-nist 1.16.3 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +34 -27
- data/grammars/basicdoc.rng +18 -2
- data/grammars/biblio.rng +1 -0
- data/lib/relaton_nist/hash_converter.rb +46 -45
- data/lib/relaton_nist/hit_collection.rb +21 -9
- data/lib/relaton_nist/nist_bibliographic_item.rb +1 -4
- data/lib/relaton_nist/nist_bibliography.rb +24 -28
- data/lib/relaton_nist/scrapper.rb +23 -19
- data/lib/relaton_nist/tech_pubs_parser.rb +6 -3
- data/lib/relaton_nist/version.rb +1 -1
- data/relaton_nist.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dcfa351621f17ad754376d1c7d3b593fdfda7bb1fdd91624cb357f1655d2eed
|
4
|
+
data.tar.gz: b4d12a7e12b1c8356683e457904f571133fe353e74b30ff012664d8f45f88dad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77bf2aabe8e5be940d974da17cf4e07433ced3b2b7eae49a9930087b46b5f4fca80dc4f4771f93922adb5c8eb5bca2a0ff124b5a6c6d1e847a08280a8a369ea1
|
7
|
+
data.tar.gz: 9ed7ce8b419bfefcb6d3c5ee4034720e7fc24220e392a7a2d5edd5f6b12ffa5dad459f14c4fe54920f9f5468768357cdfa10778580fc0811153c5f30493496f7
|
data/README.adoc
CHANGED
@@ -89,10 +89,12 @@ end
|
|
89
89
|
|
90
90
|
[source,ruby]
|
91
91
|
----
|
92
|
-
hit_collection = RelatonNist::NistBibliography.search("8200")
|
93
|
-
|
92
|
+
hit_collection = RelatonNist::NistBibliography.search("NISTIR 8200")
|
93
|
+
[relaton-nist] (NIST IR 8200) Fetching from csrc.nist.gov ...
|
94
|
+
[relaton-nist] (NIST IR 8200) Fetching from Relaton repository ...
|
95
|
+
=> <RelatonNist::HitCollection:0x00000000004b28 @ref=NIST IR 8200 @fetched=false>
|
94
96
|
|
95
|
-
item = hit_collection[
|
97
|
+
item = hit_collection[0].fetch
|
96
98
|
=> #<RelatonNist::NistBibliographicItem:0x007fc049aa6778
|
97
99
|
...
|
98
100
|
----
|
@@ -101,9 +103,9 @@ item = hit_collection[1].fetch
|
|
101
103
|
[source,ruby]
|
102
104
|
----
|
103
105
|
item.to_xml
|
104
|
-
=> "<bibitem id="
|
105
|
-
<fetched>
|
106
|
-
<title format="text/plain" language="en" script="Latn">
|
106
|
+
=> "<bibitem id="NISTIR8200" type="standard" schema-version="v1.2.5">
|
107
|
+
<fetched>2023-10-16</fetched>
|
108
|
+
<title format="text/plain" language="en" script="Latn">Interagency report on the status of international cybersecurity standardization for the internet of things (IoT)</title>
|
107
109
|
...
|
108
110
|
<bibitem>"
|
109
111
|
----
|
@@ -111,9 +113,9 @@ With argument `bibdata: true` it outputs XML wrapped by `bibdata` element and ad
|
|
111
113
|
[source,ruby]
|
112
114
|
----
|
113
115
|
item.to_xml bibdata: true
|
114
|
-
=> "<bibdata type="standard" schema-version="v1.2.
|
115
|
-
<fetched>
|
116
|
-
<title format="text/plain" language="en" script="Latn">
|
116
|
+
=> "<bibdata type="standard" schema-version="v1.2.5">
|
117
|
+
<fetched>2023-10-16</fetched>
|
118
|
+
<title format="text/plain" language="en" script="Latn">Interagency report on the status of international cybersecurity standardization for the internet of things (IoT)</title>
|
117
119
|
...
|
118
120
|
<ext schema-version="v1.0.0">
|
119
121
|
<doctype>standard</doctype>
|
@@ -124,9 +126,10 @@ item.to_xml bibdata: true
|
|
124
126
|
=== Get code, and year
|
125
127
|
[source,ruby]
|
126
128
|
----
|
127
|
-
RelatonNist::NistBibliography.get("NIST IR 8200", "2018"
|
128
|
-
[relaton-nist] (NIST
|
129
|
-
[relaton-nist] (NIST IR 8200)
|
129
|
+
RelatonNist::NistBibliography.get("NIST IR 8200", "2018")
|
130
|
+
[relaton-nist] (NIST SP 8200:2018) Fetching from csrc.nist.gov ...
|
131
|
+
[relaton-nist] (NIST IR 8200:2018) Fetching from Relaton repository...
|
132
|
+
[relaton-nist] (NIST IR 8200:2018) Found: `NIST IR 8200`
|
130
133
|
=> #<RelatonNist::NistBibliographicItem:0x00007fab74a572c0
|
131
134
|
...
|
132
135
|
----
|
@@ -153,10 +156,10 @@ NIST FIPS {docnumber}
|
|
153
156
|
----
|
154
157
|
[source,ruby]
|
155
158
|
----
|
156
|
-
RelatonNist::NistBibliography.get("SP 800-205 (February 2019) (
|
157
|
-
[relaton-nist] (SP 800-205)
|
158
|
-
[relaton-nist] (SP 800-205)
|
159
|
-
=> #<RelatonNist::NistBibliographicItem:
|
159
|
+
RelatonNist::NistBibliography.get("NIST SP 800-205 (February 2019) (IPD)")
|
160
|
+
[relaton-nist] (NIST SP 800-205) Fetching from csrc.nist.gov ...
|
161
|
+
[relaton-nist] (NIST SP 800-205) Found: `NIST SP 800-205 (Draft)`
|
162
|
+
=> #<RelatonNist::NistBibliographicItem:0x00000001105afdc8
|
160
163
|
...
|
161
164
|
----
|
162
165
|
|
@@ -172,22 +175,22 @@ Referehces can contain optional parameters `{ptN}{vN}{verN}{rN}{/Add}`:
|
|
172
175
|
[source,ruby]
|
173
176
|
----
|
174
177
|
item = RelatonNist::NistBibliography.get 'NIST SP 800-67r1'
|
175
|
-
[relaton-nist] (NIST SP 800-67r1)
|
176
|
-
[relaton-nist] (NIST SP 800-67r1)
|
177
|
-
=> #<RelatonNist::NistBibliographicItem:
|
178
|
+
[relaton-nist] (NIST SP 800-67r1) Fetching from csrc.nist.gov ...
|
179
|
+
[relaton-nist] (NIST SP 800-67r1) Found: `NIST SP 800-67 Rev. 1`
|
180
|
+
=> #<RelatonNist::NistBibliographicItem:0x00000001105acd08
|
178
181
|
...
|
179
182
|
|
180
183
|
item.docidentifier.first.id
|
181
|
-
=> "SP 800-67 Rev. 1"
|
184
|
+
=> "NIST SP 800-67 Rev. 1"
|
182
185
|
|
183
|
-
item = RelatonNist::NistBibliography.get 'SP 800-38A/Add'
|
184
|
-
[relaton-nist] (SP 800-38A/Add)
|
185
|
-
[relaton-nist] (SP 800-38A/Add)
|
186
|
-
=> #<RelatonNist::NistBibliographicItem:
|
186
|
+
item = RelatonNist::NistBibliography.get 'NIST SP 800-38A/Add'
|
187
|
+
[relaton-nist] (NIST SP 800-38A/Add) Fetching from csrc.nist.gov ...
|
188
|
+
[relaton-nist] (NIST SP 800-38A/Add) Found: `NIST SP 800-38A-Add`
|
189
|
+
=> #<RelatonNist::NistBibliographicItem:0x00000001105abf48
|
187
190
|
...
|
188
191
|
|
189
192
|
item.docidentifier.first.id
|
190
|
-
=> "SP 800-38A-Add"
|
193
|
+
=> "NIST SP 800-38A-Add"
|
191
194
|
----
|
192
195
|
|
193
196
|
=== Typed links
|
@@ -197,8 +200,12 @@ NIST documents may have `src` and `doi` link types.
|
|
197
200
|
[source,ruby]
|
198
201
|
----
|
199
202
|
item.link
|
200
|
-
=> [#<RelatonBib::TypedUri:
|
201
|
-
|
203
|
+
=> [#<RelatonBib::TypedUri:0x0000000111087a98
|
204
|
+
@content=#<Addressable::URI:0x8c0 URI:https://csrc.nist.gov/pubs/sp/800/38/a/sup/final>,
|
205
|
+
@language=nil,
|
206
|
+
@script=nil,
|
207
|
+
@type="src">,
|
208
|
+
#<RelatonBib::TypedUri:0x00000001110879a8 @content=#<Addressable::URI:0x8d4 URI:https://doi.org/10.6028/NIST.SP.800-38A-Add>, @language=nil, @script=nil, @type="doi">]
|
202
209
|
----
|
203
210
|
|
204
211
|
=== Create bibliographic item from YAML
|
data/grammars/basicdoc.rng
CHANGED
@@ -346,6 +346,8 @@
|
|
346
346
|
<ref name="keyword"/>
|
347
347
|
<ref name="xref"/>
|
348
348
|
<ref name="hyperlink"/>
|
349
|
+
<ref name="index"/>
|
350
|
+
<ref name="index-xref"/>
|
349
351
|
</choice>
|
350
352
|
</oneOrMore>
|
351
353
|
</element>
|
@@ -623,6 +625,8 @@
|
|
623
625
|
<ref name="eref"/>
|
624
626
|
<ref name="xref"/>
|
625
627
|
<ref name="hyperlink"/>
|
628
|
+
<ref name="index"/>
|
629
|
+
<ref name="index-xref"/>
|
626
630
|
</choice>
|
627
631
|
</zeroOrMore>
|
628
632
|
</element>
|
@@ -636,6 +640,8 @@
|
|
636
640
|
<ref name="eref"/>
|
637
641
|
<ref name="xref"/>
|
638
642
|
<ref name="hyperlink"/>
|
643
|
+
<ref name="index"/>
|
644
|
+
<ref name="index-xref"/>
|
639
645
|
</choice>
|
640
646
|
</zeroOrMore>
|
641
647
|
</element>
|
@@ -648,6 +654,8 @@
|
|
648
654
|
<ref name="eref"/>
|
649
655
|
<ref name="xref"/>
|
650
656
|
<ref name="hyperlink"/>
|
657
|
+
<ref name="index"/>
|
658
|
+
<ref name="index-xref"/>
|
651
659
|
</choice>
|
652
660
|
</zeroOrMore>
|
653
661
|
</element>
|
@@ -655,7 +663,11 @@
|
|
655
663
|
<define name="keyword">
|
656
664
|
<element name="keyword">
|
657
665
|
<zeroOrMore>
|
658
|
-
<
|
666
|
+
<choice>
|
667
|
+
<ref name="PureTextElement"/>
|
668
|
+
<ref name="index"/>
|
669
|
+
<ref name="index-xref"/>
|
670
|
+
</choice>
|
659
671
|
</zeroOrMore>
|
660
672
|
</element>
|
661
673
|
</define>
|
@@ -676,7 +688,11 @@
|
|
676
688
|
<define name="strike">
|
677
689
|
<element name="strike">
|
678
690
|
<zeroOrMore>
|
679
|
-
<
|
691
|
+
<choice>
|
692
|
+
<ref name="PureTextElement"/>
|
693
|
+
<ref name="index"/>
|
694
|
+
<ref name="index-xref"/>
|
695
|
+
</choice>
|
680
696
|
</zeroOrMore>
|
681
697
|
</element>
|
682
698
|
</define>
|
data/grammars/biblio.rng
CHANGED
@@ -1,49 +1,50 @@
|
|
1
1
|
module RelatonNist
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
2
|
+
module HashConverter
|
3
|
+
include RelatonBib::HashConverter
|
4
|
+
extend self
|
5
|
+
|
6
|
+
# @override RelatonBib::HashConverter.hash_to_bib
|
7
|
+
# @param args [Hash]
|
8
|
+
# @param nested [TrueClass, FalseClass]
|
9
|
+
# @return [Hash]
|
10
|
+
def hash_to_bib(args)
|
11
|
+
ret = super
|
12
|
+
return if ret.nil?
|
13
|
+
|
14
|
+
commentperiod_hash_to_bib(ret)
|
15
|
+
ret
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# @param item_hash [Hash]
|
21
|
+
# @return [RelatonNist::NistBibliographicItem]
|
22
|
+
def bib_item(item_hash)
|
23
|
+
NistBibliographicItem.new(**item_hash)
|
24
|
+
end
|
25
|
+
|
26
|
+
def commentperiod_hash_to_bib(ret)
|
27
|
+
return unless ret[:commentperiod]
|
28
|
+
|
29
|
+
ret[:commentperiod] = CommentPeriod.new(**ret[:commentperiod])
|
30
|
+
end
|
31
|
+
|
32
|
+
# @param ret [Hash]
|
33
|
+
def relations_hash_to_bib(ret)
|
34
|
+
super
|
35
|
+
return unless ret[:relation]
|
36
|
+
|
37
|
+
ret[:relation] = ret[:relation].map { |r| DocumentRelation.new(**r) }
|
38
|
+
|
39
|
+
# ret[:relation] = array(ret[:relation])
|
40
|
+
# ret[:relation]&.each do |r|
|
41
|
+
# if r[:description]
|
42
|
+
# r[:description] = FormattedString.new r[:description]
|
43
|
+
# end
|
44
|
+
# relation_bibitem_hash_to_bib(r)
|
45
|
+
# relation_locality_hash_to_bib(r)
|
46
|
+
# relation_source_locality_hash_to_bib(r)
|
47
|
+
# end
|
47
48
|
end
|
48
49
|
end
|
49
50
|
end
|
@@ -12,6 +12,9 @@ module RelatonNist
|
|
12
12
|
GHNISTDATA = "https://raw.githubusercontent.com/relaton/relaton-data-nist/main/"
|
13
13
|
INDEX_FILE = "index-v1.yaml"
|
14
14
|
|
15
|
+
attr_reader :reference
|
16
|
+
attr_accessor :array
|
17
|
+
|
15
18
|
#
|
16
19
|
# @param [String] text reference
|
17
20
|
# @param [String, nil] year reference
|
@@ -20,6 +23,7 @@ module RelatonNist
|
|
20
23
|
#
|
21
24
|
def initialize(text, year = nil, opts = {})
|
22
25
|
super text, year
|
26
|
+
@reference = year && !text.match?(/:\d{4}$/) ? "#{text}:#{year}" : text
|
23
27
|
@opts = opts
|
24
28
|
end
|
25
29
|
|
@@ -54,16 +58,21 @@ module RelatonNist
|
|
54
58
|
# @return [Array<RelatonNist::Hit>] hits
|
55
59
|
#
|
56
60
|
def search_filter # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
|
57
|
-
@array.select do |item|
|
61
|
+
arr = @array.select do |item|
|
58
62
|
parts = doi_parts(item.hit[:json]) || code_parts(item.hit[:code])
|
63
|
+
iteration = item.hit.dig(:json, "iteration")
|
64
|
+
draft = parts[:draft] || (!iteration.nil? && iteration.match?(/\wpd/i))
|
59
65
|
refparts[:code] && [parts[:series], item.hit[:series]].include?(refparts[:series]) &&
|
60
66
|
refparts[:code].casecmp(parts[:code].upcase).zero? &&
|
61
67
|
refparts[:prt] == parts[:prt] &&
|
62
68
|
(refparts[:vol].nil? || refparts[:vol] == parts[:vol]) &&
|
63
69
|
(refparts[:ver].nil? || refparts[:ver] == parts[:ver]) &&
|
64
70
|
(refparts[:rev].nil? || refparts[:rev] == parts[:rev]) &&
|
65
|
-
refparts[:draft] ==
|
71
|
+
refparts[:draft] == draft && refparts[:add] == parts[:add]
|
66
72
|
end
|
73
|
+
dup = self.dup
|
74
|
+
dup.array = arr
|
75
|
+
dup
|
67
76
|
end
|
68
77
|
|
69
78
|
private
|
@@ -99,7 +108,7 @@ module RelatonNist
|
|
99
108
|
ver: match(/v(?:er)?(?<val>[\d.]+)/, id),
|
100
109
|
rev: match(/r(?<val>\d+)/, id),
|
101
110
|
add: match(/-Add(?<val>\d*)/, id),
|
102
|
-
draft: !match(/\.ipd/, id).nil?,
|
111
|
+
draft: !match(/\.ipd|-draft/, id).nil?,
|
103
112
|
}
|
104
113
|
end
|
105
114
|
|
@@ -181,7 +190,10 @@ module RelatonNist
|
|
181
190
|
# @raise [OpenURI::HTTPError] if GitHub repo is not available
|
182
191
|
#
|
183
192
|
def from_ga # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
193
|
+
Util.warn "(#{@reference}) Fetching from Relaton repository ..."
|
184
194
|
ref = full_ref
|
195
|
+
return [] if ref.empty?
|
196
|
+
|
185
197
|
# fn = ref.gsub(%r{[/\s:.]}, "_").upcase
|
186
198
|
index = Relaton::Index.find_or_create :nist, url: "#{GHNISTDATA}index-v1.zip", file: INDEX_FILE
|
187
199
|
rows = index.search(ref).sort_by { |r| r[:id] }
|
@@ -209,20 +221,20 @@ module RelatonNist
|
|
209
221
|
#
|
210
222
|
# @return [Array<RelatonNist::Hit>] hits
|
211
223
|
#
|
212
|
-
def from_json
|
224
|
+
def from_json # rubocop:disable Metrics/AbcSize
|
225
|
+
Util.warn "(#{@reference}) Fetching from csrc.nist.gov ..."
|
213
226
|
select_data.map do |h|
|
214
227
|
/(?<series>(?<=-)\w+$)/ =~ h["series"]
|
215
228
|
title = [h["title-main"], h["title-sub"]].compact.join " - "
|
216
229
|
release_date = RelatonBib.parse_date h["published-date"], false
|
217
|
-
Hit.new({ code: docidentifier(h), series: series.upcase, title: title,
|
218
|
-
|
219
|
-
release_date: release_date, json: h }, self)
|
230
|
+
Hit.new({ code: docidentifier(h), series: series.upcase, title: title, url: h["uri"],
|
231
|
+
status: h["status"], release_date: release_date, json: h }, self)
|
220
232
|
end
|
221
233
|
end
|
222
234
|
|
223
235
|
def docidentifier(json) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
|
224
|
-
parts = doi_parts json
|
225
|
-
return json["docidentifier"] unless parts
|
236
|
+
parts = doi_parts(json) || code_parts(json["docidentifier"])
|
237
|
+
# return json["docidentifier"] unless parts
|
226
238
|
|
227
239
|
id = parts[:code]
|
228
240
|
id = "NIST #{parts[:series]} #{id}" if parts[:series]
|
@@ -1,8 +1,5 @@
|
|
1
1
|
module RelatonNist
|
2
2
|
class NistBibliographicItem < RelatonBib::BibliographicItem
|
3
|
-
# @return [String]
|
4
|
-
attr_reader :doctype
|
5
|
-
|
6
3
|
# @return [Array<RelatonNist::Keyword>]
|
7
4
|
# attr_reader :keyword
|
8
5
|
|
@@ -88,7 +85,7 @@ module RelatonNist
|
|
88
85
|
super date_format: :short, **opts do |b|
|
89
86
|
if opts[:bibdata]
|
90
87
|
ext = b.ext do
|
91
|
-
|
88
|
+
doctype&.to_xml b
|
92
89
|
commentperiod&.to_xml b
|
93
90
|
end
|
94
91
|
ext["schema-version"] = ext_schema unless opts[:embedded]
|
@@ -84,10 +84,10 @@ module RelatonNist
|
|
84
84
|
result = nistbib_search_filter(code, year, opts) || (return nil)
|
85
85
|
ret = nistbib_results_filter(result, year, opts)
|
86
86
|
if ret[:ret]
|
87
|
-
Util.warn "(#{
|
87
|
+
Util.warn "(#{result.reference}) Found: `#{ret[:ret].docidentifier.first.id}`"
|
88
88
|
ret[:ret]
|
89
89
|
else
|
90
|
-
fetch_ref_err(
|
90
|
+
fetch_ref_err(result.reference, year, ret[:years])
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
@@ -114,20 +114,19 @@ module RelatonNist
|
|
114
114
|
when "F" then "final"
|
115
115
|
else iter
|
116
116
|
end
|
117
|
-
result.
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
117
|
+
result.each do |h|
|
118
|
+
r = h.fetch
|
119
|
+
if opts[:date]
|
120
|
+
dates = r.date.select { |d| d.on(:date) == opts[:date] }
|
121
|
+
next if dates.empty?
|
122
|
+
end
|
123
|
+
next if iter && r.status.iteration != iteration
|
124
|
+
return { ret: r } if !year
|
125
125
|
|
126
|
-
|
127
|
-
|
126
|
+
r.date.select { |d| d.type == "published" }.each do |d|
|
127
|
+
return { ret: r } if year.to_i == d.on(:year)
|
128
128
|
|
129
|
-
|
130
|
-
end
|
129
|
+
missed_years << d.on(:year)
|
131
130
|
end
|
132
131
|
end
|
133
132
|
{ years: missed_years }
|
@@ -141,13 +140,13 @@ module RelatonNist
|
|
141
140
|
#
|
142
141
|
# @return [Array<RelatonNist::NistBibliographicItem>] bibliographic items
|
143
142
|
#
|
144
|
-
def fetch_pages(hits, threads)
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
end
|
143
|
+
# def fetch_pages(hits, threads)
|
144
|
+
# workers = RelatonBib::WorkersPool.new threads
|
145
|
+
# workers.worker { |w| { i: w[:i], hit: w[:hit].fetch } }
|
146
|
+
# hits.each_with_index { |hit, i| workers << { i: i, hit: hit } }
|
147
|
+
# workers.end
|
148
|
+
# workers.result.sort_by { |a| a[:i] }.map { |x| x[:hit] }
|
149
|
+
# end
|
151
150
|
|
152
151
|
#
|
153
152
|
# Get search results and filter them by code and year
|
@@ -160,7 +159,6 @@ module RelatonNist
|
|
160
159
|
# @return [RelatonNist::HitCollection] hits collection
|
161
160
|
#
|
162
161
|
def nistbib_search_filter(code, year, opts)
|
163
|
-
Util.warn "(#{code}) fetching..."
|
164
162
|
result = search(code, year, opts)
|
165
163
|
result.search_filter
|
166
164
|
end
|
@@ -168,21 +166,19 @@ module RelatonNist
|
|
168
166
|
#
|
169
167
|
# Outputs warning message if no match found
|
170
168
|
#
|
171
|
-
# @param [String]
|
169
|
+
# @param [String] ref reference
|
172
170
|
# @param [String, nil] year year
|
173
171
|
# @param [Array<String>] missed_years missed years
|
174
172
|
#
|
175
173
|
# @return [nil] nil
|
176
174
|
#
|
177
|
-
def fetch_ref_err(
|
178
|
-
|
179
|
-
Util.warn "WARNING: no match found online for `#{id}`. " \
|
180
|
-
"The code must be exactly like it is on the standards website."
|
175
|
+
def fetch_ref_err(ref, year, missed_years)
|
176
|
+
Util.warn "(#{ref}) No found."
|
181
177
|
unless missed_years.empty?
|
182
178
|
Util.warn "(There was no match for #{year}, though there " \
|
183
179
|
"were matches found for `#{missed_years.join('`, `')}`.)"
|
184
180
|
end
|
185
|
-
if /\d-\d/.match?
|
181
|
+
if /\d-\d/.match? ref
|
186
182
|
Util.warn "The provided document part may not exist, " \
|
187
183
|
"or the document may no longer be published in parts."
|
188
184
|
end
|
@@ -32,7 +32,7 @@ module RelatonNist
|
|
32
32
|
item_data[:fetched] = Date.today.to_s
|
33
33
|
item_data[:type] = "standard"
|
34
34
|
item_data[:title] = titles
|
35
|
-
item_data[:doctype] = "standard"
|
35
|
+
item_data[:doctype] = RelatonBib::DocumentType.new(type: "standard")
|
36
36
|
|
37
37
|
NistBibliographicItem.new(**item_data)
|
38
38
|
end
|
@@ -51,7 +51,7 @@ module RelatonNist
|
|
51
51
|
script: [json["script"]],
|
52
52
|
docstatus: fetch_status(json), # hit_data[:status]),
|
53
53
|
copyright: fetch_copyright(json["published-date"]),
|
54
|
-
relation: fetch_relations_json(
|
54
|
+
relation: fetch_relations_json(hit_data),
|
55
55
|
place: ["Gaithersburg, MD"],
|
56
56
|
keyword: fetch_keywords(json),
|
57
57
|
commentperiod: fetch_commentperiod_json(json),
|
@@ -80,10 +80,18 @@ module RelatonNist
|
|
80
80
|
def fetch_status(doc)
|
81
81
|
stage = doc["status"]
|
82
82
|
subst = doc["substage"]
|
83
|
-
iter =
|
83
|
+
iter = iteration(doc["iteration"])
|
84
84
|
RelatonNist::DocumentStatus.new stage: stage, substage: subst, iteration: iter.to_s
|
85
85
|
end
|
86
86
|
|
87
|
+
def iteration(iter)
|
88
|
+
case iter
|
89
|
+
when "initial", "ipd" then 1
|
90
|
+
when /(\d)pd/i then $1
|
91
|
+
else iter
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
87
95
|
# Fetch titles.
|
88
96
|
# @param hit_data [Hash]
|
89
97
|
# @return [Array<Hash>]
|
@@ -109,7 +117,7 @@ module RelatonNist
|
|
109
117
|
# d = doc.at("//span[@id='pub-release-date']")&.text&.strip
|
110
118
|
# issued = RelatonBib.parse_date d
|
111
119
|
# end
|
112
|
-
dates << { type: "issued", on: issued.to_s }
|
120
|
+
dates << { type: "issued", on: issued.to_s } if issued
|
113
121
|
dates
|
114
122
|
end
|
115
123
|
|
@@ -182,9 +190,9 @@ module RelatonNist
|
|
182
190
|
# @return [String, NilClass]
|
183
191
|
def fetch_edition(doc)
|
184
192
|
# if doc.is_a? Hash
|
185
|
-
return unless doc["edition"]
|
193
|
+
return unless doc["edition"] || doc["revision"]
|
186
194
|
|
187
|
-
rev = doc["edition"]
|
195
|
+
rev = doc["edition"] || doc["revision"]
|
188
196
|
"Revision #{rev}"
|
189
197
|
end
|
190
198
|
|
@@ -210,13 +218,14 @@ module RelatonNist
|
|
210
218
|
links
|
211
219
|
end
|
212
220
|
|
213
|
-
def fetch_relations_json(
|
221
|
+
def fetch_relations_json(hit)
|
222
|
+
doc = hit[:json]
|
214
223
|
relations = doc["supersedes"].map do |r|
|
215
|
-
doc_relation "supersedes",
|
224
|
+
doc_relation "supersedes", hit[:code], r["uri"]
|
216
225
|
end
|
217
226
|
|
218
227
|
relations + doc["superseded-by"].map do |r|
|
219
|
-
doc_relation "updates",
|
228
|
+
doc_relation "updates", hit[:code], r["uri"]
|
220
229
|
end
|
221
230
|
end
|
222
231
|
|
@@ -230,16 +239,11 @@ module RelatonNist
|
|
230
239
|
t = "obsoletes"
|
231
240
|
else t = type
|
232
241
|
end
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
content: ref, language: lang, script: script, format: "text/plain",
|
239
|
-
),
|
240
|
-
link: [RelatonBib::TypedUri.new(type: "src", content: uri)],
|
241
|
-
),
|
242
|
-
)
|
242
|
+
ids = [RelatonBib::DocumentIdentifier.new(id: ref, type: "NIST", primary: true)]
|
243
|
+
fref = RelatonBib::FormattedRef.new(content: ref, language: lang, script: script, format: "text/plain")
|
244
|
+
link = [RelatonBib::TypedUri.new(type: "src", content: uri)]
|
245
|
+
bib = RelatonBib::BibliographicItem.new(formattedref: fref, link: link, docid: ids)
|
246
|
+
DocumentRelation.new(type: t, description: descr, bibitem: bib)
|
243
247
|
end
|
244
248
|
|
245
249
|
# @param doc [Hash]
|
@@ -12,7 +12,7 @@ module RelatonNist
|
|
12
12
|
"hasPart" => "hasPart",
|
13
13
|
}.freeze
|
14
14
|
|
15
|
-
ATTRS = %i[docid title link abstract date edition contributor relation docstatus place series].freeze
|
15
|
+
ATTRS = %i[docid title link abstract date doctype edition contributor relation docstatus place series].freeze
|
16
16
|
NS = "http://www.crossref.org/relations.xsd".freeze
|
17
17
|
|
18
18
|
def initialize(doc, series)
|
@@ -41,8 +41,7 @@ module RelatonNist
|
|
41
41
|
#
|
42
42
|
def parse
|
43
43
|
RelatonNist::NistBibliographicItem.new(
|
44
|
-
type: "standard", language: [@doc["language"]], script: ["Latn"],
|
45
|
-
doctype: "standard", **args
|
44
|
+
type: "standard", language: [@doc["language"]], script: ["Latn"], **args
|
46
45
|
)
|
47
46
|
rescue StandardError => e
|
48
47
|
warn "Document: `#{@doc.at('doi').text}`"
|
@@ -135,6 +134,10 @@ module RelatonNist
|
|
135
134
|
end
|
136
135
|
end
|
137
136
|
|
137
|
+
def parse_doctype
|
138
|
+
RelatonBib::DocumentType.new(type: "standard")
|
139
|
+
end
|
140
|
+
|
138
141
|
# @return [String]
|
139
142
|
def parse_edition
|
140
143
|
@doc.at("edition_number")&.text
|
data/lib/relaton_nist/version.rb
CHANGED
data/relaton_nist.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
25
25
|
|
26
|
-
spec.add_dependency "relaton-bib", "~> 1.
|
26
|
+
spec.add_dependency "relaton-bib", "~> 1.17.0"
|
27
27
|
spec.add_dependency "relaton-index", "~> 0.2.0"
|
28
28
|
spec.add_dependency "rubyzip"
|
29
29
|
end
|
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.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: relaton-bib
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.17.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.17.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: relaton-index
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|