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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96861330895fb2cca8e2d6ab7320bd4daa8ef8e2873231399761604eed233be1
4
- data.tar.gz: 524bb34cd6285c212067c3ac791f916ecd72296a523627f82b7cf364de917dd3
3
+ metadata.gz: cd31209270fb62d1b7dabbddf7f379eb7b33a21832f3e290dd9ed49c94d715c4
4
+ data.tar.gz: 8f15ad43f7d1edfd0a9135a6b750bf1414c3fd24216fd30c730586b9cd342f5c
5
5
  SHA512:
6
- metadata.gz: 2afde329d073bb4dc564005568eb06fdb52e1cc1911c74d6ad4656ab0e492d01108a2c3ba31fe2b29bdb84bab5640f7f199afdd021dcadd5b6c1aaab5b9269f8
7
- data.tar.gz: 230883c366766fd4dc7b23a3acd0edee052709391e7c3cdd4e97f28a7f864666859a95fcf4d401b5247d6b81b80543bb2cb6a9ac2e575b6e96b0fc647f0130be
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
- === Configuration
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.8">
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.8">
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.
@@ -244,6 +244,9 @@
244
244
  <data type="ID"/>
245
245
  </attribute>
246
246
  <attribute name="reviewer"/>
247
+ <optional>
248
+ <attribute name="type"/>
249
+ </optional>
247
250
  <optional>
248
251
  <attribute name="date">
249
252
  <data type="dateTime"/>
@@ -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
- warn e.message
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.warn "(#{@reference}) Fetching from Relaton repository ..."
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.warn "(#{@reference}) Fetching from csrc.nist.gov ..."
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, NilClass]
6
+ # @return [RelatonNist::CommentPeriod, nil]
7
7
  attr_reader :commentperiod
8
8
 
9
- # @param id [String, NilClass]
9
+ # @param id [String, nil]
10
10
  # @param title [Array<RelatonBib::TypedTitleString>]
11
- # @param formattedref [RelatonBib::FormattedRef, NilClass]
12
- # @param type [String, NilClass]
11
+ # @param formattedref [RelatonBib::FormattedRef, nil]
12
+ # @param type [String, nil]
13
13
  # @param docid [Array<RelatonBib::DocumentIdentifier>]
14
- # @param docnumber [String, NilClass]
14
+ # @param docnumber [String, nil]
15
15
  # @param language [Arra<String>]
16
16
  # @param script [Array<String>]
17
- # @param docstatus [RelatonNist::DocumentStatus, NilClass]
18
- # @param edition [String, NilClass]
19
- # @param version [RelatonBib::BibliographicItem::Version, NilClass]
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, NilClass]
27
- # @param validity [RelatonBib:Validity, NilClass]
28
- # @param fetched [Date, NilClass] default nil
29
- # @param doctype [String]
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, NilClass]
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.warn "(#{result.reference}) Found: `#{ret[:ret].docidentifier.first.id}`"
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.warn "(#{ref}) No found."
176
+ Util.info "No found.", key: ref
177
177
  unless missed_years.empty?
178
- Util.warn "(There was no match for #{year}, though there " \
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.warn "The provided document part may not exist, " \
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").text
173
- ident = person.xpath("ORCID").map do |id|
174
- RelatonBib::PersonIdentifier.new "orcid", id.text
175
- end
176
- RelatonBib::FullName.new(surname: surname, forename: fname,
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
@@ -1,9 +1,6 @@
1
1
  module RelatonNist
2
2
  module Util
3
3
  extend RelatonBib::Util
4
-
5
- def self.logger
6
- RelatonNist.configuration.logger
7
- end
4
+ PROGNAME = "relaton-nist".freeze
8
5
  end
9
6
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonNist
2
- VERSION = "1.18.0".freeze
2
+ VERSION = "1.19.0".freeze
3
3
  end
data/lib/relaton_nist.rb CHANGED
@@ -2,7 +2,6 @@ require "singleton"
2
2
  require "relaton/index"
3
3
  require "relaton_bib"
4
4
  require "relaton_nist/version"
5
- require "relaton_nist/config"
6
5
  require "relaton_nist/util"
7
6
  require "relaton_nist/nist_bibliography"
8
7
  require "relaton_nist/data_fetcher"
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 "relaton-bib", "~> 1.18.0"
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.18.0
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-01-08 00:00:00.000000000 Z
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.18.0
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.18.0
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.26
131
+ rubygems_version: 3.3.27
119
132
  signing_key:
120
133
  specification_version: 4
121
134
  summary: 'RelatonNist: retrive NIST standards.'
@@ -1,10 +0,0 @@
1
- module RelatonNist
2
- module Config
3
- include RelatonBib::Config
4
- end
5
- extend Config
6
-
7
- class Configuration < RelatonBib::Configuration
8
- PROGNAME = "relaton-nist".freeze
9
- end
10
- end