relaton-nist 1.14.3 → 1.14.5
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 -0
- data/.github/workflows/release.yml +3 -2
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/Gemfile +9 -0
- data/lib/relaton_nist/data_fetcher.rb +6 -0
- data/lib/relaton_nist/hit_collection.rb +15 -15
- data/lib/relaton_nist/nist_bibliographic_item.rb +1 -1
- data/lib/relaton_nist/nist_bibliography.rb +1 -1
- data/lib/relaton_nist/processor.rb +7 -0
- data/lib/relaton_nist/version.rb +1 -1
- data/lib/relaton_nist.rb +1 -0
- data/relaton_nist.gemspec +3 -11
- metadata +11 -109
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b442dc75e9c4b20221b94bd56200f5391f479709cb44bda543827bdeca67cf7
|
4
|
+
data.tar.gz: 553d1a834486c36d3febec1046480f5e803d98865c34f119c5698b253f3186fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1b1c058632239fefd0bb171f645eba0a7036e806fc3064faa4f2742d386e01e07f891b4c89172ae6b9811e75d6d05b0603391e68b58ae88789cb2d9cbd8ed35
|
7
|
+
data.tar.gz: '07039ccd91afca1ebc62471d0c7b3fa64695f7f5ed88f0eb11fd12d00c87851a33f66c08d7ba4e69f61ff0b1a82bb9e0a88eaf613d18d00b4a4e52ac051916f4'
|
data/.github/workflows/rake.yml
CHANGED
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
@@ -2,3 +2,12 @@ source "https://rubygems.org"
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in relaton_nist.gemspec
|
4
4
|
gemspec
|
5
|
+
|
6
|
+
gem "equivalent-xml", "~> 0.6"
|
7
|
+
gem "pry-byebug"
|
8
|
+
gem "rake", "~> 13.0"
|
9
|
+
gem "rspec", "~> 3.0"
|
10
|
+
gem "ruby-jing"
|
11
|
+
gem "simplecov"
|
12
|
+
gem "vcr"
|
13
|
+
gem "webmock"
|
@@ -24,6 +24,10 @@ module RelatonNist
|
|
24
24
|
@files = []
|
25
25
|
end
|
26
26
|
|
27
|
+
def index
|
28
|
+
@index ||= Relaton::Index.find_or_create :nist, file: "index-v1.yaml"
|
29
|
+
end
|
30
|
+
|
27
31
|
def parse_docid(doc) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
28
32
|
# case doi
|
29
33
|
# when "10.6028/NBS.CIRC.12e2revjune" then doi.sub!("13e", "12e")
|
@@ -296,6 +300,7 @@ module RelatonNist
|
|
296
300
|
when "xml" then bib.to_xml bibdata: true
|
297
301
|
else bib.send "to_#{@format}"
|
298
302
|
end
|
303
|
+
index.add_or_update bib.docidentifier[0].id, file
|
299
304
|
File.write file, output, encoding: "UTF-8"
|
300
305
|
end
|
301
306
|
|
@@ -337,6 +342,7 @@ module RelatonNist
|
|
337
342
|
docs.xpath("/body/query/doi_record/report-paper/report-paper_metadata")
|
338
343
|
.each { |doc| parse_doc doc }
|
339
344
|
|
345
|
+
index.save
|
340
346
|
t2 = Time.now
|
341
347
|
puts "Stopped at: #{t2}"
|
342
348
|
puts "Done in: #{(t2 - t1).round} sec."
|
@@ -9,7 +9,8 @@ require "open-uri"
|
|
9
9
|
module RelatonNist
|
10
10
|
# Hit collection.
|
11
11
|
class HitCollection < RelatonBib::HitCollection
|
12
|
-
GHNISTDATA = "https://raw.githubusercontent.com/relaton/relaton-data-nist/main/
|
12
|
+
GHNISTDATA = "https://raw.githubusercontent.com/relaton/relaton-data-nist/main/"
|
13
|
+
INDEX_FILE = "index-v1.yaml"
|
13
14
|
|
14
15
|
#
|
15
16
|
# @param [String] text reference
|
@@ -57,14 +58,11 @@ module RelatonNist
|
|
57
58
|
parts = doi_parts(item.hit[:json]) || code_parts(item.hit[:code])
|
58
59
|
(refparts[:code] && [parts[:series], item.hit[:series]].include?(refparts[:series]) &&
|
59
60
|
refparts[:code].casecmp(parts[:code].upcase).zero? &&
|
60
|
-
(
|
61
|
-
(
|
62
|
-
(
|
63
|
-
(
|
64
|
-
refparts[:draft] == parts[:draft] && refparts[:add] == parts[:add]
|
65
|
-
refparts[:res] == parts[:res]) # ||
|
66
|
-
# (refparts[:code] && !refparts[:code].empty? &&
|
67
|
-
# item.hit[:title]&.include?("#{refparts[:series]} #{refparts[:code]}"))
|
61
|
+
(refparts[:prt] == parts[:prt]) &&
|
62
|
+
(refparts[:vol] == parts[:vol]) &&
|
63
|
+
(refparts[:ver] == parts[:ver]) &&
|
64
|
+
(refparts[:rev] == parts[:rev]) &&
|
65
|
+
refparts[:draft] == parts[:draft] && refparts[:add] == parts[:add])
|
68
66
|
end
|
69
67
|
end
|
70
68
|
|
@@ -72,7 +70,7 @@ module RelatonNist
|
|
72
70
|
|
73
71
|
def code_parts(code) # rubocop:disable Metrics/MethodLength
|
74
72
|
{
|
75
|
-
prefix: match(/^(?:NIST|NBS)\s?/, code),
|
73
|
+
# prefix: match(/^(?:NIST|NBS)\s?/, code),
|
76
74
|
series: match(/(?<val>(?:SP|FIPS|IR|ITL\sBulletin|White\sPaper))\s/, code),
|
77
75
|
code: match(/(?<val>[0-9-]{3,}[A-Z]?)/, code),
|
78
76
|
prt: match(/(?:pt|\sPart\s)(?<val>\d+)/, code),
|
@@ -85,7 +83,6 @@ module RelatonNist
|
|
85
83
|
# (?:\s(?<rev2>Rev\.\s\d+))?
|
86
84
|
add: match(/\sAdd(?:endum)?(?<val>\d*)/, code),
|
87
85
|
draft: !match(/\((?:Retired\s)?Draft\)/, code).nil?,
|
88
|
-
res: match(/(?<=\s)RES/, text),
|
89
86
|
}
|
90
87
|
end
|
91
88
|
|
@@ -94,7 +91,7 @@ module RelatonNist
|
|
94
91
|
|
95
92
|
id = json["doi"].split("/").last
|
96
93
|
{
|
97
|
-
prefix: match(/^(?:NIST|NBS)\./, id),
|
94
|
+
# prefix: match(/^(?:NIST|NBS)\./, id),
|
98
95
|
series: match(/(?:SP|FIPS|IR|ITL\sBulletin|White\sPaper)(?=\.)/, id),
|
99
96
|
code: match(/(?<=\.)\d{3,}(?:-\d+)*(?:[[:alpha:]](?!\d|raft|er|t?\d))?/, id),
|
100
97
|
prt: match(/pt?(?<val>\d+)/, id),
|
@@ -122,7 +119,6 @@ module RelatonNist
|
|
122
119
|
rev: match(/(?:(?:(?<dl>\.)|[^a-z])r|\sRev\.\s)(?(<dl>)-)(?<val>\d+)/, text),
|
123
120
|
add: match(/(?:(?<dl>\.)?add|\/Add)(?(<dl>)-)(?<val>\d*)/, text),
|
124
121
|
draft: !(match(/\((?:Draft|PD)\)/, text).nil? && @opts[:stage].nil?),
|
125
|
-
res: match(/(?<=\s)RES/, text),
|
126
122
|
# prt2: match(/(?<=\s)Part\s[A-Z\d]+/, text),
|
127
123
|
# vol2: match(/(?<=\s)Vol\.\s\d+/, text),
|
128
124
|
# ver2: match(/(?<=\s)Ver\.\s\d+/, text),
|
@@ -186,8 +182,12 @@ module RelatonNist
|
|
186
182
|
#
|
187
183
|
def from_ga # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
188
184
|
ref = full_ref
|
189
|
-
fn = ref.gsub(%r{[/\s:.]}, "_").upcase
|
190
|
-
|
185
|
+
# fn = ref.gsub(%r{[/\s:.]}, "_").upcase
|
186
|
+
index = Relaton::Index.find_or_create :nist, url: "#{GHNISTDATA}index-v1.zip", file: INDEX_FILE
|
187
|
+
row = index.search { |r| r[:id] == ref }.min_by { |r| r[:id] }
|
188
|
+
return [] unless row
|
189
|
+
|
190
|
+
yaml = OpenURI.open_uri "#{GHNISTDATA}#{row[:file]}"
|
191
191
|
hash = YAML.safe_load yaml
|
192
192
|
hash["fetched"] = Date.today.to_s
|
193
193
|
bib = RelatonNist::NistBibliographicItem.from_hash hash
|
@@ -19,7 +19,7 @@ module RelatonNist
|
|
19
19
|
# @return [RelatonNist::HitCollection] search result
|
20
20
|
#
|
21
21
|
def search(text, year = nil, opts = {})
|
22
|
-
ref = text.sub(/^
|
22
|
+
ref = text.sub(/^NISTIR/, "NIST IR")
|
23
23
|
HitCollection.search ref, year, opts
|
24
24
|
rescue OpenURI::HTTPError, SocketError, OpenSSL::SSL::SSLError => e
|
25
25
|
raise RelatonBib::RequestError, e.message
|
@@ -47,5 +47,12 @@ module RelatonNist
|
|
47
47
|
def grammar_hash
|
48
48
|
@grammar_hash ||= ::RelatonNist.grammar_hash
|
49
49
|
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# Remove index file
|
53
|
+
#
|
54
|
+
def remove_index_file
|
55
|
+
Relaton::Index.find_or_create(:nist, url: true, file: HitCollection::INDEX_FILE).remove_file
|
56
|
+
end
|
50
57
|
end
|
51
58
|
end
|
data/lib/relaton_nist/version.rb
CHANGED
data/lib/relaton_nist.rb
CHANGED
data/relaton_nist.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
lib = File.expand_path("
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
require "relaton_nist/version"
|
4
4
|
|
@@ -21,17 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.bindir = "exe"
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
25
|
-
|
26
|
-
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
27
|
-
spec.add_development_dependency "pry-byebug"
|
28
|
-
spec.add_development_dependency "rake", "~> 13.0"
|
29
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
30
|
-
spec.add_development_dependency "ruby-jing"
|
31
|
-
spec.add_development_dependency "simplecov"
|
32
|
-
spec.add_development_dependency "vcr"
|
33
|
-
spec.add_development_dependency "webmock"
|
24
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
34
25
|
|
35
26
|
spec.add_dependency "relaton-bib", "~> 1.14.0"
|
27
|
+
spec.add_dependency "relaton-index", "~> 0.2.0"
|
36
28
|
spec.add_dependency "rubyzip"
|
37
29
|
end
|
metadata
CHANGED
@@ -1,141 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-nist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.14.
|
4
|
+
version: 1.14.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: 2023-
|
11
|
+
date: 2023-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.6'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0.6'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: pry-byebug
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '13.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '13.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
14
|
+
name: relaton-bib
|
57
15
|
requirement: !ruby/object:Gem::Requirement
|
58
16
|
requirements:
|
59
17
|
- - "~>"
|
60
18
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
-
type: :
|
19
|
+
version: 1.14.0
|
20
|
+
type: :runtime
|
63
21
|
prerelease: false
|
64
22
|
version_requirements: !ruby/object:Gem::Requirement
|
65
23
|
requirements:
|
66
24
|
- - "~>"
|
67
25
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: ruby-jing
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: simplecov
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: vcr
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: webmock
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
26
|
+
version: 1.14.0
|
125
27
|
- !ruby/object:Gem::Dependency
|
126
|
-
name: relaton-
|
28
|
+
name: relaton-index
|
127
29
|
requirement: !ruby/object:Gem::Requirement
|
128
30
|
requirements:
|
129
31
|
- - "~>"
|
130
32
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
33
|
+
version: 0.2.0
|
132
34
|
type: :runtime
|
133
35
|
prerelease: false
|
134
36
|
version_requirements: !ruby/object:Gem::Requirement
|
135
37
|
requirements:
|
136
38
|
- - "~>"
|
137
39
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
40
|
+
version: 0.2.0
|
139
41
|
- !ruby/object:Gem::Dependency
|
140
42
|
name: rubyzip
|
141
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,14 +106,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
204
106
|
requirements:
|
205
107
|
- - ">="
|
206
108
|
- !ruby/object:Gem::Version
|
207
|
-
version: 2.
|
109
|
+
version: 2.7.0
|
208
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
111
|
requirements:
|
210
112
|
- - ">="
|
211
113
|
- !ruby/object:Gem::Version
|
212
114
|
version: '0'
|
213
115
|
requirements: []
|
214
|
-
rubygems_version: 3.
|
116
|
+
rubygems_version: 3.3.26
|
215
117
|
signing_key:
|
216
118
|
specification_version: 4
|
217
119
|
summary: 'RelatonNist: retrive NIST standards.'
|