relaton-nist 0.6.0 → 0.9.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: 7e3fe0082c96d14813be5f97e804a0a18388dddef792c2a568f1c8eafbe2ab3e
4
- data.tar.gz: e17bcac5fbf0a88421e0ad1f323df1757a5d3ef0d2afe340dac1b129a873bbb7
3
+ metadata.gz: abd608217be8e9fa36bc9e6d387d76bcac0655cc9ae9cb2ad6dd8a10981f15ec
4
+ data.tar.gz: 80e6d48a013bb510009ffc968bb7332daac07a9858bf42895183d848c4ba7e5c
5
5
  SHA512:
6
- metadata.gz: adfa7e515816d96492539b8a0a58eca2ea0c4b0b04ea6db630185ed0acd4297bfc50eb3d6c74a7b7ad39a4c6ca259efbf511a47028e689adc4f2e2344f93def0
7
- data.tar.gz: 649054e40e9449bb87b120683cd50027d9f2fbbfd55884cffbff5db678ac9d3f181adcce7ebd6f4379a1b95eeaa5c846cf28e5d66744f0ee5b7d096c7721128f
6
+ metadata.gz: 1d79eddb9c2a1f58fe7478c1de1d7fd4444a7db3c84b2f59b8b8f3447bedd9ee84cf55297e0b32abbaf42c632f90b7952615203fbc3d1e5c4adfff330446d8ac
7
+ data.tar.gz: d327e6358a7f2f5a3b9761c9106b17c6b04c9db026359d217a35a7d501759a26f5767bc68b6ebd01f6a04eaa95693732f34c1e1b701b1d98b6055080bfc1b89b
@@ -3,9 +3,6 @@
3
3
  module RelatonNist
4
4
  # Hit.
5
5
  class Hit < RelatonBib::Hit
6
- # @return [RelatonNist::HitCollection]
7
- attr_reader :hit_collection
8
-
9
6
  # Parse page.
10
7
  # @return [RelatonNist::NistBliographicItem]
11
8
  def fetch
@@ -13,30 +13,24 @@ module RelatonNist
13
13
  DATAFILEDIR = File.expand_path ".relaton/nist", Dir.home
14
14
  DATAFILE = File.expand_path "pubs-export.zip", DATAFILEDIR
15
15
 
16
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
17
-
18
16
  # @param ref_nbr [String]
19
17
  # @param year [String]
20
18
  # @param opts [Hash]
21
19
  # @option opts [String] :stage
22
20
  def initialize(ref_nbr, year = nil, opts = {})
23
- @text = ref_nbr
24
- @year = year
21
+ super ref_nbr, year
25
22
 
26
23
  /(?<docid>(SP|FIPS)\s[0-9-]+)/ =~ text
27
- hits = docid ? from_json(docid, **opts) : from_csrc(**opts)
24
+ @array = docid ? from_json(docid, **opts) : from_csrc(**opts)
28
25
 
29
- hits.sort! do |a, b|
26
+ @array.sort! do |a, b|
30
27
  if a.sort_value != b.sort_value
31
28
  b.sort_value - a.sort_value
32
29
  else
33
30
  (b.hit[:release_date] - a.hit[:release_date]).to_i
34
31
  end
35
32
  end
36
- concat hits
37
- @fetched = false
38
33
  end
39
- # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
40
34
 
41
35
  private
42
36
 
@@ -60,9 +60,12 @@ module RelatonNist
60
60
  def nistbib_get1(code, year, opts)
61
61
  result = nistbib_search_filter(code, year, opts) || (return nil)
62
62
  ret = nistbib_results_filter(result, year, opts)
63
- return ret[:ret] if ret[:ret]
64
-
65
- fetch_ref_err(code, year, ret[:years])
63
+ if ret[:ret]
64
+ warn "[relaton-nist] (\"#{code}\") found #{ret[:ret].docidentifier.first.id}"
65
+ ret[:ret]
66
+ else
67
+ fetch_ref_err(code, year, ret[:years])
68
+ end
66
69
  end
67
70
 
68
71
  # Sort through the results from RelatonNist, fetching them three at a time,
@@ -119,7 +122,7 @@ module RelatonNist
119
122
  def nistbib_search_filter(code, year, opts)
120
123
  docid = code.match(%r{[0-9-]{3,}}).to_s
121
124
  serie = code.match(%r{(FISP|SP|NISTIR)(?=\s)})
122
- warn "fetching #{code}..."
125
+ warn "[relaton-nist] (\"#{code}\") fetching..."
123
126
  result = search(code, year, opts)
124
127
  result.select do |i|
125
128
  i.hit[:code]&.include?(docid) && (!serie || i.hit[:serie] == serie.to_s)
@@ -128,12 +131,12 @@ module RelatonNist
128
131
 
129
132
  def fetch_ref_err(code, year, missed_years)
130
133
  id = year ? "#{code}:#{year}" : code
131
- warn "WARNING: no match found online for #{id}. "\
134
+ warn "[relaton-nist] WARNING: no match found online for #{id}. "\
132
135
  "The code must be exactly like it is on the standards website."
