relaton-nist 1.14.7 → 1.14.9

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: af449d7420c8250ae7df9a33a292ac5278150c9159c05252650707746284feaa
4
- data.tar.gz: f01fceceb91e3e91e0cb6b532fa2b63fdecfb88d18ddc9879f98b10733637232
3
+ metadata.gz: d70d5c4814d320a0e7de37ffa6c87f70303132fc93a667e1ea7397cda9e3b2cd
4
+ data.tar.gz: 4ac72228dfae2aeff749b90765235c374385647e16746d6efafc43ce3a86a0d6
5
5
  SHA512:
6
- metadata.gz: 158958c46a83455aa5a14ec3f9c1f84a6bd70870fb2f1e85dc37d2200d8a3b3a0a4bf824f924ac775f54d1204656f0f40c078f6b71a737efd33d46f93fc681c3
7
- data.tar.gz: c999b71e25e1aef1f5d3a066db3f0720149c23a2cca13a75fa453201a06aabc7cf21a4b313b21f8e98dbeece8803c8f65ba0a3d79e0d8c942244d07fe656341d
6
+ metadata.gz: 2128557619cae8f53fd3d80839303597d77e85065a58618a49302dd8593982ba374a7b73ab87fbe6c27661af923857f2382688990ff64acf27d2dd4607a8e0b5
7
+ data.tar.gz: 8a909befb6b35b64b9f48cbcbcbef0a9ef42f336709a9a628844bf29ac94266ba466067ea3636c57e92e8c5e789b9b65cbc7317941697e288ae65a7a619da55f
@@ -7,7 +7,8 @@ on:
7
7
  inputs:
8
8
  next_version:
9
9
  description: |
10
- Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
10
+ Next release version. Possible values: x.y.z, major, minor, patch (or pre|rc|etc).
11
+ Also, you can pass 'skip' to skip 'git tag' and do 'gem push' for the current version
11
12
  required: true
12
13
  default: 'skip'
13
14
  repository_dispatch:
@@ -56,13 +56,13 @@ module RelatonNist
56
56
  def search_filter # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
57
57
  @array.select do |item|
58
58
  parts = doi_parts(item.hit[:json]) || code_parts(item.hit[:code])
59
- (refparts[:code] && [parts[:series], item.hit[:series]].include?(refparts[:series]) &&
59
+ refparts[:code] && [parts[:series], item.hit[:series]].include?(refparts[:series]) &&
60
60
  refparts[:code].casecmp(parts[:code].upcase).zero? &&
61
- (refparts[:prt] == parts[:prt]) &&
61
+ refparts[:prt] == parts[:prt] &&
62
62
  (refparts[:vol].nil? || refparts[:vol] == parts[:vol]) &&
63
63
  (refparts[:ver].nil? || refparts[:ver] == parts[:ver]) &&
64
64
  (refparts[:rev].nil? || refparts[:rev] == parts[:rev]) &&
65
- refparts[:draft] == parts[:draft] && refparts[:add] == parts[:add])
65
+ refparts[:draft] == parts[:draft] && refparts[:add] == parts[:add]
66
66
  end
67
67
  end
68
68
 
@@ -71,8 +71,8 @@ module RelatonNist
71
71
  def code_parts(code) # rubocop:disable Metrics/MethodLength
72
72
  {
73
73
  # prefix: match(/^(?:NIST|NBS)\s?/, code),
74
- series: match(/(?<val>(?:SP|FIPS|IR|ITL\sBulletin|White\sPaper))\s/, code),
75
- code: match(/(?<val>[0-9-]{3,}[A-Z]?)/, code),
74
+ series: match(/(?<val>(?:SP|FIPS|CSWP|IR|ITL\sBulletin|White\sPaper))\s/, code),
75
+ code: match(/(?<val>[0-9-]+(?:(?!(?:ver|r|v|pt)\d|-add\d?)[A-Za-z-])*)/, code),
76
76
  prt: match(/(?:pt|\sPart\s)(?<val>\d+)/, code),
77
77
  vol: match(/(?:v|\sVol\.\s)(?<val>\d+)/, code),
78
78
  ver: match(/(?:ver|\sVer\.\s|Version\s)(?<val>[\d.]+)/, code),
@@ -81,7 +81,7 @@ module RelatonNist
81
81
  # (?:\s(?<vol2>Vol\.\s\d+))?
82
82
  # (?:\s(?<ver2>(?:Ver\.|Version)\s[\d.]+))?
83
83
  # (?:\s(?<rev2>Rev\.\s\d+))?
84
- add: match(/\sAdd(?:endum)?(?<val>\d*)/, code),
84
+ add: match(/(?:-add|\sAdd)(?:endum)?(?<val>\d*)/, code),
85
85
  draft: !match(/\((?:Retired\s)?Draft\)/, code).nil?,
86
86
  }
87
87
  end
