relaton-nist 1.18.0 → 1.19.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 +7 -14
- data/grammars/basicdoc.rng +3 -0
- data/lib/relaton_nist/data_fetcher.rb +2 -3
- data/lib/relaton_nist/hit_collection.rb +2 -2
- data/lib/relaton_nist/nist_bibliographic_item.rb +13 -13
- data/lib/relaton_nist/nist_bibliography.rb +6 -6
- data/lib/relaton_nist/tech_pubs_parser.rb +13 -7
- data/lib/relaton_nist/util.rb +1 -4
- data/lib/relaton_nist/version.rb +1 -1
- data/lib/relaton_nist.rb +0 -1
- data/relaton_nist.gemspec +2 -1
- metadata +19 -6
- data/lib/relaton_nist/config.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd31209270fb62d1b7dabbddf7f379eb7b33a21832f3e290dd9ed49c94d715c4
|
4
|
+
data.tar.gz: 8f15ad43f7d1edfd0a9135a6b750bf1414c3fd24216fd30c730586b9cd342f5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea6daf8959d56b98ab2e02e63315c2ecf7bd483824ec2ad0832fc9239e32d57e556942d86edbaa4c88655904d2e04e9a05c50cb4bbf38486773ab3cb0986c851
|
7
|
+
data.tar.gz: 2ca580e13556eb72455cc61f9a783d30894675d3f98630dd2de589a3a2a894380bc96a26453eb345e727eec37a7ecb8535b35aa011b34cab9580b858fc0e70ae
|
data/README.adoc
CHANGED
@@ -71,24 +71,13 @@ Or install it yourself as:
|
|
71
71
|
|
72
72
|
== Usage
|
73
73
|
|
74
|
-
===
|
75
|
-
|
76
|
-
Configuration is optional. The available option is `logger` which is a `Logger` instance. By default, the logger is `Logger.new($stderr)` with `Logger::WARN` level. To change the logger level, use `RelatonNist.configure` block.
|
74
|
+
=== Search for a standard using keywords
|
77
75
|
|
78
76
|
[source,ruby]
|
79
77
|
----
|
80
78
|
require 'relaton_nist'
|
81
79
|
=> true
|
82
80
|
|
83
|
-
RelatonNist.configure do |config|
|
84
|
-
config.logger.level = Logger::DEBUG
|
85
|
-
end
|
86
|
-
----
|
87
|
-
|
88
|
-
=== Search for a standard using keywords
|
89
|
-
|
90
|
-
[source,ruby]
|
91
|
-
----
|
92
81
|
hit_collection = RelatonNist::NistBibliography.search("NISTIR 8200")
|
93
82
|
[relaton-nist] (NIST IR 8200) Fetching from csrc.nist.gov ...
|
94
83
|
[relaton-nist] (NIST IR 8200) Fetching from Relaton repository ...
|
@@ -103,7 +92,7 @@ item = hit_collection[0].fetch
|
|
103
92
|
[source,ruby]
|
104
93
|
----
|
105
94
|
item.to_xml
|
106
|
-
=> "<bibitem id="NISTIR8200" type="standard" schema-version="v1.2.
|
95
|
+
=> "<bibitem id="NISTIR8200" type="standard" schema-version="v1.2.9">
|
107
96
|
<fetched>2023-10-16</fetched>
|
108
97
|
<title format="text/plain" language="en" script="Latn">Interagency report on the status of international cybersecurity standardization for the internet of things (IoT)</title>
|
109
98
|
...
|
@@ -113,7 +102,7 @@ With argument `bibdata: true` it outputs XML wrapped by `bibdata` element and ad
|
|
113
102
|
[source,ruby]
|
114
103
|
----
|
115
104
|
item.to_xml bibdata: true
|
116
|
-
=> "<bibdata type="standard" schema-version="v1.2.
|
105
|
+
=> "<bibdata type="standard" schema-version="v1.2.9">
|
117
106
|
<fetched>2023-10-16</fetched>
|
118
107
|
<title format="text/plain" language="en" script="Latn">Interagency report on the status of international cybersecurity standardization for the internet of things (IoT)</title>
|
119
108
|
...
|
@@ -239,6 +228,10 @@ Done in: 42 sec.
|
|
239
228
|
=> nil
|
240
229
|
----
|
241
230
|
|
231
|
+
=== Logging
|
232
|
+
|
233
|
+
RelatonNist uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the https://github.com/relaton/relaton-logger#usage[relaton-logger] documentation.
|
234
|
+
|
242
235
|
== Development
|
243
236
|
|
244
237
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/grammars/basicdoc.rng
CHANGED
@@ -30,7 +30,7 @@ module RelatonNist
|
|
30
30
|
id = bib.docidentifier[0].id.gsub(%r{[/\s:.]}, "_").upcase.sub(/^NIST_IR/, "NISTIR")
|
31
31
|
file = File.join(@output, "#{id}.#{@ext}")
|
32
32
|
if @files.include? file
|
33
|
-
warn "File #{file} exists. Docid: #{bib.docidentifier[0].id}"
|
33
|
+
Util.warn "File #{file} exists. Docid: #{bib.docidentifier[0].id}"
|
34
34
|
# warn "Link: #{bib.link.detect { |l| l.type == 'src' }.content}"
|
35
35
|
else @files << file
|
36
36
|
end
|
@@ -64,8 +64,7 @@ module RelatonNist
|
|
64
64
|
puts "Stopped at: #{t2}"
|
65
65
|
puts "Done in: #{(t2 - t1).round} sec."
|
66
66
|
rescue StandardError => e
|
67
|
-
|
68
|
-
warn e.backtrace[0..5].join("\n")
|
67
|
+
Util.error "#{e.message}\n#{e.backtrace[0..5].join("\n")}"
|
69
68
|
end
|
70
69
|
|
71
70
|
def fetch_tech_pubs
|
@@ -190,7 +190,7 @@ module RelatonNist
|
|
190
190
|
# @raise [OpenURI::HTTPError] if GitHub repo is not available
|
191
191
|
#
|
192
192
|
def from_ga # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
193
|
-
Util.
|
193
|
+
Util.info "Fetching from Relaton repository ...", key: @reference
|
194
194
|
ref = full_ref
|
195
195
|
return [] if ref.empty?
|
196
196
|
|
@@ -222,7 +222,7 @@ module RelatonNist
|
|
222
222
|
# @return [Array<RelatonNist::Hit>] hits
|
223
223
|
#
|
224
224
|
def from_json # rubocop:disable Metrics/AbcSize
|
225
|
-
Util.
|
225
|
+
Util.info "Fetching from csrc.nist.gov ...", key: @reference
|
226
226
|
select_data.map do |h|
|
227
227
|
/(?<series>(?<=-)\w+$)/ =~ h["series"]
|
228
228
|
title = [h["title-main"], h["title-sub"]].compact.join " - "
|
@@ -3,32 +3,32 @@ module RelatonNist
|
|
3
3
|
# @return [Array<RelatonNist::Keyword>]
|
4
4
|
# attr_reader :keyword
|
5
5
|
|
6
|
-
# @return [RelatonNist::CommentPeriod,
|
6
|
+
# @return [RelatonNist::CommentPeriod, nil]
|
7
7
|
attr_reader :commentperiod
|
8
8
|
|
9
|
-
# @param id [String,
|
9
|
+
# @param id [String, nil]
|
10
10
|
# @param title [Array<RelatonBib::TypedTitleString>]
|
11
|
-
# @param formattedref [RelatonBib::FormattedRef,
|
12
|
-
# @param type [String,
|
11
|
+
# @param formattedref [RelatonBib::FormattedRef, nil]
|
12
|
+
# @param type [String, nil]
|
13
13
|
# @param docid [Array<RelatonBib::DocumentIdentifier>]
|
14
|
-
# @param docnumber [String,
|
14
|
+
# @param docnumber [String, nil]
|
15
15
|
# @param language [Arra<String>]
|
16
16
|
# @param script [Array<String>]
|
17
|
-
# @param docstatus [RelatonNist::DocumentStatus,
|
18
|
-
# @param edition [String,
|
19
|
-
# @param version [RelatonBib::BibliographicItem::Version,
|
17
|
+
# @param docstatus [RelatonNist::DocumentStatus, nil]
|
18
|
+
# @param edition [String, nil]
|
19
|
+
# @param version [RelatonBib::BibliographicItem::Version, nil]
|
20
20
|
# @param biblionote [Array<RelatonBib::FormattedStrong>]
|
21
21
|
# @param series [Array<RelatonBib::Series>]
|
22
22
|
# @param medium [RelatonBib::Medium, NilClas]
|
23
23
|
# @param place [Array<String>]
|
24
24
|
# @param extent [Array<Relaton::BibItemLocality>]
|
25
25
|
# @param accesslocation [Array<String>]
|
26
|
-
# @param classification [RelatonBib::Classification,
|
27
|
-
# @param validity [RelatonBib:Validity,
|
28
|
-
# @param fetched [Date,
|
29
|
-
# @param doctype [
|
26
|
+
# @param classification [RelatonBib::Classification, nil]
|
27
|
+
# @param validity [RelatonBib:Validity, nil]
|
28
|
+
# @param fetched [Date, nil] default nil
|
29
|
+
# @param doctype [RelatonBib::DocumentType, nil]
|
30
30
|
# @param keyword [Array<RelatonBib::Keyword>]
|
31
|
-
# @param commentperiod [RelatonNist::CommentPeriod,
|
31
|
+
# @param commentperiod [RelatonNist::CommentPeriod, nil]
|
32
32
|
#
|
33
33
|
# @param date [Array<Hash>]
|
34
34
|
# @option date [String] :type
|
@@ -84,7 +84,7 @@ 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.
|
87
|
+
Util.info "Found: `#{ret[:ret].docidentifier.first.id}`", key: result.reference
|
88
88
|
ret[:ret]
|
89
89
|
else
|
90
90
|
fetch_ref_err(result.reference, year, ret[:years])
|
@@ -173,14 +173,14 @@ module RelatonNist
|
|
173
173
|
# @return [nil] nil
|
174
174
|
#
|
175
175
|
def fetch_ref_err(ref, year, missed_years)
|
176
|
-
Util.
|
176
|
+
Util.info "No found.", key: ref
|
177
177
|
unless missed_years.empty?
|
178
|
-
Util.
|
179
|
-
"were matches found for `#{missed_years.join('`, `')}`.)"
|
178
|
+
Util.info "(There was no match for #{year}, though there " \
|
179
|
+
"were matches found for `#{missed_years.join('`, `')}`.)", key: ref
|
180
180
|
end
|
181
181
|
if /\d-\d/.match? ref
|
182
|
-
Util.
|
183
|
-
"or the document may no longer be published in parts."
|
182
|
+
Util.info "The provided document part may not exist, " \
|
183
|
+
"or the document may no longer be published in parts.", key: ref
|
184
184
|
end
|
185
185
|
nil
|
186
186
|
end
|
@@ -152,7 +152,7 @@ module RelatonNist
|
|
152
152
|
# @return [Array<Hash>]
|
153
153
|
def parse_contributor
|
154
154
|
contribs = @doc.xpath("contributors/person_name").map do |p|
|
155
|
-
person = RelatonBib::Person.new(name: fullname(p), affiliation: affiliation)
|
155
|
+
person = RelatonBib::Person.new(name: fullname(p), affiliation: affiliation, identifier: identifier(p))
|
156
156
|
{ entity: person, role: [{ type: p["contributor_role"] }] }
|
157
157
|
end
|
158
158
|
contribs + @doc.xpath("publisher").map do |p|
|
@@ -160,6 +160,12 @@ module RelatonNist
|
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
163
|
+
def identifier(person)
|
164
|
+
person.xpath("ORCID").map do |id|
|
165
|
+
RelatonBib::PersonIdentifier.new "orcid", id.text
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
163
169
|
#
|
164
170
|
# Create full name object from person name element.
|
165
171
|
#
|
@@ -169,12 +175,11 @@ module RelatonNist
|
|
169
175
|
#
|
170
176
|
def fullname(person)
|
171
177
|
fname, initials = forename_initial person
|
172
|
-
surname = localized_string person.at("surname")
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
initials: initials, identifier: ident)
|
178
|
+
surname = localized_string person.at("surname")&.text
|
179
|
+
completename = localized_string person.text unless surname
|
180
|
+
RelatonBib::FullName.new(
|
181
|
+
surname: surname, forename: fname, initials: initials, completename: completename,
|
182
|
+
)
|
178
183
|
end
|
179
184
|
|
180
185
|
#
|
@@ -296,6 +301,7 @@ module RelatonNist
|
|
296
301
|
# @return [RelatonBib::LocalizedString] localized string
|
297
302
|
#
|
298
303
|
def localized_string(content)
|
304
|
+
return unless content
|
299
305
|
RelatonBib::LocalizedString.new content, @doc["language"], "Latn"
|
300
306
|
end
|
301
307
|
end
|
data/lib/relaton_nist/util.rb
CHANGED
data/lib/relaton_nist/version.rb
CHANGED
data/lib/relaton_nist.rb
CHANGED
data/relaton_nist.gemspec
CHANGED
@@ -23,7 +23,8 @@ 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 "
|
26
|
+
spec.add_dependency "base64"
|
27
|
+
spec.add_dependency "relaton-bib", "~> 1.19.0"
|
27
28
|
spec.add_dependency "relaton-index", "~> 0.2.0"
|
28
29
|
spec.add_dependency "rubyzip"
|
29
30
|
end
|
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-nist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.19.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: 2024-
|
11
|
+
date: 2024-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: base64
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: relaton-bib
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
33
|
+
version: 1.19.0
|
20
34
|
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
40
|
+
version: 1.19.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: relaton-index
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,7 +92,6 @@ files:
|
|
78
92
|
- grammars/relaton-nist.rng
|
79
93
|
- lib/relaton_nist.rb
|
80
94
|
- lib/relaton_nist/comment_period.rb
|
81
|
-
- lib/relaton_nist/config.rb
|
82
95
|
- lib/relaton_nist/data_fetcher.rb
|
83
96
|
- lib/relaton_nist/document_relation.rb
|
84
97
|
- lib/relaton_nist/document_status.rb
|
@@ -115,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
128
|
- !ruby/object:Gem::Version
|
116
129
|
version: '0'
|
117
130
|
requirements: []
|
118
|
-
rubygems_version: 3.3.
|
131
|
+
rubygems_version: 3.3.27
|
119
132
|
signing_key:
|
120
133
|
specification_version: 4
|
121
134
|
summary: 'RelatonNist: retrive NIST standards.'
|