133
- warn "(There was no match for #{year}, though there were matches "\
136
+ warn "[relaton-nist] (There was no match for #{year}, though there were matches "\
134
137
  "found for #{missed_years.join(', ')}.)" unless missed_years.empty?
135
138
  if /\d-\d/ =~ code
136
- warn "The provided document part may not exist, or the document "\
139
+ warn "[relaton-nist] The provided document part may not exist, or the document "\
137
140
  "may no longer be published in parts."
138
141
  end
139
142
  nil
@@ -235,7 +235,7 @@ module RelatonNist
235
235
  )
236
236
  end
237
237
  if contr["surname"]
238
- affiliation = RelatonBib::Affilation.new organization: org
238
+ affiliation = RelatonBib::Affiliation.new organization: org
239
239
  entity = RelatonBib::Person.new(
240
240
  name: full_name(contr, lang, script), affiliation: [affiliation],
241
241
  )
@@ -271,7 +271,7 @@ module RelatonNist
271
271
  url = nil
272
272
  end
273
273
  org = RelatonBib::Organization.new name: org_name, url: url, abbreviation: abbrev
274
- affiliation = RelatonBib::Affilation.new organization: org
274
+ affiliation = RelatonBib::Affiliation.new organization: org
275
275
  entity = RelatonBib::Person.new(
276
276
  name: fullname, affiliation: [affiliation],
277
277
  )
@@ -1,3 +1,3 @@
1
1
  module RelatonNist
2
- VERSION = "0.6.0".freeze
2
+ VERSION = "0.9.0".freeze
3
3
  end
@@ -3,8 +3,13 @@ module RelatonNist
3
3
  class << self
4
4
  def from_xml(xml)
5
5
  doc = Nokogiri::XML xml
6
+ doc.remove_namespaces!
6
7
  nistitem = doc.at("/bibitem|/bibdata")
7
- NistBibliographicItem.new(item_data(nistitem))
8
+ if nistitem
9
+ NistBibliographicItem.new(item_data(nistitem))
10
+ elsif
11
+ warn "[relaton-nist] can't find bibitem or bibdata element in the XML"
12
+ end
8
13
  end
9
14
 
10
15
  private
data/relaton_nist.gemspec CHANGED
@@ -23,18 +23,17 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ["lib"]
24
24
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
25
25
 
26
- spec.add_development_dependency "byebug"
27
26
  spec.add_development_dependency "debase"
28
27
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
29
28
  spec.add_development_dependency "pry-byebug"
30
29
  spec.add_development_dependency "rake", "~> 10.0"
31
30
  spec.add_development_dependency "rspec", "~> 3.0"
32
31
  spec.add_development_dependency "ruby-debug-ide"
32
+ spec.add_development_dependency "ruby-jing"
33
33
  spec.add_development_dependency "simplecov"
34
34
  spec.add_development_dependency "vcr"
35
35
  spec.add_development_dependency "webmock"
36
- spec.add_development_dependency "ruby-jing"
37
36
 
38
- spec.add_dependency "relaton-bib", "~> 0.6.0"
37
+ spec.add_dependency "relaton-bib", "~> 0.9.0"
39
38
  spec.add_dependency "rubyzip"
40
39
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-nist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.9.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: 2020-02-15 00:00:00.000000000 Z
11
+ date: 2020-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: byebug
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: debase
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +95,7 @@ dependencies:
109
95
  - !ruby/object:Gem::Version
110
96
  version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
- name: simplecov
98
+ name: ruby-jing
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - ">="
@@ -123,7 +109,7 @@ dependencies:
123
109
  - !ruby/object:Gem::Version
124
110
  version: '0'
125
111
  - !ruby/object:Gem::Dependency
126
- name: vcr
112
+ name: simplecov
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
115
  - - ">="
@@ -137,7 +123,7 @@ dependencies:
137
123
  - !ruby/object:Gem::Version
138
124
  version: '0'
139
125
  - !ruby/object:Gem::Dependency
140
- name: webmock
126
+ name: vcr
141
127
  requirement: !ruby/object:Gem::Requirement
142
128
  requirements:
143
129
  - - ">="
@@ -151,7 +137,7 @@ dependencies:
151
137
  - !ruby/object:Gem::Version
152
138
  version: '0'
153
139
  - !ruby/object:Gem::Dependency
154
- name: ruby-jing
140
+ name: webmock
155
141
  requirement: !ruby/object:Gem::Requirement
156
142
  requirements:
157
143
  - - ">="
@@ -170,14 +156,14 @@ dependencies:
170
156
  requirements:
171
157
  - - "~>"
172
158
  - !ruby/object:Gem::Version
173
- version: 0.6.0
159
+ version: 0.9.0
174
160
  type: :runtime
175
161
  prerelease: false
176
162
  version_requirements: !ruby/object:Gem::Requirement
177
163
  requirements:
178
164
  - - "~>"
179
165
  - !ruby/object:Gem::Version
180
- version: 0.6.0
166
+ version: 0.9.0
181
167
  - !ruby/object:Gem::Dependency
182
168
  name: rubyzip
183
169
  requirement: !ruby/object:Gem::Requirement