relaton-nist 1.11.0 → 1.11.3

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: 3efd113d39aa3ae5803492db6fedb79c6c77b8e6c346f545d7e56aedf5ccb90c
4
- data.tar.gz: 15bbf418f6ea804ccfb295fd566029bebf6e197d0d5985d5ee63f19909ce3bdc
3
+ metadata.gz: b6b0ce8787fdc41eb5b334df6e1d8f65c2bbfe6437ab8b36124d917c7549a869
4
+ data.tar.gz: d9b3bd1f467450a874ba8f9bc8d98c669a3296a0014c6083b248522bb4f6cd2a
5
5
  SHA512:
6
- metadata.gz: 69b106a55f829e861510cd4cd71eda6c11e689f0b78742cafe8333d81a0e6fcba87d708825439d85eb88543ea6a223749565b6d99469c34cf2889f87e429a88e
7
- data.tar.gz: 00fba574ac9177d32e8af0d9fc3d09947c13c2075a6bcdcf01d3525ee296e9b993f53033f6213dee59a8c33250606cb5034201697a1c1e022bfab2daa770ef2f
6
+ metadata.gz: beb5e04d0d431263d209e5172a419b940afe614888fd7a9158c360b7277d61312edf8824fef3989608a543c3bb36bd8612d1e737a07e7349d027aa9578d6c829
7
+ data.tar.gz: f46f37e146aedc51b9d91896ba38604af5bb95cc93e2d19c17e4f3894cffe5adac98fd05b176aa6830bed802b30e8163371d38caa25021742dc91fc8b0d11a10
data/Gemfile CHANGED
@@ -1,6 +1,3 @@
1
- Encoding.default_external = Encoding::UTF_8
2
- Encoding.default_internal = Encoding::UTF_8
3
-
4
1
  source "https://rubygems.org"
5
2
 
6
3
  # Specify your gem's dependencies in relaton_nist.gemspec
@@ -75,7 +75,9 @@ module RelatonNist
75
75
  t = doc.xpath("titles/title|titles/subtitle")
76
76
  return [] unless t.any?
77
77
 
78
- RelatonBib::TypedTitleString.from_string t.map(&:text).join, "en", "Latn"
78
+ # RelatonBib::TypedTitleString.from_string t.map(&:text).join, "en", "Latn"
79
+ [{ content: t.map(&:text).join, language: "en", script: "Latn",
80
+ format: "text/plain" }]
79
81
  end
80
82
 
81
83
  # @param doc [Nokogiri::XML::Element]
@@ -156,20 +158,37 @@ module RelatonNist
156
158
  { entity: person, role: [{ type: p["contributor_role"] }] }
157
159
  end
158
160
  contribs + doc.xpath("publisher").map do |p|
159
- abbr = p.at("../institution/institution_acronym")&.text
160
- place = p.at("./publisher_place")
161
- cont = []
162
- if place
163
- city, state = place.text.split(", ")
164
- cont << RelatonBib::Address.new(street: [], city: city, state: state, country: "US")
165
- end
166
- org = RelatonBib::Organization.new(
167
- name: p.at("publisher_name").text, abbreviation: abbr, contact: cont,
168
- )
169
- { entity: org, role: [{ type: "publisher" }] }
161
+ { entity: create_org(p), role: [{ type: "publisher" }] }
162
+ end
163
+ end
164
+
165
+ #
166
+ # Create publisher organization
167
+ #
168
+ # @param [Nokogiri::XML::Element] pub publisher element
169
+ #
170
+ # @return [RelatonBib::Organization] publisher organization
171
+ #
172
+ def create_org(pub)
173
+ name = pub.at("publisher_name").text
174
+ abbr = pub.at("../institution[institution_name[.='#{name}']]/institution_acronym")&.text
175
+ place = pub.at("./publisher_place") ||
176
+ pub.at("../institution[institution_name[.='#{name}']]/institution_place")
177
+ cont = []
178
+ if place
179
+ city, state = place.text.split(", ")
180
+ cont << RelatonBib::Address.new(street: [], city: city, state: state, country: "US")
170
181
  end
182
+ RelatonBib::Organization.new name: name, abbreviation: abbr, contact: cont
171
183
  end
172
184
 
185
+ #
186
+ # Create affiliation organization
187
+ #
188
+ # @param [Nokogiri::XML::Element] doc affiliation element
189
+ #
190
+ # @return [Array<RelatonBib::Affiliation>] affiliation
191
+ #
173
192
  def affiliation(doc)
174
193
  doc.xpath("./institution/institution_department").map do |id|
175
194
  org = RelatonBib::Organization.new name: id.text
@@ -183,9 +202,20 @@ module RelatonNist
183
202
  doc.xpath("institution/institution_place").map(&:text)
184
203
  end
185
204
 
205
+ #
206
+ # Fetches series
207
+ #
208
+ # @param [Nokogiri::XML::Element] doc document element
209
+ #
210
+ # @return [Array<RelatonBib::Series>] series
211
+ #
186
212
  def fetch_series(doc)
