relaton-nist 1.18.0 → 1.19.1
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 +12 -9
- data/lib/relaton_nist/hit_collection.rb +2 -2
- data/lib/relaton_nist/mods_parser.rb +209 -0
- data/lib/relaton_nist/nist_bibliographic_item.rb +13 -13
- data/lib/relaton_nist/nist_bibliography.rb +7 -7
- 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 +3 -1
- metadata +34 -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: 84f25c99f7dfa62a09294c042a3774332fdb018841028aa7ef0dde5b07c9788c
|
4
|
+
data.tar.gz: 618fca8f81fe125d4c265c02d1cf4a65c8188b960f7dd91332e91b4ec22bb05d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e4c3cfdec6fbe121b8b669e7beca74df804bbda725c358fc0be0bccc8853d12644f79937edf9eebd06fb06a0a91b92b37d61ad9267784ed6a3f476d2f3ea8ac
|
7
|
+
data.tar.gz: 517f957beaf97d42b0cf0d8fc9749ef9af2f99f2db0510a994be4e4ac56003f2d6c5ad2fa46d6f574b0868c520e79797911dbbe5d6a1516382f6625f486b6e17
|
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
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "yaml"
|
4
|
+
require "loc_mods"
|
5
|
+
require_relative "mods_parser"
|
4
6
|
|
5
7
|
module RelatonNist
|
6
8
|
class DataFetcher
|
7
|
-
URL = "https://
|
9
|
+
URL = "https://github.com/usnistgov/NIST-Tech-Pubs/releases/download/May2024/allrecords-MODS.xml"
|
8
10
|
|
9
11
|
def initialize(output, format)
|
10
12
|
@output = output
|
@@ -30,7 +32,7 @@ module RelatonNist
|
|
30
32
|
id = bib.docidentifier[0].id.gsub(%r{[/\s:.]}, "_").upcase.sub(/^NIST_IR/, "NISTIR")
|
31
33
|
file = File.join(@output, "#{id}.#{@ext}")
|
32
34
|
if @files.include? file
|
33
|
-
warn "File #{file} exists. Docid: #{bib.docidentifier[0].id}"
|
35
|
+
Util.warn "File #{file} exists. Docid: #{bib.docidentifier[0].id}"
|
34
36
|
# warn "Link: #{bib.link.detect { |l| l.type == 'src' }.content}"
|
35
37
|
else @files << file
|
36
38
|
end
|
@@ -64,21 +66,22 @@ module RelatonNist
|
|
64
66
|
puts "Stopped at: #{t2}"
|
65
67
|
puts "Done in: #{(t2 - t1).round} sec."
|
66
68
|
rescue StandardError => e
|
67
|
-
|
68
|
-
warn e.backtrace[0..5].join("\n")
|
69
|
+
Util.error "#{e.message}\n#{e.backtrace[0..5].join("\n")}"
|
69
70
|
end
|
70
71
|
|
71
72
|
def fetch_tech_pubs
|
72
|
-
docs =
|
73
|
-
docs.xpath(
|
74
|
-
|
75
|
-
|
73
|
+
docs = LocMods::Collection.from_xml OpenURI.open_uri(URL)
|
74
|
+
# docs.xpath(
|
75
|
+
# "/body/query/doi_record/report-paper/report-paper_metadata",
|
76
|
+
# )
|
77
|
+
docs.mods.each { |doc| write_file ModsParser.new(doc, series).parse }
|
76
78
|
end
|
77
79
|
|
78
80
|
def add_static_files
|
79
81
|
Dir["./static/*.yaml"].each do |file|
|
80
82
|
hash = YAML.load_file file
|
81
|
-
|
83
|
+
bib = RelatonNist::NistBibliographicItem.from_hash(hash)
|
84
|
+
index.add_or_update bib.docidentifier[0].id, file
|
82
85
|
end
|
83
86
|
end
|
84
87
|
|
@@ -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 " - "
|
@@ -0,0 +1,209 @@
|
|
1
|
+
module RelatonNist
|
2
|
+
class ModsParser
|
3
|
+
RELATION_TYPES = {
|
4
|
+
"otherVersion" => "editionOf",
|
5
|
+
"preceding" => "updates",
|
6
|
+
"succeeding" => "updatedBy",
|
7
|
+
}.freeze
|
8
|
+
|
9
|
+
ATTRS = %i[type docid title link abstract date doctype contributor relation place series].freeze
|
10
|
+
|
11
|
+
def initialize(doc, series)
|
12
|
+
@doc = doc
|
13
|
+
@series = series
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [RelatonNist::NistBibliographicItem]
|
17
|
+
def parse
|
18
|
+
args = ATTRS.each_with_object({}) do |attr, hash|
|
19
|
+
hash[attr] = send("parse_#{attr}")
|
20
|
+
end
|
21
|
+
NistBibliographicItem.new(**args)
|
22
|
+
end
|
23
|
+
|
24
|
+
def parse_type
|
25
|
+
"standard"
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [Array<RelatonBib::DocumentIdentifier>]
|
29
|
+
def parse_docid
|
30
|
+
[
|
31
|
+
{ type: "NIST", id: pub_id, primary: true },
|
32
|
+
{ type: "DOI", id: doi },
|
33
|
+
].map { |id| RelatonBib::DocumentIdentifier.new(**id) }
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [String]
|
37
|
+
def pub_id
|
38
|
+
get_id_from_str doi
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_id_from_str(str)
|
42
|
+
str.match(/\/((?:NBS|NIST).+)/)[1].gsub(".", " ")
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [String]
|
46
|
+
def doi
|
47
|
+
url = @doc.location.reduce(nil) { |m, l| m || l.url.detect { |u| u.usage == "primary display" } }
|
48
|
+
id = url.content.match(/10\.6028\/.+/)[0]
|
49
|
+
case id
|
50
|
+
when "10.6028/NBS.CIRC.sup" then "10.6028/NBS.CIRC.24e7sup"
|
51
|
+
when "10.6028/NBS.CIRC.supJun1925-Jun1926" then "10.6028/NBS.CIRC.24e7sup2"
|
52
|
+
when "10.6028/NBS.CIRC.supJun1925-Jun1927" then "10.6028/NBS.CIRC.24e7sup3"
|
53
|
+
when "10.6028/NBS.CIRC.24supJuly1922" then "10.6028/NBS.CIRC.24e6sup"
|
54
|
+
when "10.6028/NBS.CIRC.24supJan1924" then "10.6028/NBS.CIRC.24e6sup2"
|
55
|
+
else id
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# @return [Array<RelatonBib::TypedTitleString>]
|
60
|
+
def parse_title
|
61
|
+
title = @doc.title_info.reduce([]) do |a, ti|
|
62
|
+
next a if ti.type == "alternative"
|
63
|
+
|
64
|
+
a += ti.title.map { |t| create_title(t, "title-main", ti.non_sort[0]) }
|
65
|
+
a + ti.sub_title.map { |t| create_title(t, "title-part") }
|
66
|
+
end
|
67
|
+
if title.size > 1
|
68
|
+
content = title.map { |t| t.title.content }.join(" - ")
|
69
|
+
title << create_title(content, "main")
|
70
|
+
elsif title.size == 1
|
71
|
+
title[0].instance_variable_set :@type, "main"
|
72
|
+
end
|
73
|
+
title
|
74
|
+
end
|
75
|
+
|
76
|
+
def create_title(title, type, non_sort = nil)
|
77
|
+
content = title.gsub("\n", " ").squeeze(" ").strip
|
78
|
+
content = "#{non_sort.content}#{content}".squeeze(" ") if non_sort
|
79
|
+
RelatonBib::TypedTitleString.new content: content, type: type, language: "en", script: "Latn"
|
80
|
+
end
|
81
|
+
|
82
|
+
def parse_link
|
83
|
+
@doc.location.map do |location|
|
84
|
+
url = location.url.first
|
85
|
+
type = url.usage == "primary display" ? "doi" : "src"
|
86
|
+
RelatonBib::TypedUri.new content: url.content, type: type
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def parse_abstract
|
91
|
+
@doc.abstract.map do |a|
|
92
|
+
content = a.content.gsub("\n", " ").squeeze(" ").strip
|
93
|
+
RelatonBib::FormattedString.new content: content, language: "en", script: "Latn"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def parse_date
|
98
|
+
date = @doc.origin_info[0].date_issued.map do |di|
|
99
|
+
create_date(di, "issued")
|
100
|
+
# end + @doc.record_info[0].record_creation_date.map do |rcd|
|
101
|
+
# create_date(rcd, "created")
|
102
|
+
# end + @doc.record_info[0].record_change_date.map do |rcd|
|
103
|
+
# create_date(rcd, "updated")
|
104
|
+
end
|
105
|
+
date.compact
|
106
|
+
end
|
107
|
+
|
108
|
+
def create_date(date, type)
|
109
|
+
RelatonBib::BibliographicDate.new type: type, on: decode_date(date)
|
110
|
+
rescue Date::Error
|
111
|
+
end
|
112
|
+
|
113
|
+
def decode_date(date)
|
114
|
+
if date.encoding == "marc" && date.content.size == 6
|
115
|
+
Date.strptime(date.content, "%y%m%d").to_s
|
116
|
+
elsif date.encoding == "iso8601"
|
117
|
+
Date.strptime(date.content, "%Y%m%d").to_s
|
118
|
+
else date.content
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def parse_doctype
|
123
|
+
RelatonBib::DocumentType.new(type: "standard")
|
124
|
+
end
|
125
|
+
|
126
|
+
def parse_contributor
|
127
|
+
# eaxclude primary contributors to avoid duplication
|
128
|
+
@doc.name.reject { |n| n.usage == "primary" }.map do |name|
|
129
|
+
entity, default_role = create_entity(name)
|
130
|
+
next unless entity
|
131
|
+
|
132
|
+
role = name.role.reduce([]) do |a, r|
|
133
|
+
a + r.role_term.map { |rt| { type: rt.content } }
|
134
|
+
end
|
135
|
+
role << { type: default_role } if role.empty?
|
136
|
+
RelatonBib::ContributionInfo.new entity: entity, role: role
|
137
|
+
end.compact
|
138
|
+
end
|
139
|
+
|
140
|
+
def create_entity(name)
|
141
|
+
case name.type
|
142
|
+
when "personal" then [create_person(name), "author"]
|
143
|
+
when "corporate" then [create_org(name), "publisher"]
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def create_person(name)
|
148
|
+
# exclude typed name parts because they are not actual name parts
|
149
|
+
cname = name.name_part.reject(&:type).map(&:content).join(" ")
|
150
|
+
complatename = RelatonBib::LocalizedString.new cname, "en"
|
151
|
+
fname = RelatonBib::FullName.new completename: complatename
|
152
|
+
name_id = name.name_identifier[0]
|
153
|
+
identifier = RelatonBib::PersonIdentifier.new "uri", name_id.content if name_id
|
154
|
+
RelatonBib::Person.new name: fname, identifier: [identifier]
|
155
|
+
end
|
156
|
+
|
157
|
+
def create_org(name)
|
158
|
+
names = name.name_part.reject(&:type).map { |n| n.content.gsub("\n", " ").squeeze(" ").strip }
|
159
|
+
url = name.name_identifier[0]&.content
|
160
|
+
id = RelatonBib::OrgIdentifier.new "uri", url if url
|
161
|
+
RelatonBib::Organization.new name: names, identifier: [id]
|
162
|
+
end
|
163
|
+
|
164
|
+
def parse_relation
|
165
|
+
@doc.related_item.reject { |ri| ri.type == "series" }.map do |ri|
|
166
|
+
type = RELATION_TYPES[ri.type]
|
167
|
+
RelatonBib::DocumentRelation.new(type: type, bibitem: create_related_item(ri))
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def create_related_item(item)
|
172
|
+
item_id = get_id_from_str related_item_id(item)
|
173
|
+
docid = RelatonBib::DocumentIdentifier.new type: "NIST", id: item_id
|
174
|
+
fref = RelatonBib::FormattedRef.new content: item_id
|
175
|
+
NistBibliographicItem.new(docid: [docid], formattedref: fref)
|
176
|
+
end
|
177
|
+
|
178
|
+
def related_item_id(item)
|
179
|
+
if item.other_type && item.other_type[0..6] == "10.6028"
|
180
|
+
item.other_type
|
181
|
+
else
|
182
|
+
item.name[0].name_part[0].content
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def parse_place
|
187
|
+
@doc.origin_info.select { |p| p.event_type == "publisher"}.map do |p|
|
188
|
+
place = p.place[0].place_term[0].content
|
189
|
+
/(?<city>\w+), (?<state>\w+)/ =~ place
|
190
|
+
RelatonBib::Place.new city: city, region: create_region(state)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def create_region(state)
|
195
|
+
[RelatonBib::Place::RegionType.new(iso: state)]
|
196
|
+
rescue ArgumentError
|
197
|
+
[]
|
198
|
+
end
|
199
|
+
|
200
|
+
def parse_series
|
201
|
+
@doc.related_item.select { |ri| ri.type == "series" }.map do |ri|
|
202
|
+
tinfo = ri.title_info[0]
|
203
|
+
tcontent = tinfo.title[0].strip
|
204
|
+
title = RelatonBib::TypedTitleString.new content: tcontent
|
205
|
+
RelatonBib::Series.new title: title, number: tinfo.part_number[0]
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
@@ -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])
|
@@ -123,7 +123,7 @@ module RelatonNist
|
|
123
123
|
next if iter && r.status.iteration != iteration
|
124
124
|
return { ret: r } if !year
|
125
125
|
|
126
|
-
r.date.select { |d| d.type == "published" }.each do |d|
|
126
|
+
r.date.select { |d| d.type == "published" || d.type == "issued" }.each do |d|
|
127
127
|
return { ret: r } if year.to_i == d.on(:year)
|
128
128
|
|
129
129
|
missed_years << d.on(:year)
|
@@ -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,9 @@ 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 "loc_mods", "~> 0.2.0"
|
28
|
+
spec.add_dependency "relaton-bib", "~> 1.19.2"
|
27
29
|
spec.add_dependency "relaton-index", "~> 0.2.0"
|
28
30
|
spec.add_dependency "rubyzip"
|
29
31
|
end
|
metadata
CHANGED
@@ -1,29 +1,57 @@
|
|
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.1
|
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-12 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'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: loc_mods
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.2.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.2.0
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: relaton-bib
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
16
44
|
requirements:
|
17
45
|
- - "~>"
|
18
46
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
47
|
+
version: 1.19.2
|
20
48
|
type: :runtime
|
21
49
|
prerelease: false
|
22
50
|
version_requirements: !ruby/object:Gem::Requirement
|
23
51
|
requirements:
|
24
52
|
- - "~>"
|
25
53
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
54
|
+
version: 1.19.2
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: relaton-index
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,13 +106,13 @@ files:
|
|
78
106
|
- grammars/relaton-nist.rng
|
79
107
|
- lib/relaton_nist.rb
|
80
108
|
- lib/relaton_nist/comment_period.rb
|
81
|
-
- lib/relaton_nist/config.rb
|
82
109
|
- lib/relaton_nist/data_fetcher.rb
|
83
110
|
- lib/relaton_nist/document_relation.rb
|
84
111
|
- lib/relaton_nist/document_status.rb
|
85
112
|
- lib/relaton_nist/hash_converter.rb
|
86
113
|
- lib/relaton_nist/hit.rb
|
87
114
|
- lib/relaton_nist/hit_collection.rb
|
115
|
+
- lib/relaton_nist/mods_parser.rb
|
88
116
|
- lib/relaton_nist/nist_bibliographic_item.rb
|
89
117
|
- lib/relaton_nist/nist_bibliography.rb
|
90
118
|
- lib/relaton_nist/processor.rb
|
@@ -115,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
143
|
- !ruby/object:Gem::Version
|
116
144
|
version: '0'
|
117
145
|
requirements: []
|
118
|
-
rubygems_version: 3.3.
|
146
|
+
rubygems_version: 3.3.27
|
119
147
|
signing_key:
|
120
148
|
specification_version: 4
|
121
149
|
summary: 'RelatonNist: retrive NIST standards.'
|