@@ -92,14 +92,14 @@ module RelatonNist
92
92
  id = json["doi"].split("/").last
93
93
  {
94
94
  # prefix: match(/^(?:NIST|NBS)\./, id),
95
- series: match(/(?:SP|FIPS|IR|ITL\sBulletin|White\sPaper)(?=\.)/, id),
96
- code: match(/(?<=\.)\d{3,}(?:-\d+)*(?:[[:alpha:]](?!\d|raft|er|t?\d))?/, id),
95
+ series: match(/(?:SP|FIPS|CSWP|IR|ITL\sBulletin|White\sPaper)(?=\.)/, id),
96
+ code: match(/(?<=\.)\d+(?:-\d+)*(?:[[:alpha:]](?!\d|raft|er|t?\d))?/, id),
97
97
  prt: match(/pt?(?<val>\d+)/, id),
98
98
  vol: match(/v(?<val>\d+)(?!\.\d)/, id),
99
99
  ver: match(/v(?:er)?(?<val>[\d.]+)/, id),
100
100
  rev: match(/r(?<val>\d+)/, id),
101
101
  add: match(/-Add(?<val>\d*)/, id),
102
- draft: !match(/-draft/, id).nil?,
102
+ draft: !match(/\.ipd/, id).nil?,
103
103
  }
104
104
  end
105
105
 
@@ -110,9 +110,9 @@ module RelatonNist
110
110
  #
111
111
  def refparts # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
