relaton-nist 1.12.2 → 1.12.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81b3111f5bb486625e9b8028bd607a00de151487d9b7114d88ba54f219b7cd07
4
- data.tar.gz: df54cc75c2228c28ce4e04e1faddbb672446560c99aad3f804308fd1a7eb57eb
3
+ metadata.gz: 4c73a4a75166a362d34e2d1a4bec088d74863cf1ac9a4eee0798cfa84cbceca6
4
+ data.tar.gz: 398bd9b074c7c10da66c86047e617e7b643ea6cc3e45f1daa6fdd6f43d38bb4c
5
5
  SHA512:
6
- metadata.gz: 2776eebb515b1ddbdb72f3ce4f31df912e2b2eb92eb7d6200462686d48676f17473e1668050fc4397cab720b1ff4e24b10b45df3cc8623413dfe0e75212f480c
7
- data.tar.gz: 14c30c1e0f58c26075e55a0f7c3ded41cac1a4122844fb11efe3cf1052b13048ceada426bfa0983bd28ef6b9f29b3e508ffbe7a405ea222b7885c8273b9db794
6
+ metadata.gz: 7695197e53d2d8b8b2048f034c6d47db2ce293f7f8dedafacefae8efb4ad85ed96169f5b317957a228b32bfa1e9a8899b80238aa8be594edd94e89619c9fbb51
7
+ data.tar.gz: 1b2eb51d32d0b0eb9456242e5727b891468509a55cdc2ce2251fa84857b83d6d29966bb3799557672da7cabc126949f0cc18d6581cb9464caa38293a317a7265
data/README.adoc CHANGED
@@ -1,4 +1,4 @@
1
- = RelatonNist: retrieve NIST Standards for bibliographic use using the BibliographicItem model
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
- RelatonNist is a Ruby gem that implements the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model].
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
 
@@ -137,26 +137,10 @@ module RelatonNist
137
137
 
138
138
  # @param doc [Nokogiri::XML::Element]
139
139
  # @return [Array<Hash>]
140
- def fetch_contributor(doc) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
140
+ def fetch_contributor(doc)
141
141
  contribs = doc.xpath("contributors/person_name").map do |p|
142
- forename = []
143
- initial = []
144
- p.at("given_name")&.text&.split&.each do |fn|
145
- if /^(?<init>\w)\.?$/ =~ fn
146
- initial << RelatonBib::LocalizedString.new(init, doc["language"], "Latn")
147
- else
148
- forename << RelatonBib::LocalizedString.new(fn, doc["language"], "Latn")
149
- end
150
- end
151
- sname = p.at("surname").text
152
- surname = RelatonBib::LocalizedString.new sname, doc["language"], "Latn"
153
- ident = p.xpath("ORCID").map do |id|
154
- RelatonBib::PersonIdentifier.new "orcid", id.text
155
- end
156
- fullname = RelatonBib::FullName.new(
157
- surname: surname, forename: forename, initial: initial, identifier: ident,
158
- )
159
- person = RelatonBib::Person.new name: fullname, affiliation: affiliation(doc)
142
+ person = RelatonBib::Person.new(name: fullname(p, doc),
143
+ affiliation: affiliation(doc))
160
144
  { entity: person, role: [{ type: p["contributor_role"] }] }
161
145
  end
162
146
  contribs + doc.xpath("publisher").map do |p|
@@ -164,6 +148,57 @@ module RelatonNist
164
148
  end
165
149
  end
166
150
 
151
+ #
152
+ # Create full name object from person name element.
153
+ #
154
+ # @param [Nokogiri::XML::Element] person name element
155
+ # @param [Nokogiri::XML::Element] doc document element
156
+ #
157
+ # @return [RelatonBib::FullName] full name object
158
+ #
159
+ def fullname(person, doc)
160
+ forename, initial = forename_initial(person, doc)
161
+ surname = localized_string person.at("surname").text, doc
162
+ ident = person.xpath("ORCID").map do |id|
163
+ RelatonBib::PersonIdentifier.new "orcid", id.text
164
+ end
165
+ RelatonBib::FullName.new(surname: surname, forename: forename,
166
+ initial: initial, identifier: ident)
167
+ end
168
+
169
+ #
170
+ # Create forename and initials objects from person name element.
171
+ #
172
+ # @param [Nokogiri::XML::Element] person person name element
173
+ # @param [Nokogiri::XML::Element] doc document element
174
+ #
175
+ # @return [Array<Array<RelatonBib::LocalizedString>>] forename and initials
176
+ #
177
+ def forename_initial(person, doc)
178
+ forename = []
179
+ initial = []
180
+ fname = person.at("given_name")&.text
181
+ if fname
182
+ if /^(?<inits>(?:\w[.\s]+|[A-Z]{1,2}$)+)$/ =~ fname
183
+ inits.split(/[.\s]*/).each { |i| initial << localized_string(i, doc) }
184
+ else forename << localized_string(fname, doc)
185
+ end
186
+ end
187
+ [forename, initial]
188
+ end
189
+
190
+ #
191
+ # Create localized string
192
+ #
193
+ # @param [String] content content of string
194
+ # @param [Nokogiri::XML::Elemrnt] doc XML element
195
+ #
196
+ # @return [RelatonBib::LocalizedString] localized string
197
+ #
198
+ def localized_string(content, doc)
199
+ RelatonBib::LocalizedString.new content, doc["language"], "Latn"
200
+ end
201
+
167
202
  #
168
203
  # Create publisher organization
169
204
  #
@@ -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[:serie], hit[:code], hit[:title]].join " "
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
- fn = text.gsub(%r{[/\s:.]}, "_").upcase
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
- /(?<serie>(?<=-)\w+$)/ =~ h["series"]
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"], serie: serie.upcase, title: title,
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? text
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
- HitCollection.search text, year, opts
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
- nistbib_get1(code, year, opts)
59
+ nistbib_get(code, year, opts)
59
60
  end
60
61
 
61
62
  private
62
63
 
63
- def nistbib_get1(code, year, opts)
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) # rubocop:disable Metrics/MethodLength
137
+ def nistbib_search_filter(code, year, opts)
137
138
  warn "[relaton-nist] (\"#{code}\") fetching..."
138
- # match = %r{
139
- # ^((?:NIST)\s)?
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
- "The code must be exactly like it is on the standards website."
236
- warn "[relaton-nist] (There was no match for #{year}, though there were matches "\
237
- "found for #{missed_years.join(', ')}.)" unless missed_years.empty?
238
- if /\d-\d/ =~ code
239
- warn "[relaton-nist] The provided document part may not exist, "\
240
- "or the document may no longer be published in parts."
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
@@ -1,3 +1,3 @@
1
1
  module RelatonNist
2
- VERSION = "1.12.2".freeze
2
+ VERSION = "1.12.5".freeze
3
3
  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.12.2
4
+ version: 1.12.5
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-02 00:00:00.000000000 Z
11
+ date: 2022-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml