relaton-nist 1.17.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/.github/workflows/rake.yml +1 -1
- data/.github/workflows/release.yml +1 -1
- data/README.adoc +7 -14
- data/grammars/basicdoc.rng +150 -52
- data/grammars/biblio-standoc.rng +44 -1
- data/grammars/biblio.rng +32 -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 +26 -14
- 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/.github/workflows/rake.yml
CHANGED
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
@@ -95,8 +95,89 @@
|
|
95
95
|
<ref name="pagebreak"/>
|
96
96
|
<ref name="hr"/>
|
97
97
|
<ref name="bookmark"/>
|
98
|
+
<ref name="amend"/>
|
98
99
|
</choice>
|
99
100
|
</define>
|
101
|
+
<define name="amend">
|
102
|
+
<element name="amend">
|
103
|
+
<ref name="AmendType"/>
|
104
|
+
</element>
|
105
|
+
</define>
|
106
|
+
<define name="AmendType">
|
107
|
+
<optional>
|
108
|
+
<attribute name="id">
|
109
|
+
<data type="ID"/>
|
110
|
+
</attribute>
|
111
|
+
</optional>
|
112
|
+
<attribute name="change">
|
113
|
+
<choice>
|
114
|
+
<value>add</value>
|
115
|
+
<value>modify</value>
|
116
|
+
<value>delete</value>
|
117
|
+
<value>replace</value>
|
118
|
+
</choice>
|
119
|
+
</attribute>
|
120
|
+
<optional>
|
121
|
+
<attribute name="path"/>
|
122
|
+
</optional>
|
123
|
+
<optional>
|
124
|
+
<attribute name="path_end"/>
|
125
|
+
</optional>
|
126
|
+
<optional>
|
127
|
+
<attribute name="title"/>
|
128
|
+
</optional>
|
129
|
+
<optional>
|
130
|
+
<element name="location">
|
131
|
+
<zeroOrMore>
|
132
|
+
<choice>
|
133
|
+
<ref name="locality"/>
|
134
|
+
<ref name="localityStack"/>
|
135
|
+
</choice>
|
136
|
+
</zeroOrMore>
|
137
|
+
</element>
|
138
|
+
</optional>
|
139
|
+
<optional>
|
140
|
+
<element name="description">
|
141
|
+
<zeroOrMore>
|
142
|
+
<ref name="BasicBlock"/>
|
143
|
+
</zeroOrMore>
|
144
|
+
</element>
|
145
|
+
</optional>
|
146
|
+
<optional>
|
147
|
+
<element name="newcontent">
|
148
|
+
<optional>
|
149
|
+
<attribute name="id">
|
150
|
+
<data type="ID"/>
|
151
|
+
</attribute>
|
152
|
+
</optional>
|
153
|
+
<zeroOrMore>
|
154
|
+
<ref name="BasicBlock"/>
|
155
|
+
</zeroOrMore>
|
156
|
+
</element>
|
157
|
+
</optional>
|
158
|
+
<zeroOrMore>
|
159
|
+
<ref name="classification"/>
|
160
|
+
</zeroOrMore>
|
161
|
+
<zeroOrMore>
|
162
|
+
<ref name="contributor"/>
|
163
|
+
</zeroOrMore>
|
164
|
+
</define>
|
165
|
+
<define name="classification">
|
166
|
+
<element name="classification">
|
167
|
+
<ref name="classification_tag"/>
|
168
|
+
<ref name="classification_value"/>
|
169
|
+
</element>
|
170
|
+
</define>
|
171
|
+
<define name="classification_tag">
|
172
|
+
<element name="tag">
|
173
|
+
<text/>
|
174
|
+
</element>
|
175
|
+
</define>
|
176
|
+
<define name="classification_value">
|
177
|
+
<element name="value">
|
178
|
+
<text/>
|
179
|
+
</element>
|
180
|
+
</define>
|
100
181
|
<define name="paragraph">
|
101
182
|
<element name="p">
|
102
183
|
<ref name="ParagraphType"/>
|
@@ -163,6 +244,9 @@
|
|
163
244
|
<data type="ID"/>
|
164
245
|
</attribute>
|
165
246
|
<attribute name="reviewer"/>
|
247
|
+
<optional>
|
248
|
+
<attribute name="type"/>
|
249
|
+
</optional>
|
166
250
|
<optional>
|
167
251
|
<attribute name="date">
|
168
252
|
<data type="dateTime"/>
|
@@ -715,27 +799,36 @@
|
|
715
799
|
</define>
|
716
800
|
<define name="ruby">
|
717
801
|
<element name="ruby">
|
718
|
-
<
|
719
|
-
<
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
802
|
+
<choice>
|
803
|
+
<ref name="ruby_pronunciation"/>
|
804
|
+
<ref name="ruby_annotation"/>
|
805
|
+
</choice>
|
806
|
+
<choice>
|
807
|
+
<text/>
|
808
|
+
<ref name="ruby"/>
|
809
|
+
</choice>
|
725
810
|
</element>
|
726
811
|
</define>
|
727
|
-
<define name="
|
728
|
-
<element name="
|
729
|
-
<
|
730
|
-
|
731
|
-
|
812
|
+
<define name="ruby_pronunciation">
|
813
|
+
<element name="pronunciation">
|
814
|
+
<attribute name="value"/>
|
815
|
+
<optional>
|
816
|
+
<attribute name="script"/>
|
817
|
+
</optional>
|
818
|
+
<optional>
|
819
|
+
<attribute name="lang"/>
|
820
|
+
</optional>
|
732
821
|
</element>
|
733
822
|
</define>
|
734
|
-
<define name="
|
735
|
-
<element name="
|
736
|
-
<
|
737
|
-
|
738
|
-
|
823
|
+
<define name="ruby_annotation">
|
824
|
+
<element name="annotation">
|
825
|
+
<attribute name="value"/>
|
826
|
+
<optional>
|
827
|
+
<attribute name="script"/>
|
828
|
+
</optional>
|
829
|
+
<optional>
|
830
|
+
<attribute name="lang"/>
|
831
|
+
</optional>
|
739
832
|
</element>
|
740
833
|
</define>
|
741
834
|
<define name="br">
|
@@ -914,44 +1007,49 @@
|
|
914
1007
|
-->
|
915
1008
|
<define name="image">
|
916
1009
|
<element name="image">
|
917
|
-
<
|
918
|
-
|
1010
|
+
<ref name="Image"/>
|
1011
|
+
</element>
|
1012
|
+
</define>
|
1013
|
+
<define name="Image">
|
1014
|
+
<attribute name="id">
|
1015
|
+
<data type="ID"/>
|
1016
|
+
</attribute>
|
1017
|
+
<attribute name="src">
|
1018
|
+
<data type="anyURI"/>
|
1019
|
+
</attribute>
|
1020
|
+
<attribute name="mimetype"/>
|
1021
|
+
<optional>
|
1022
|
+
<attribute name="filename"/>
|
1023
|
+
</optional>
|
1024
|
+
<optional>
|
1025
|
+
<attribute name="width">
|
1026
|
+
<ref name="ImageSize"/>
|
919
1027
|
</attribute>
|
920
|
-
|
1028
|
+
</optional>
|
1029
|
+
<optional>
|
1030
|
+
<attribute name="height">
|
1031
|
+
<ref name="ImageSize"/>
|
1032
|
+
</attribute>
|
1033
|
+
</optional>
|
1034
|
+
<optional>
|
1035
|
+
<attribute name="alt"/>
|
1036
|
+
</optional>
|
1037
|
+
<optional>
|
1038
|
+
<attribute name="title"/>
|
1039
|
+
</optional>
|
1040
|
+
<optional>
|
1041
|
+
<attribute name="longdesc">
|
921
1042
|
<data type="anyURI"/>
|
922
1043
|
</attribute>
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
<
|
928
|
-
<
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
</choice>
|
933
|
-
</attribute>
|
934
|
-
</optional>
|
935
|
-
<optional>
|
936
|
-
<attribute name="height">
|
937
|
-
<choice>
|
938
|
-
<data type="int"/>
|
939
|
-
<value>auto</value>
|
940
|
-
</choice>
|
941
|
-
</attribute>
|
942
|
-
</optional>
|
943
|
-
<optional>
|
944
|
-
<attribute name="alt"/>
|
945
|
-
</optional>
|
946
|
-
<optional>
|
947
|
-
<attribute name="title"/>
|
948
|
-
</optional>
|
949
|
-
<optional>
|
950
|
-
<attribute name="longdesc">
|
951
|
-
<data type="anyURI"/>
|
952
|
-
</attribute>
|
953
|
-
</optional>
|
954
|
-
</element>
|
1044
|
+
</optional>
|
1045
|
+
</define>
|
1046
|
+
<define name="ImageSize">
|
1047
|
+
<choice>
|
1048
|
+
<data type="string">
|
1049
|
+
<param name="pattern">\d+([.]\d+)?(%?)</param>
|
1050
|
+
</data>
|
1051
|
+
<value>auto</value>
|
1052
|
+
</choice>
|
955
1053
|
</define>
|
956
1054
|
<define name="video">
|
957
1055
|
<element name="video">
|
data/grammars/biblio-standoc.rng
CHANGED
@@ -9,11 +9,42 @@
|
|
9
9
|
-->
|
10
10
|
<include href="biblio.rng">
|
11
11
|
<define name="BibData">
|
12
|
-
<ref name="
|
12
|
+
<ref name="StandardBibliographicItem"/>
|
13
13
|
<optional>
|
14
14
|
<ref name="ext"/>
|
15
15
|
</optional>
|
16
16
|
</define>
|
17
|
+
<define name="docrelation">
|
18
|
+
<element name="relation">
|
19
|
+
<attribute name="type">
|
20
|
+
<ref name="DocRelationType"/>
|
21
|
+
</attribute>
|
22
|
+
<optional>
|
23
|
+
<element name="description">
|
24
|
+
<ref name="FormattedString"/>
|
25
|
+
</element>
|
26
|
+
</optional>
|
27
|
+
<element name="bibitem">
|
28
|
+
<ref name="StandardReducedBibliographicItem"/>
|
29
|
+
</element>
|
30
|
+
<choice>
|
31
|
+
<zeroOrMore>
|
32
|
+
<ref name="locality"/>
|
33
|
+
</zeroOrMore>
|
34
|
+
<zeroOrMore>
|
35
|
+
<ref name="localityStack"/>
|
36
|
+
</zeroOrMore>
|
37
|
+
</choice>
|
38
|
+
<choice>
|
39
|
+
<zeroOrMore>
|
40
|
+
<ref name="sourceLocality"/>
|
41
|
+
</zeroOrMore>
|
42
|
+
<zeroOrMore>
|
43
|
+
<ref name="sourceLocalityStack"/>
|
44
|
+
</zeroOrMore>
|
45
|
+
</choice>
|
46
|
+
</element>
|
47
|
+
</define>
|
17
48
|
</include>
|
18
49
|
<define name="ext">
|
19
50
|
<element name="ext">
|
@@ -161,4 +192,16 @@
|
|
161
192
|
</optional>
|
162
193
|
</element>
|
163
194
|
</define>
|
195
|
+
<define name="StandardBibliographicItem">
|
196
|
+
<ref name="BibliographicItem"/>
|
197
|
+
<zeroOrMore>
|
198
|
+
<ref name="amend"/>
|
199
|
+
</zeroOrMore>
|
200
|
+
</define>
|
201
|
+
<define name="StandardReducedBibliographicItem">
|
202
|
+
<ref name="ReducedBibliographicItem"/>
|
203
|
+
<zeroOrMore>
|
204
|
+
<ref name="amend"/>
|
205
|
+
</zeroOrMore>
|
206
|
+
</define>
|
164
207
|
</grammar>
|
data/grammars/biblio.rng
CHANGED
@@ -241,6 +241,9 @@
|
|
241
241
|
</element>
|
242
242
|
</define>
|
243
243
|
<define name="FullNameType">
|
244
|
+
<optional>
|
245
|
+
<ref name="name_abbreviation"/>
|
246
|
+
</optional>
|
244
247
|
<choice>
|
245
248
|
<group>
|
246
249
|
<zeroOrMore>
|
@@ -266,6 +269,11 @@
|
|
266
269
|
<ref name="variantname"/>
|
267
270
|
</zeroOrMore>
|
268
271
|
</define>
|
272
|
+
<define name="name_abbreviation">
|
273
|
+
<element name="abbreviation">
|
274
|
+
<ref name="LocalizedString"/>
|
275
|
+
</element>
|
276
|
+
</define>
|
269
277
|
<define name="prefix">
|
270
278
|
<element name="prefix">
|
271
279
|
<ref name="LocalizedString"/>
|
@@ -348,6 +356,9 @@
|
|
348
356
|
<zeroOrMore>
|
349
357
|
<ref name="contact"/>
|
350
358
|
</zeroOrMore>
|
359
|
+
<optional>
|
360
|
+
<ref name="logo"/>
|
361
|
+
</optional>
|
351
362
|
</element>
|
352
363
|
</define>
|
353
364
|
<define name="orgname">
|
@@ -366,6 +377,21 @@
|
|
366
377
|
</choice>
|
367
378
|
</element>
|
368
379
|
</define>
|
380
|
+
<define name="logo">
|
381
|
+
<element name="logo">
|
382
|
+
<ref name="image"/>
|
383
|
+
</element>
|
384
|
+
</define>
|
385
|
+
<define name="depiction">
|
386
|
+
<element name="depiction">
|
387
|
+
<optional>
|
388
|
+
<attribute name="scope"/>
|
389
|
+
</optional>
|
390
|
+
<zeroOrMore>
|
391
|
+
<ref name="image"/>
|
392
|
+
</zeroOrMore>
|
393
|
+
</element>
|
394
|
+
</define>
|
369
395
|
<define name="NameWithVariants">
|
370
396
|
<element name="primary">
|
371
397
|
<ref name="LocalizedString"/>
|
@@ -752,6 +778,9 @@
|
|
752
778
|
<optional>
|
753
779
|
<ref name="validity"/>
|
754
780
|
</optional>
|
781
|
+
<optional>
|
782
|
+
<ref name="depiction"/>
|
783
|
+
</optional>
|
755
784
|
</define>
|
756
785
|
<define name="ReducedBibliographicItem">
|
757
786
|
<optional>
|
@@ -849,6 +878,9 @@
|
|
849
878
|
<optional>
|
850
879
|
<ref name="validity"/>
|
851
880
|
</optional>
|
881
|
+
<optional>
|
882
|
+
<ref name="depiction"/>
|
883
|
+
</optional>
|
852
884
|
</define>
|
853
885
|
<define name="btitle">
|
854
886
|
<element name="title">
|
@@ -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
|
@@ -43,10 +43,10 @@ module RelatonNist
|
|
43
43
|
RelatonNist::NistBibliographicItem.new(
|
44
44
|
type: "standard", language: [@doc["language"]], script: ["Latn"], **args
|
45
45
|
)
|
46
|
-
rescue StandardError => e
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
# rescue StandardError => e
|
47
|
+
# warn "Document: `#{pub_id}`"
|
48
|
+
# warn e.message
|
49
|
+
# warn e.backtrace[0..5].join("\n")
|
50
50
|
end
|
51
51
|
|
52
52
|
def args
|
@@ -73,12 +73,18 @@ module RelatonNist
|
|
73
73
|
#
|
74
74
|
def pub_id
|
75
75
|
# anchor(doc).gsub(".", " ")
|
76
|
-
doi
|
76
|
+
if doi
|
77
|
+
doi.split("/")[1..].join("/").gsub(".", " ").sub(/^nist\sir/, "NIST IR")
|
78
|
+
else
|
79
|
+
@doc.at("publisher_item/item_number").text
|
80
|
+
end
|
77
81
|
end
|
78
82
|
|
79
83
|
def doi # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength
|
80
|
-
@doi
|
81
|
-
|
84
|
+
return @doi if defined? @doi
|
85
|
+
|
86
|
+
@doi = begin
|
87
|
+
id = @doc.at("doi_data/doi")&.text
|
82
88
|
case id
|
83
89
|
when "10.6028/NBS.CIRC.e2e" then "10.6028/NBS.CIRC.2e2"
|
84
90
|
when "10.6028/NBS.CIRC.sup" then "10.6028/NBS.CIRC.24e7sup"
|
@@ -146,7 +152,7 @@ module RelatonNist
|
|
146
152
|
# @return [Array<Hash>]
|
147
153
|
def parse_contributor
|
148
154
|
contribs = @doc.xpath("contributors/person_name").map do |p|
|
149
|
-
person = RelatonBib::Person.new(name: fullname(p), affiliation: affiliation)
|
155
|
+
person = RelatonBib::Person.new(name: fullname(p), affiliation: affiliation, identifier: identifier(p))
|
150
156
|
{ entity: person, role: [{ type: p["contributor_role"] }] }
|
151
157
|
end
|
152
158
|
contribs + @doc.xpath("publisher").map do |p|
|
@@ -154,6 +160,12 @@ module RelatonNist
|
|
154
160
|
end
|
155
161
|
end
|
156
162
|
|
163
|
+
def identifier(person)
|
164
|
+
person.xpath("ORCID").map do |id|
|
165
|
+
RelatonBib::PersonIdentifier.new "orcid", id.text
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
157
169
|
#
|
158
170
|
# Create full name object from person name element.
|
159
171
|
#
|
@@ -163,12 +175,11 @@ module RelatonNist
|
|
163
175
|
#
|
164
176
|
def fullname(person)
|
165
177
|
fname, initials = forename_initial person
|
166
|
-
surname = localized_string person.at("surname")
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
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
|
+
)
|
172
183
|
end
|
173
184
|
|
174
185
|
#
|
@@ -290,6 +301,7 @@ module RelatonNist
|
|
290
301
|
# @return [RelatonBib::LocalizedString] localized string
|
291
302
|
#
|
292
303
|
def localized_string(content)
|
304
|
+
return unless content
|
293
305
|
RelatonBib::LocalizedString.new content, @doc["language"], "Latn"
|
294
306
|
end
|
295
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:
|
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.'
|