187
- title = RelatonBib::TypedTitleString.new(content: "NIST")
188
- [RelatonBib::Series.new(title: title, number: pub_id(doc))]
213
+ series_path = File.expand_path("series.yaml", __dir__)
214
+ series = YAML.load_file series_path
215
+ prf, srs, = pub_id(doc).split
216
+ sname = series[srs] || srs
217
+ title = RelatonBib::TypedTitleString.new(content: "#{prf} #{sname}")
218
+ [RelatonBib::Series.new(title: title, number: "#{prf} #{srs}")]
189
219
  end
190
220
 
191
221
  #
@@ -137,7 +137,7 @@ module RelatonNist
137
137
  # @return [Hash]
138
138
  def data
139
139
  ctime = File.ctime DATAFILE if File.exist? DATAFILE
140
- if !ctime || ctime.to_date < Date.today
140
+ if !ctime || ctime.to_date < Date.today || File.size(DATAFILE).zero?
141
141
  fetch_data(ctime)
142
142
  end
143
143
  unzip
@@ -163,10 +163,7 @@ module RelatonNist
163
163
  return @data if @data
164
164
 
165
165
  Zip::File.open(DATAFILE) do |zf|
166
- zf.each do |f|
167
- @data = JSON.parse f.get_input_stream.read
168
- break
169
- end
166
+ @data = JSON.parse zf.first.get_input_stream.read
170
167
  end
171
168
  @data
172
169
  end
@@ -0,0 +1,49 @@
1
+ ---
2
+ AMS: Advanced Manufacturing Series
3
+ BRPD: Basic Radio Propagation Predictions Series
4
+ BH: Building and Housing Reports
5
+ BMS: Building Materials and Structures Reports
6
+ BSS: Building Science Series
7
+ CRPL: CRPL Solar-Geophysical Data
8
+ IP: CRPL Ionospheric Predictions
9
+ CIRC: Circulars
10
+ CIS: Consumer Information Series
11
+ CS: Commercial Standards
12
+ CSM: Commercial Standards Monthly
13
+ CSWP: Cybersecurity White Papers
14
+ EAB: Economic Analysis Briefs
15
+ FIPS: Federal Information Processing Standards Publications
16
+ GCR: Grant/Contractor Reports
17
+ HB: Handbooks
18
+ HR: Hydraulic Research in the United States
19
+ IRPL: Interservice Radio Propagation Laboratory
20
+ LCIRC: Letter Circular
21
+ MONO: Monographs
22
+ MP: Miscellaneous Publications
23
+ NCSTAR: National Construction Safety Team Act Reports
24
+ NSRDS: National Standard Reference Data Series
25
+ IR: NISTIRs (Interagency/Internal Reports)
26
+ OWMWP: Office of Weights and Measures White Papers
27
+ PC: Photographic Circulars
28
+ RPT: NBS Reports
29
+ SIBS: Special Interior Ballistics Studies
30
+ SP: Special Publications (General)
31
+ SP250: 'SP 250: Calibration Services'
32
+ SP260: 'SP 260: Standard Reference Materials'
33
+ SP300: 'SP 300: Precision Measurement and Calibration'
34
+ SP400: 'SP 400: Semiconductor Measurement Technology'
35
+ SP480: 'SP 480: Law Enforcement Technology'
36
+ SP500: 'SP 500: Computer Systems Technology'
37
+ SP700: 'SP 700: Industrial Measurement Series'
38
+ SP800: 'SP 800: Computer Security Series'
39
+ SP823: 'SP 823: Integrated Services Digital Network Series'
40
+ SP960: 'SP 960: NIST Recommended Practice Guides'
41
+ SP1200: 'SP 1200: Protocols'
42
+ SP1500: 'SP 1500: Working Group Papers'
43
+ SP1800: 'SP 1800: NIST Cybersecurity Practice Guides'
44
+ SP1900: 'SP 1900: Cyber-Physical Systems'
45
+ SP2000: 'SP 2000: Standards Coordination'
46
+ SP2100: 'SP 2100: Conference Proceedings'
47
+ TIBM: Technical Information on Building Materials
48
+ TN: Technical Notes
49
+ TTB: Technology Transfer Brief
@@ -1,3 +1,3 @@
1
1
  module RelatonNist
2
- VERSION = "1.11.0".freeze
2
+ VERSION = "1.11.3".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-nist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-10 00:00:00.000000000 Z
11
+ date: 2022-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -185,6 +185,7 @@ files:
185
185
  - lib/relaton_nist/nist_bibliography.rb
186
186
  - lib/relaton_nist/processor.rb
187
187
  - lib/relaton_nist/scrapper.rb
188
+ - lib/relaton_nist/series.yaml
188
189
  - lib/relaton_nist/version.rb
189
190
  - lib/relaton_nist/xml_parser.rb
190
191
  - relaton_nist.gemspec