relaton-nist 1.3.0 → 1.3.1

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: dac2975c8efc8f3fb1fe8720fb852daba9bd66fb0e7bfc5fd87e24b69ed08ff1
4
- data.tar.gz: 84503272191f86d904c947bbe6143c4363bc5fe03d0bb4f40b56162ef45f6c7d
3
+ metadata.gz: a7a5a66a0bf3122bb2ecc3146f30ee12ca9a746ed7c96747fef6949925392769
4
+ data.tar.gz: e56387b519fe1efd6c1874c2a42d4e4555080c73f982049bc8b2366c82540422
5
5
  SHA512:
6
- metadata.gz: b82763b595daf55b2d09643804f5caf2351e11f8de4f1e61b0c8f98273770da35aaa4161209ad21a137e04dbfc35fa6cc8ff14f9f15ad2e7c450e2e8bcb7e9a2
7
- data.tar.gz: 23f6829e141eb6b2f3f90f23de5b6f8b731b8659060ca7459599727ff5652368f8f8970a1234b0c551ffd40321b1a99e4a9e212b84669c803e4483f0eba079ad
6
+ metadata.gz: da82fcc539ca6c7ade8214e01966f81018e57dd89496669fbee744cb133d2b0db6d2da369cee4ca05ac4161189c1f114897dd332368c9a634b72a5641e5cce52
7
+ data.tar.gz: 882fdf875645a91716aab1b275eb18d257d245d71f5bdea7615d78495b3cfa9696a4f0a5b96bf11e0770de52eec1849b21d02118c104dd86d4397df871fd2365
@@ -17,10 +17,10 @@ module RelatonNist
17
17
  # @param year [String]
18
18
  # @param opts [Hash]
19
19
  # @option opts [String] :stage
20
- def initialize(ref_nbr, year = nil, opts = {})
20
+ def initialize(ref_nbr, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize
21
21
  super ref_nbr, year
22
22
 
23
- /(?<docid>(SP|FIPS)\s[0-9-]+)/ =~ text
23
+ /(?<docid>(SP|FIPS)\s[0-9-]+\w?)/ =~ text
24
24
  @array = docid ? from_json(docid, **opts) : from_csrc(**opts)
25
25
 
26
26
  @array.sort! do |a, b|
@@ -45,28 +45,28 @@ module RelatonNist
45
45
  from = d.strftime "%m/%d/%Y"
46
46
  to = d.next_year.prev_day.strftime "%m/%d/%Y"
47
47
  end
48
- url = "#{DOMAIN}/publications/search?keywords-lg=#{text}"
48
+ url = "#{DOMAIN}/publications/search?keywords-lg=#{text}"
49
49
  url += "&dateFrom-lg=#{from}" if from
50
50
  url += "&dateTo-lg=#{to}" if to
51
- url += if /PD/ =~ opts[:stage]
51
+ url += if /PD/.match? opts[:stage]
52
52
  "&status-lg=Draft,Retired Draft,Withdrawn"
53
53
  else
54
54
  "&status-lg=Final,Withdrawn"
55
55
  end
56
56
 
57
- doc = Nokogiri::HTML OpenURI.open_uri(::Addressable::URI.parse(url).normalize)
57
+ doc = Nokogiri::HTML OpenURI.open_uri(::Addressable::URI.parse(url).normalize)
58
58
  doc.css("table.publications-table > tbody > tr").map do |h|
59
59
  link = h.at("td/div/strong/a")
60
60
  serie = h.at("td[1]").text.strip
61
61
  code = h.at("td[2]").text.strip
62
62
  title = link.text
63
- doc_url = DOMAIN + link[:href]
63
+ doc_url = DOMAIN + link[:href]
64
64
  status = h.at("td[4]").text.strip.downcase
65
65
  release_date = Date.strptime h.at("td[5]").text.strip, "%m/%d/%Y"
66
66
  Hit.new(
67
67
  {
68
- code: code, serie: serie, title: title, url: doc_url, status: status,
69
- release_date: release_date
68
+ code: code, serie: serie, title: title, url: doc_url,
69
+ status: status, release_date: release_date
70
70
  }, self
71
71
  )
72
72
  end
@@ -91,17 +91,18 @@ module RelatonNist
91
91
  # @param docid [String]
92
92
  # @param stage [String]
93
93
  # @return [Array<Hach>]
94
- def select_data(docid, **opts)
94
+ def select_data(docid, **opts) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength,Metrics/PerceivedComplexity
95
95
  d = Date.strptime year, "%Y" if year
96
+ didrx = Regexp.new(docid)
96
97
  data.select do |doc|
97
98
  next unless match_year?(doc, d)
98
99
 
99
- if /PD/ =~ opts[:stage]
100
+ if /PD/.match? opts[:stage]
100
101
  next unless %w[draft-public draft-prelim].include? doc["status"]
101
102
  else
102
103
  next unless doc["status"] == "final"
103
104
  end
104
- doc["docidentifier"] =~ Regexp.new(docid)
105
+ doc["docidentifier"] =~ didrx
105
106
  end
106
107
  end
107
108
 
@@ -129,7 +130,9 @@ module RelatonNist
129
130
  #
130
131
  # @prarm ctime [Time, NilClass]
131
132
  def fetch_data(ctime)
132
- resp = OpenURI.open_uri("https://csrc.nist.gov/CSRC/media/feeds/metanorma/pubs-export.meta")
133
+ resp = OpenURI.open_uri(
134
+ "https://csrc.nist.gov/CSRC/media/feeds/metanorma/pubs-export.meta"
135
+ )
133
136
  if !ctime || ctime < resp.last_modified
134
137
  @data = nil
135
138
  zip = OpenURI.open_uri "https://csrc.nist.gov/CSRC/media/feeds/metanorma/pubs-export.zip"
@@ -121,7 +121,7 @@ module RelatonNist
121
121
  end
122
122
 
123
123
  def nistbib_search_filter(code, year, opts)
124
- idregex = %r{[0-9-]{3,}}
124
+ idregex = %r{[0-9-]{3,}\w?}
125
125
  docid = code.match(idregex).to_s
126
126
  serie = code.match(%r{(FISP|SP|NISTIR)(?=\s)})
127
127
  warn "[relaton-nist] (\"#{code}\") fetching..."
@@ -1,3 +1,3 @@
1
1
  module RelatonNist
2
- VERSION = "1.3.0".freeze
2
+ VERSION = "1.3.1".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.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-20 00:00:00.000000000 Z
11
+ date: 2020-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debase
@@ -220,7 +220,7 @@ homepage: https://github.com/metanorma/relaton-nist
220
220
  licenses:
221
221
  - MIT
222
222
  metadata: {}
223
- post_install_message:
223
+ post_install_message:
224
224
  rdoc_options: []
225
225
  require_paths:
226
226
  - lib
@@ -236,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
236
  version: '0'
237
237
  requirements: []
238
238
  rubygems_version: 3.0.6
239
- signing_key:
239
+ signing_key:
240
240
  specification_version: 4
241
241
  summary: 'RelatonNist: retrive NIST standards.'
242
242
  test_files: []