relaton-nist 1.12.1 → 1.12.4
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 -3
- data/lib/relaton_nist/data_fetcher.rb +1 -1
- data/lib/relaton_nist/hit.rb +1 -1
- data/lib/relaton_nist/hit_collection.rb +73 -45
- data/lib/relaton_nist/nist_bibliography.rb +18 -105
- data/lib/relaton_nist/processor.rb +1 -1
- data/lib/relaton_nist/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a08c33ae20e118a973b19b9697114dd4be09331bc3322a3d75250959c4cb0880
|
4
|
+
data.tar.gz: 1066aab4db2167b2551fd59a76248a96bbcfddbbcc11e0894cb16d91af0fe69c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0b46445fda68e042630f4eccfc925a317dbe22a3331fe5ef86eebcceb7a036134bedba1a2b6679987d4a2b727ee2590887d52a26c014adbbd27b382b70b2adc
|
7
|
+
data.tar.gz: cdc10291398c3f037a00f7a2b013f3a159ed1b8803a0d401522cfb4df0119036cd7b1a9cbfb28ebdf05819a4f365fd4bc0d284fc3031ef34311418e279e35eba
|
data/README.adoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
=
|
1
|
+
= Relaton for NIST: bibliographic retrieval of NIST publications
|
2
2
|
|
3
3
|
image:https://img.shields.io/gem/v/relaton-nist.svg["Gem Version", link="https://rubygems.org/gems/relaton-nist"]
|
4
4
|
image:https://github.com/relaton/relaton-nist/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/relaton/relaton-nist/actions?workflow=macos"]
|
@@ -8,10 +8,41 @@ image:https://codeclimate.com/github/relaton/relaton-nist/badges/gpa.svg["Code C
|
|
8
8
|
image:https://img.shields.io/github/issues-pr-raw/relaton/relaton-nist.svg["Pull Requests", link="https://github.com/relaton/relaton-nist/pulls"]
|
9
9
|
image:https://img.shields.io/github/commits-since/relaton/relaton-nist/latest.svg["Commits since latest",link="https://github.com/relaton/relaton-nist/releases"]
|
10
10
|
|
11
|
+
== Purpose
|
11
12
|
|
12
|
-
|
13
|
+
`relaton-nist` provides bibliographic information of NIST publications using the
|
14
|
+
https://github.com/metanorma/metanorma-model-nist#nist-bibliographic-item-model[NistBibliographicItem model].
|
15
|
+
|
16
|
+
Relaton for NIST has been developed in cooperation with the NIST Cybersecurity
|
17
|
+
Resource Center (CSRC) and the Computer Security Division (ITL/CSD).
|
18
|
+
|
19
|
+
== Data sources
|
20
|
+
|
21
|
+
Relaton for NIST retrieves bibliographic information from two sources:
|
22
|
+
|
23
|
+
* bibliographic feed from the NIST Cybersecurity Resource Center (CSRC) of
|
24
|
+
all CSRC publications (in Relaton JSON)
|
25
|
+
* bibliographic dataset from the NIST Library through the Information Services
|
26
|
+
Office (ISO) that contains information about all NIST Technical Publications
|
27
|
+
(https://github.com/usnistgov/NIST-Tech-Pubs[GitHub])
|
28
|
+
|
29
|
+
Bibliographic information offered through CSRC are provided with enhanced
|
30
|
+
metadata that is not available at the NIST Library dataset, including:
|
31
|
+
|
32
|
+
* public drafts (the NIST Library dataset only contains final publications)
|
33
|
+
* revision information: revision number, iteration
|
34
|
+
* document stage information: retired, withdrawn, etc.
|
35
|
+
* bibliographic dates, including issued date, updated date, published date,
|
36
|
+
obsolete date, commenting period
|
37
|
+
* document relationships: supersession and replacements
|
38
|
+
* contacts: enhanced name parts and affiliation information
|
39
|
+
|
40
|
+
Relaton for NIST therefore uses the following order of priority for the data
|
41
|
+
sources:
|
42
|
+
|
43
|
+
. bibliographic feed from NIST CSRC
|
44
|
+
. NIST Library dataset
|
13
45
|
|
14
|
-
You can use it to retrieve metadata of NIST Standards from https://csrc.nist.gov, and access such metadata through the `IsoBibliographicItem` object.
|
15
46
|
|
16
47
|
== Installation
|
17
48
|
|
@@ -217,7 +217,7 @@ module RelatonNist
|
|
217
217
|
prf, srs, num = pub_id(doc).split
|
218
218
|
sname = series[srs] || srs
|
219
219
|
title = RelatonBib::TypedTitleString.new(content: "#{prf} #{sname}")
|
220
|
-
abbr = RelatonBib::LocalizedString.new
|
220
|
+
abbr = RelatonBib::LocalizedString.new srs
|
221
221
|
[RelatonBib::Series.new(title: title, abbreviation: abbr, number: num)]
|
222
222
|
end
|
223
223
|
|
data/lib/relaton_nist/hit.rb
CHANGED
@@ -14,7 +14,7 @@ module RelatonNist
|
|
14
14
|
# @return [Iteger]
|
15
15
|
def sort_value # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
16
16
|
@sort_value ||= begin
|
17
|
-
sort_phrase = [hit[:
|
17
|
+
sort_phrase = [hit[:series], hit[:code], hit[:title]].join " "
|
18
18
|
corr = hit_collection&.text&.split&.map do |w|
|
19
19
|
if w =~ /\w+/ &&
|
20
20
|
sort_phrase =~ Regexp.new(Regexp.escape(w), Regexp::IGNORECASE)
|
@@ -25,8 +25,75 @@ module RelatonNist
|
|
25
25
|
sort_hits!
|
26
26
|
end
|
27
27
|
|
28
|
+
# @return [Array<RelatonNist::Hit>]
|
29
|
+
def search_filter # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
30
|
+
@array.select do |item|
|
31
|
+
%r{
|
32
|
+
^(?:(?:NIST|NBS)\s?)?
|
33
|
+
(?:(?<series>(?:SP|FIPS|IR|ITL\sBulletin|White\sPaper))\s)?
|
34
|
+
(?<code>[0-9-]{3,}[A-Z]?)
|
35
|
+
(?<prt1>pt\d+)?
|
36
|
+
(?<vol1>v\d+)?
|
37
|
+
(?<ver1>ver[\d.]+)?
|
38
|
+
(?<rev1>r\d+)?
|
39
|
+
(?:\s(?<prt2>Part\s\d+))?
|
40
|
+
(?:\s(?<vol2>Vol\.\s\d+))?
|
41
|
+
(?:\s(?<ver2>(?:Ver\.|Version)\s[\d.]+))?
|
42
|
+
(?:\s(?<rev2>Rev\.\s\d+))?
|
43
|
+
(?:\s(?<add>Add)endum)?
|
44
|
+
}x =~ item.hit[:code]
|
45
|
+
(refparts[:code] && [series, item.hit[:series]].include?(refparts[:series]) && refparts[:code] == code &&
|
46
|
+
long_to_short(refparts[:prt1], refparts[:prt2]) == long_to_short(prt1, prt2) &&
|
47
|
+
long_to_short(refparts[:vol1], refparts[:vol2]) == long_to_short(vol1, vol2) &&
|
48
|
+
long_to_short(refparts[:ver1], refparts[:ver2]) == long_to_short(ver1, ver2) &&
|
49
|
+
long_to_short(refparts[:rev1], refparts[:rev2]) == long_to_short(rev1, rev2) &&
|
50
|
+
long_to_short(refparts[:add1], refparts[:add2]) == add) || item.hit[:title]&.include?(text.sub(/^NIST\s/, ""))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
28
54
|
private
|
29
55
|
|
56
|
+
def refparts # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
57
|
+
@refparts ||= {
|
58
|
+
perfix: match(/^(NIST|NBS)\s?/, text),
|
59
|
+
series: match(/(SP|FIPS|IR|ITL\sBulletin|White\sPaper)(?=\.|\s)/, text),
|
60
|
+
code: match(/(?<=\.|\s)[0-9-]{3,}[A-Z]?/, text),
|
61
|
+
prt1: match(/(?<=(\.))?pt(?(1)-)[A-Z\d]+/, text),
|
62
|
+
vol1: match(/(?<=(\.))?v(?(1)-)\d+/, text),
|
63
|
+
ver1: match(/(?<=(\.))?ver(?(1)[-\d]|[.\d])+/, text)&.gsub(/-/, "."),
|
64
|
+
rev1: match(/(?<=[^a-z])(?<=(\.))?r(?(1)-)\d+/, text),
|
65
|
+
add1: match(/(?<=(\.))?add(?(1)-)\d+/, text),
|
66
|
+
prt2: match(/(?<=\s)Part\s[A-Z\d]+/, text),
|
67
|
+
vol2: match(/(?<=\s)Vol\.\s\d+/, text),
|
68
|
+
ver2: match(/(?<=\s)Ver\.\s\d+/, text),
|
69
|
+
rev2: match(/(?<=\s)Rev\.\s\d+/, text),
|
70
|
+
add2: match(/(?<=\/)Add/, text),
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
def match(regex, code)
|
75
|
+
regex.match(code)&.to_s
|
76
|
+
end
|
77
|
+
|
78
|
+
def full_ref # rubocop:disable Metrics/AbcSize
|
79
|
+
@full_ref ||= begin
|
80
|
+
ref = "#{refparts[:perfix]}#{refparts[:series]} #{refparts[:code]}"
|
81
|
+
ref += long_to_short(refparts[:prt1], refparts[:prt2]).to_s
|
82
|
+
ref += long_to_short(refparts[:vol1], refparts[:vol2]).to_s
|
83
|
+
ref
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# @param short [String]
|
88
|
+
# @param long [String]
|
89
|
+
# @return [String, nil]
|
90
|
+
def long_to_short(short, long)
|
91
|
+
return short.sub(/-/, "") if short
|
92
|
+
return unless long
|
93
|
+
|
94
|
+
long.sub(/Part\s/, "pt").sub(/Vol\.\s/, "v").sub(/Rev\.\s/, "r").sub(/(Ver\.|Version)\s/, "ver")
|
95
|
+
end
|
96
|
+
|
30
97
|
def sort_hits!
|
31
98
|
@array.sort! do |a, b|
|
32
99
|
if a.sort_value == b.sort_value
|
@@ -39,7 +106,8 @@ module RelatonNist
|
|
39
106
|
end
|
40
107
|
|
41
108
|
def from_ga # rubocop:disable Metrics/AbcSize
|
42
|
-
|
109
|
+
ref = full_ref
|
110
|
+
fn = ref.gsub(%r{[/\s:.]}, "_").upcase
|
43
111
|
yaml = OpenURI.open_uri "#{GHNISTDATA}#{fn}.yaml"
|
44
112
|
hash = YAML.safe_load yaml
|
45
113
|
bib = RelatonNist::NistBibliographicItem.from_hash hash
|
@@ -52,55 +120,15 @@ module RelatonNist
|
|
52
120
|
raise e
|
53
121
|
end
|
54
122
|
|
55
|
-
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
56
|
-
|
57
|
-
# @param stage [String]
|
58
|
-
# @return [Array<RelatonNist::Hit>]
|
59
|
-
# def from_csrc(**opts)
|
60
|
-
# from, to = nil
|
61
|
-
# if year
|
62
|
-
# d = Date.strptime year, "%Y"
|
63
|
-
# from = d.strftime "%m/%d/%Y"
|
64
|
-
# to = d.next_year.prev_day.strftime "%m/%d/%Y"
|
65
|
-
# end
|
66
|
-
# url = "#{DOMAIN}/publications/search?keywords-lg=#{text}"\
|
67
|
-
# "&sortBy-lg=relevence"
|
68
|
-
# url += "&dateFrom-lg=#{from}" if from
|
69
|
-
# url += "&dateTo-lg=#{to}" if to
|
70
|
-
# url += if /PD/.match? opts[:stage]
|
71
|
-
# "&status-lg=Draft,Retired Draft,Withdrawn"
|
72
|
-
# else
|
73
|
-
# "&status-lg=Final,Withdrawn"
|
74
|
-
# end
|
75
|
-
|
76
|
-
# doc = Nokogiri::HTML OpenURI.open_uri(::Addressable::URI.parse(url).normalize)
|
77
|
-
# doc.css("table.publications-table > tbody > tr").map do |h|
|
78
|
-
# link = h.at("td/div/strong/a")
|
79
|
-
# serie = h.at("td[1]").text.strip
|
80
|
-
# code = h.at("td[2]").text.strip
|
81
|
-
# title = link.text
|
82
|
-
# doc_url = DOMAIN + link[:href]
|
83
|
-
# status = h.at("td[4]").text.strip.downcase
|
84
|
-
# release_date = Date.strptime h.at("td[5]").text.strip, "%m/%d/%Y"
|
85
|
-
# Hit.new(
|
86
|
-
# {
|
87
|
-
# code: code, serie: serie, title: title, url: doc_url,
|
88
|
-
# status: status, release_date: release_date
|
89
|
-
# }, self
|
90
|
-
# )
|
91
|
-
# end
|
92
|
-
# end
|
93
|
-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
94
|
-
|
95
123
|
# Fetches data form json
|
96
124
|
# @param stage [String]
|
97
125
|
# @return [Array<RelatonNist::Hit>]
|
98
126
|
def from_json(**opts)
|
99
127
|
select_data(**opts).map do |h|
|
100
|
-
/(?<
|
128
|
+
/(?<series>(?<=-)\w+$)/ =~ h["series"]
|
101
129
|
title = [h["title-main"], h["title-sub"]].compact.join " - "
|
102
130
|
release_date = RelatonBib.parse_date h["published-date"], false
|
103
|
-
Hit.new({ code: h["docidentifier"],
|
131
|
+
Hit.new({ code: h["docidentifier"], series: series.upcase, title: title,
|
104
132
|
url: h["uri"], status: h["status"],
|
105
133
|
release_date: release_date, json: h }, self)
|
106
134
|
end
|
@@ -109,6 +137,7 @@ module RelatonNist
|
|
109
137
|
# @param stage [String]
|
110
138
|
# @return [Array<Hach>]
|
111
139
|
def select_data(**opts) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength,Metrics/PerceivedComplexity
|
140
|
+
ref = "#{refparts[:series]} #{refparts[:code]}"
|
112
141
|
d = Date.strptime year, "%Y" if year
|
113
142
|
statuses = %w[draft-public draft-prelim]
|
114
143
|
data.select do |doc|
|
@@ -119,7 +148,7 @@ module RelatonNist
|
|
119
148
|
else
|
120
149
|
next unless doc["status"] == "final"
|
121
150
|
end
|
122
|
-
doc["docidentifier"].include?
|
151
|
+
doc["docidentifier"].include?(ref) || doc["docidentifier"].include?(full_ref)
|
123
152
|
end
|
124
153
|
end
|
125
154
|
|
@@ -147,7 +176,6 @@ module RelatonNist
|
|
147
176
|
#
|
148
177
|
# @prarm ctime [Time, NilClass]
|
149
178
|
def fetch_data(ctime)
|
150
|
-
# resp = OpenURI.open_uri("#{PUBS_EXPORT}.meta")
|
151
179
|
if !ctime || ctime < OpenURI.open_uri("#{PUBS_EXPORT}.meta").last_modified
|
152
180
|
@data = nil
|
153
181
|
uri_open = URI.method(:open) || Kernel.method(:open)
|
@@ -14,7 +14,8 @@ module RelatonNist
|
|
14
14
|
# @param text [String]
|
15
15
|
# @return [RelatonNist::HitCollection]
|
16
16
|
def search(text, year = nil, opts = {})
|
17
|
-
|
17
|
+
ref = text.sub(/^NIST\sIR/, "NISTIR")
|
18
|
+
HitCollection.search ref, year, opts
|
18
19
|
rescue OpenURI::HTTPError, SocketError, OpenSSL::SSL::SSLError => e
|
19
20
|
raise RelatonBib::RequestError, e.message
|
20
21
|
end
|
@@ -55,12 +56,12 @@ module RelatonNist
|
|
55
56
|
end
|
56
57
|
|
57
58
|
code += "-1" if opts[:all_parts]
|
58
|
-
|
59
|
+
nistbib_get(code, year, opts)
|
59
60
|
end
|
60
61
|
|
61
62
|
private
|
62
63
|
|
63
|
-
def
|
64
|
+
def nistbib_get(code, year, opts)
|
64
65
|
result = nistbib_search_filter(code, year, opts) || (return nil)
|
65
66
|
ret = nistbib_results_filter(result, year, opts)
|
66
67
|
if ret[:ret]
|
@@ -84,7 +85,7 @@ module RelatonNist
|
|
84
85
|
# @option opts [String] :stage
|
85
86
|
#
|
86
87
|
# @return [Hash]
|
87
|
-
def nistbib_results_filter(result, year, opts)
|
88
|
+
def nistbib_results_filter(result, year, opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
88
89
|
missed_years = []
|
89
90
|
iter = /\w+(?=PD)|(?<=PD-)\w+/.match(opts[:stage])&.to_s
|
90
91
|
iteration = case iter
|
@@ -133,111 +134,23 @@ module RelatonNist
|
|
133
134
|
# @param year [String, nil]
|
134
135
|
# @param opts [Hash]
|
135
136
|
# @return [RelatonNist::HitCollection]
|
136
|
-
def nistbib_search_filter(code, year, opts)
|
137
|
+
def nistbib_search_filter(code, year, opts)
|
137
138
|
warn "[relaton-nist] (\"#{code}\") fetching..."
|
138
|
-
|
139
|
-
|
140
|
-
# (?<serie>(SP|FIPS|NISTIR|ITL\sBulletin|White\sPaper))\s
|
141
|
-
# (?<code>[0-9-]{3,}[A-Z]?)
|
142
|
-
# (?<prt1>pt\d+)?
|
143
|
-
# (?<vol1>v\d+)?
|
144
|
-
# (?<ver1>ver[\d\.]+)?
|
145
|
-
# (?<rev1>r\d+)?
|
146
|
-
# (\s(?<prt2>Part\s\d+))?
|
147
|
-
# (\s(?<vol2>Vol\.\s\d+))?
|
148
|
-
# (\s(?<ver2>(Ver\.|Version)\s[\d\.]+))?
|
149
|
-
# (\s(?<rev2>Rev\.\s\d+))?
|
150
|
-
# (\/(?<upd>Add))?
|
151
|
-
# }x.match(code)
|
152
|
-
# match ||= %r{
|
153
|
-
# ^NIST\.
|
154
|
-
# (?<serie>(SP|FIPS|IR|ITL\sBulletin|White\sPaper))\.
|
155
|
-
# ((PD-\d+|PUB)\.)?
|
156
|
-
# (?<code>[0-9-]{3,}[A-Z]?)
|
157
|
-
# (\.(?<prt1>pt-\d+))?
|
158
|
-
# (\.(?<vol1>v-\d+))?
|
159
|
-
# (\.(?<ver1>ver-[\d\.]+))?
|
160
|
-
# (\.(?<rev1>r-\d+))?
|
161
|
-
# }x.match(code)
|
162
|
-
matches = {
|
163
|
-
serie: match(/(SP|FIPS|(NIST)?IR|ITL\sBulletin|White\sPaper)(?=\.|\s)/, code),
|
164
|
-
code: match(/(?<=\.|\s)[0-9-]{3,}[A-Z]?/, code),
|
165
|
-
prt1: match(/(?<=(\.))?pt(?(1)-)[A-Z\d]+/, code),
|
166
|
-
vol1: match(/(?<=(\.))?v(?(1)-)\d+/, code),
|
167
|
-
ver1: match(/(?<=(\.))?ver(?(1)[-\d]|[\.\d])+/, code)&.gsub(/-/, "."),
|
168
|
-
rev1: match(/(?<=[^a-z])(?<=(\.))?r(?(1)-)\d+/, code),
|
169
|
-
add1: match(/(?<=(\.))?add(?(1)-)\d+/, code),
|
170
|
-
prt2: match(/(?<=\s)Part\s[A-Z\d]+/, code),
|
171
|
-
vol2: match(/(?<=\s)Vol\.\s\d+/, code),
|
172
|
-
ver2: match(/(?<=\s)Ver\.\s\d+/, code),
|
173
|
-
rev2: match(/(?<=\s)Rev\.\s\d+/, code),
|
174
|
-
add2: match(/(?<=\/)Add/, code),
|
175
|
-
}
|
176
|
-
ref = matches[:code] ? "#{matches[:serie]} #{matches[:code]}" : code
|
177
|
-
result = search(ref, year, opts)
|
178
|
-
selected_result = result.select { |i| search_filter i, matches, code }
|
179
|
-
return selected_result if selected_result.any? || !matches[:code]
|
180
|
-
|
181
|
-
search full_ref(matches)
|
182
|
-
end
|
183
|
-
|
184
|
-
def full_ref(matches)
|
185
|
-
ref = "#{matches[:serie]} #{matches[:code]}"
|
186
|
-
ref += long_to_short(matches[:prt1], matches[:prt2]).to_s
|
187
|
-
ref += long_to_short(matches[:vol1], matches[:vol2]).to_s
|
188
|
-
ref
|
189
|
-
end
|
190
|
-
|
191
|
-
def match(regex, code)
|
192
|
-
regex.match(code)&.to_s
|
193
|
-
end
|
194
|
-
|
195
|
-
# @param item [RelatonNist::Hit]
|
196
|
-
# @param matches [Hash]
|
197
|
-
# @param text [String]
|
198
|
-
# @return [Boolean]
|
199
|
-
def search_filter(item, matches, text) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
200
|
-
%r{
|
201
|
-
^((?:NIST)\s)?
|
202
|
-
((?<serie>(SP|FIPS|NISTIR|ITL\sBulletin|White\sPaper))\s)?
|
203
|
-
(?<code>[0-9-]{3,}[A-Z]?)
|
204
|
-
(?<prt1>pt\d+)?
|
205
|
-
(?<vol1>v\d+)?
|
206
|
-
(?<ver1>ver[\d.]+)?
|
207
|
-
(?<rev1>r\d+)?
|
208
|
-
(\s(?<prt2>Part\s\d+))?
|
209
|
-
(\s(?<vol2>Vol\.\s\d+))?
|
210
|
-
(\s(?<ver2>(Ver\.|Version)\s[\d.]+))?
|
211
|
-
(\s(?<rev2>Rev\.\s\d+))?
|
212
|
-
(\s(?<add>Add)endum)?
|
213
|
-
}x =~ item.hit[:code]
|
214
|
-
matches[:code] && [serie, item.hit[:serie]].include?(matches[:serie]) && matches[:code] == code &&
|
215
|
-
long_to_short(matches[:prt1], matches[:prt2]) == long_to_short(prt1, prt2) &&
|
216
|
-
long_to_short(matches[:vol1], matches[:vol2]) == long_to_short(vol1, vol2) &&
|
217
|
-
long_to_short(matches[:ver1], matches[:ver2]) == long_to_short(ver1, ver2) &&
|
218
|
-
long_to_short(matches[:rev1], matches[:rev2]) == long_to_short(rev1, rev2) &&
|
219
|
-
long_to_short(matches[:add1], matches[:add2]) == add || item.hit[:title].include?(text.sub(/^NIST\s/, ""))
|
220
|
-
end
|
221
|
-
|
222
|
-
# @param short [String]
|
223
|
-
# @param long [String]
|
224
|
-
# @return [String, nil]
|
225
|
-
def long_to_short(short, long)
|
226
|
-
return short.sub(/-/, "") if short
|
227
|
-
return unless long
|
228
|
-
|
229
|
-
long.sub(/Part\s/, "pt").sub(/Vol\.\s/, "v").sub(/Rev\.\s/, "r").sub(/(Ver\.|Version)\s/, "ver")
|
139
|
+
result = search(code, year, opts)
|
140
|
+
result.search_filter
|
230
141
|
end
|
231
142
|
|
232
|
-
def fetch_ref_err(code, year, missed_years)
|
143
|
+
def fetch_ref_err(code, year, missed_years) # rubocop:disable Metrics/MethodLength
|
233
144
|
id = year ? "#{code}:#{year}" : code
|
234
|
-
warn "[relaton-nist] WARNING: no match found online for #{id}. "\
|
235
|
-
|
236
|
-
|
237
|
-
"
|
238
|
-
|
239
|
-
|
240
|
-
|
145
|
+
warn "[relaton-nist] WARNING: no match found online for #{id}. " \
|
146
|
+
"The code must be exactly like it is on the standards website."
|
147
|
+
unless missed_years.empty?
|
148
|
+
warn "[relaton-nist] (There was no match for #{year}, though there " \
|
149
|
+
"were matches found for #{missed_years.join(', ')}.)"
|
150
|
+
end
|
151
|
+
if /\d-\d/.match? code
|
152
|
+
warn "[relaton-nist] The provided document part may not exist, " \
|
153
|
+
"or the document may no longer be published in parts."
|
241
154
|
end
|
242
155
|
nil
|
243
156
|
end
|
@@ -5,7 +5,7 @@ module RelatonNist
|
|
5
5
|
def initialize # rubocop:disable Lint/MissingSuper
|
6
6
|
@short = :relaton_nist
|
7
7
|
@prefix = "NIST"
|
8
|
-
@defaultprefix = %r{^(NIST|NISTGCR|ITL Bulletin|JPCRD|NISTIR|CSRC|FIPS)(/[^\s])?\s}
|
8
|
+
@defaultprefix = %r{^(NIST|NBS|NISTGCR|ITL Bulletin|JPCRD|NISTIR|CSRC|FIPS)(/[^\s])?\s}
|
9
9
|
@idtype = "NIST"
|
10
10
|
@datasets = %w[nist-tech-pubs]
|
11
11
|
end
|
data/lib/relaton_nist/version.rb
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.12.
|
4
|
+
version: 1.12.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|