relaton-nist 1.14.3 → 1.14.4

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: 2e235a74aee86bfb4fce55d8e7a89b4ab4afc2df13ae0a733512f30a7f63cd4c
4
- data.tar.gz: bc8e8144f15c430618d0b2d6447d33dc607cf0fac165ebffdfa9ff816c18da37
3
+ metadata.gz: b6d5fa6a33aea5f2dd4cf62aa71a4da7ab9b41847ac35f35053810cccf2d334a
4
+ data.tar.gz: f38d1704600169333dfbcc8e24f29bbdc93f92f47ded7754f04a4492bd3dd1a1
5
5
  SHA512:
6
- metadata.gz: 2ce74d0722ef6ba698eb73f07e990c011b7247beed74e3750629a81da24f0ffd5ea1a4fc1028ad2102828f93a0076a641f9bbb9bb992bbecce34c8d494192809
7
- data.tar.gz: 8ca7b46ccb2a5f2c689f78cb8d4c964b6c93334e6ff04f6748f9e651995607baa0cc0c4b164a1104aee41aa2c46243372a35b5c41ab0740e6dc405289becb3c2
6
+ metadata.gz: c807912db5bef3e57fc3a70ae862a6f9adca7b884d9174f56457ac28443a6bef6c572b745f5c3df6377313e5140b1a625c546ee9a93eaf050d70ccad4ad351b2
7
+ data.tar.gz: 64a6c9e1f751d6b8bfeae3c22b6fe7197e1d516afda4205dbcaf4cd67381ee6fc95e57865882a916824b6751feec7791138fbffa2d61357fd45e4797c436c35a
@@ -5,6 +5,7 @@ name: rake
5
5
  on:
6
6
  push:
7
7
  branches: [ master, main ]
8
+ tags: [ v* ]
8
9
  pull_request:
9
10
 
10
11
  jobs:
@@ -10,8 +10,9 @@ on:
10
10
  Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
11
11
  required: true
12
12
  default: 'skip'
13
- push:
14
- tags: [ v* ]
13
+ repository_dispatch:
14
+ types: [ do-release ]
15
+
15
16
 
16
17
  jobs:
17
18
  release:
data/.gitignore CHANGED
@@ -7,6 +7,7 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  .vscode/
10
+ /vendor/
10
11
  .rubocop-https---raw-githubusercontent-com-riboseinc-oss-guides-master-ci-rubocop-yml
11
12
 
12
13
  # rspec failure tracking
data/.rubocop.yml CHANGED
@@ -7,6 +7,6 @@ require: rubocop-rails
7
7
  inherit_from:
8
8
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
9
9
  AllCops:
10
- TargetRubyVersion: 2.6
10
+ TargetRubyVersion: 2.7
11
11
  Rails:
12
12
  Enabled: false
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/data/"
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
@@ -186,8 +187,12 @@ module RelatonNist
186
187
  #
187
188
  def from_ga # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
188
189
  ref = full_ref
189
- fn = ref.gsub(%r{[/\s:.]}, "_").upcase
190
- yaml = OpenURI.open_uri "#{GHNISTDATA}#{fn}.yaml"
190
+ # fn = ref.gsub(%r{[/\s:.]}, "_").upcase
191
+ index = Relaton::Index.find_or_create :nist, url: "#{GHNISTDATA}index-v1.zip", file: INDEX_FILE
192
+ row = index.search { |r| r[:id] == ref }.min_by { |r| r[:id] }
193
+ return [] unless row
194
+
195
+ yaml = OpenURI.open_uri "#{GHNISTDATA}#{row[:file]}"
191
196
  hash = YAML.safe_load yaml
192
197
  hash["fetched"] = Date.today.to_s
193
198
  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(/^NIST\sIR/, "NISTIR")
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
@@ -1,3 +1,3 @@
1
1
  module RelatonNist
2
- VERSION = "1.14.3".freeze
2
+ VERSION = "1.14.4".freeze
3
3
  end
data/lib/relaton_nist.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "singleton"
2
+ require "relaton/index"
2
3
  require "relaton_nist/version"
3
4
  require "relaton_nist/nist_bibliography"
4
5
  require "relaton_nist/data_fetcher"
data/relaton_nist.gemspec CHANGED
@@ -1,4 +1,4 @@
1
- lib = File.expand_path("../lib", __FILE__)
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.6.0")
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.3
4
+ version: 1.14.4
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-04-01 00:00:00.000000000 Z
11
+ date: 2023-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: equivalent-xml
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: '3.0'
62
- type: :development
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: '3.0'
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-bib
28
+ name: relaton-index
127
29
  requirement: !ruby/object:Gem::Requirement
128
30
  requirements:
129
31
  - - "~>"
130
32
  - !ruby/object:Gem::Version
131
- version: 1.14.0
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: 1.14.0
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.6.0
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.1.6
116
+ rubygems_version: 3.3.26
215
117
  signing_key:
216
118
  specification_version: 4
217
119
  summary: 'RelatonNist: retrive NIST standards.'