112
112
  @refparts ||= {
113
- perfix: match(/^(NIST|NBS)\s?/, text),
114
- series: match(/(SP|FIPS|IR|ITL\sBulletin|White\sPaper)(?=\.|\s)/, text),
115
- code: match(/(?<=\.|\s)[0-9-]{3,}[A-Z]?/, text),
113
+ perfix: match(/^(NIST|NBS)/, text),
114
+ series: match(/(SP|FIPS|CSWP|IR|ITL\sBulletin|White\sPaper)(?=\.|\s)/, text),
115
+ code: match(/(?<=\.|\s)[0-9-]+(?:(?!(ver|r|v|pt)\d|-add\d?)[A-Za-z-])*/, text),
116
116
  prt: match(/(?:(?<dl>\.)?pt(?(<dl>)-)|\sPart\s)(?<val>[A-Z\d]+)/, text),
117
117
  vol: match(/(?:(?<dl>\.)?v(?(<dl>)-)|\sVol\.\s)(?<val>\d+)/, text),
118
118
  ver: match(/(?:(?<dl>\.)?\s?ver|\sVer\.\s)(?<val>\d(?(<dl>)[-\d]|[.\d])*)/, text)&.gsub(/-/, "."),
@@ -149,10 +149,11 @@ module RelatonNist
149
149
  #
150
150
  def full_ref # rubocop:disable Metrics/AbcSize
151
151
  @full_ref ||= begin
152
- ref = "#{refparts[:perfix]}#{refparts[:series]} #{refparts[:code]}"
153
- ref += "pt#{refparts[:prt]}" if refparts[:prt] # long_to_short(refparts, "prt").to_s
154
- ref += "ver#{refparts[:ver]}" if refparts[:ver] # long_to_short(refparts, "vol").to_s
152
+ ref = [refparts[:perfix], refparts[:series], refparts[:code]].compact.join " "
153
+ ref += "pt#{refparts[:prt]}" if refparts[:prt]
154
+ ref += "ver#{refparts[:ver]}" if refparts[:ver]
155
155
  ref += "v#{refparts[:vol]}" if refparts[:vol]
156
+ ref += "r#{refparts[:rev]}" if refparts[:rev]
156
157
  ref
157
158
  end
158
159
  end
@@ -183,17 +184,20 @@ module RelatonNist
183
184
  ref = full_ref
184
185
  # fn = ref.gsub(%r{[/\s:.]}, "_").upcase
185
186
  index = Relaton::Index.find_or_create :nist, url: "#{GHNISTDATA}index-v1.zip", file: INDEX_FILE
186
- row = index.search { |r| r[:id] == ref }.min_by { |r| r[:id] }
187
- return [] unless row
187
+ rows = index.search(ref).sort_by { |r| r[:id] }
188
+ # return [] unless row
188
189
 
189
- yaml = OpenURI.open_uri "#{GHNISTDATA}#{row[:file]}"
190
- hash = YAML.safe_load yaml
191
- hash["fetched"] = Date.today.to_s
192
- bib = RelatonNist::NistBibliographicItem.from_hash hash
193
- id = bib.docidentifier.find(&:primary).id
194
- hit = Hit.new({ code: id }, self)
195
- hit.fetch = bib
196
- [hit]
190
+ # yaml = OpenURI.open_uri "#{GHNISTDATA}#{row[:file]}"
191
+ # hash = YAML.safe_load yaml
192
+ # hash["fetched"] = Date.today.to_s
193
+ # bib = RelatonNist::NistBibliographicItem.from_hash hash
194
+ # id = bib.docidentifier.find(&:primary).id
195
+
196
+ rows.map do |row|
197
+ Hit.new({ code: row[:id], path: row[:file] }, self)
198
+ end
199
+ # hit.fetch = bib
200
+ # [hit]
197
201
  rescue OpenURI::HTTPError => e
198
202
  return [] if e.io.status[0] == "404"
199
203
 
@@ -221,7 +225,7 @@ module RelatonNist
221
225
  return json["docidentifier"] unless parts
222
226
 
223
227
  id = parts[:code]
224
- id = "#{parts[:series]} #{id}" if parts[:series]
228
+ id = "NIST #{parts[:series]} #{id}" if parts[:series]
225
229
  id += " Part #{parts[:prt]}" if parts[:prt]
226
230
  id += " Vol. #{parts[:vol]}" if parts[:vol]
227
231
  id += " Ver. #{parts[:ver]}" if parts[:ver]
@@ -263,8 +267,9 @@ module RelatonNist
263
267
  def match_year?(doc, date)
264
268
  return true unless year
265
269
 
266
- idate = RelatonBib.parse_date doc["issued-date"], false
267
- idate.between? date, date.next_year.prev_day
270
+ d = doc["issued-date"] || doc["published-date"]
271
+ pidate = RelatonBib.parse_date d, false
272
+ pidate.between? date, date.next_year.prev_day
268
273
  end
269
274
  end
270
275
  end
@@ -47,9 +47,9 @@ module RelatonNist
47
47
  if date2
48
48
  case date2
49
49
  when /\w+\s\d{4}/
50
- opts[:issued_date] = Date.strptime date2, "%B %Y"
50
+ opts[:date] = Date.strptime date2, "%B %Y"
51
51
  when /\w+\s\d{2},\s\d{4}/
52
- opts[:updated_date] = Date.strptime date2, "%B %d, %Y"
52
+ opts[:date] = Date.strptime date2, "%B %d, %Y"
53
53
  end
54
54
  end
55
55
  opts[:stage] = stage if stage
@@ -117,16 +117,9 @@ module RelatonNist
117
117
  end
118
118
  result.each_slice(3) do |s| # ISO website only allows 3 connections
119
119
  fetch_pages(s, 3).each_with_index do |r, _i|
120
- if opts[:issued_date]
121
- ids = r.date.select do |d|
122
- d.type == "issued" && d.on(:date) == opts[:issued_date]
123
- end
124
- next if ids.empty?
125
- elsif opts[:updated_date]
126
- pds = r.date.select do |d|
127
- d.type == "published" && d.on(:date) == opts[:updated_date]
128
- end
129
- next if pds.empty?
120
+ if opts[:date]
121
+ dates = r.date.select { |d| d.on(:date) == opts[:date] }
122
+ next if dates.empty?
130
123
  end
131
124
  next if iter && r.status.iteration != iteration
132
125
  return { ret: r } if !year
@@ -11,13 +11,24 @@ module RelatonNist
11
11
  # @param hit_data [Hash]
12
12
  # @return [Hash]
13
13
  def parse_page(hit_data)
14
+ hit_data[:path] ? fetch_gh(hit_data) : parse_json(hit_data)
15
+ end
16
+
17
+ def fetch_gh(hit_data)
18
+ yaml = OpenURI.open_uri "#{HitCollection::GHNISTDATA}#{hit_data[:path]}"
19
+ hash = YAML.safe_load yaml
20
+ hash["fetched"] = Date.today.to_s
21
+ NistBibliographicItem.from_hash hash
22
+ end
23
+
24
+ def parse_json(hit_data)
14
25
  item_data = from_json hit_data
15
26
  titles = fetch_titles(hit_data)
16
- unless /^(SP|NISTIR|FIPS) /.match? item_data[:docid][0].id
17
- item_data[:docid][0] = RelatonBib::DocumentIdentifier.new(
18
- id: titles[0][:content].upcase, type: "NIST", primary: true,
19
- )
20
- end
27
+ # unless /^(SP|NISTIR|FIPS) /.match? item_data[:docid][0].id
28
+ # item_data[:docid][0] = RelatonBib::DocumentIdentifier.new(
29
+ # id: titles[0][:content].upcase, type: "NIST", primary: true,
30
+ # )
31
+ # end
21
32
  item_data[:fetched] = Date.today.to_s
22
33
  item_data[:type] = "standard"
23
34
  item_data[:title] = titles
@@ -1,3 +1,3 @@
1
1
  module RelatonNist
2
- VERSION = "1.14.7".freeze
2
+ VERSION = "1.14.9".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.14.7
4
+ version: 1.14.9
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-07-14 00:00:00.000000000 Z
11
+ date: 2023-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: relaton-bib