relaton-nist 0.5.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +9 -4
- data/.github/workflows/ubuntu.yml +9 -4
- data/.github/workflows/windows.yml +9 -4
- data/lib/relaton_nist/hash_converter.rb +0 -5
- data/lib/relaton_nist/hit.rb +6 -8
- data/lib/relaton_nist/hit_collection.rb +5 -11
- data/lib/relaton_nist/nist_bibliographic_item.rb +3 -3
- data/lib/relaton_nist/nist_bibliography.rb +0 -1
- data/lib/relaton_nist/scrapper.rb +2 -2
- data/lib/relaton_nist/version.rb +1 -1
- data/lib/relaton_nist/xml_parser.rb +6 -8
- data/relaton_nist.gemspec +1 -2
- metadata +4 -19
- data/lib/relaton_nist/keyword.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 805836254764292ed3a420817f46d40e53514dcea92ce8f806aa2b0723332da8
|
4
|
+
data.tar.gz: 31d8735c928d99d28ea3c09802beb22553848d74fd111c616d8b530eff695629
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9395ced7ec09e9fdb1d7d4474af0f10bde4da961f0152ff5321403a04358062698363a3ecdf3b16e2986cc25ab99a0df1f047c0277a6d33d40f1fda9edd8a98a
|
7
|
+
data.tar.gz: 16fbec11a1da3c7deb5bd87428456c43d9ed77001b3a52aa376315c58898181c7fbcc10acfedac46e1651790e17ac64c66aca0e9c454715185e747a0ebf21a5d
|
data/.github/workflows/macos.yml
CHANGED
@@ -1,14 +1,19 @@
|
|
1
|
-
# Auto-generated
|
2
|
-
#
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
3
|
name: macos
|
4
4
|
|
5
|
-
on:
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master ]
|
8
|
+
pull_request:
|
9
|
+
branches: [ '**' ]
|
6
10
|
|
7
11
|
jobs:
|
8
12
|
test-macos:
|
9
13
|
name: Test on Ruby ${{ matrix.ruby }} macOS
|
10
14
|
runs-on: macos-latest
|
11
15
|
strategy:
|
16
|
+
fail-fast: false
|
12
17
|
matrix:
|
13
18
|
ruby: [ '2.6', '2.5', '2.4' ]
|
14
19
|
steps:
|
@@ -20,7 +25,7 @@ jobs:
|
|
20
25
|
architecture: 'x64'
|
21
26
|
- name: Update gems
|
22
27
|
run: |
|
23
|
-
sudo gem install bundler
|
28
|
+
sudo gem install bundler --force
|
24
29
|
bundle install --jobs 4 --retry 3
|
25
30
|
- name: Run specs
|
26
31
|
run: |
|
@@ -1,14 +1,19 @@
|
|
1
|
-
# Auto-generated
|
2
|
-
#
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
3
|
name: ubuntu
|
4
4
|
|
5
|
-
on:
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master ]
|
8
|
+
pull_request:
|
9
|
+
branches: [ '**' ]
|
6
10
|
|
7
11
|
jobs:
|
8
12
|
test-linux:
|
9
13
|
name: Test on Ruby ${{ matrix.ruby }} Ubuntu
|
10
14
|
runs-on: ubuntu-latest
|
11
15
|
strategy:
|
16
|
+
fail-fast: false
|
12
17
|
matrix:
|
13
18
|
ruby: [ '2.6', '2.5', '2.4' ]
|
14
19
|
steps:
|
@@ -20,7 +25,7 @@ jobs:
|
|
20
25
|
architecture: 'x64'
|
21
26
|
- name: Update gems
|
22
27
|
run: |
|
23
|
-
gem install bundler
|
28
|
+
gem install bundler
|
24
29
|
bundle install --jobs 4 --retry 3
|
25
30
|
- name: Run specs
|
26
31
|
run: |
|
@@ -1,14 +1,19 @@
|
|
1
|
-
# Auto-generated
|
2
|
-
#
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
3
|
name: windows
|
4
4
|
|
5
|
-
on:
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master ]
|
8
|
+
pull_request:
|
9
|
+
branches: [ '**' ]
|
6
10
|
|
7
11
|
jobs:
|
8
12
|
test-windows:
|
9
13
|
name: Test on Ruby ${{ matrix.ruby }} Windows
|
10
14
|
runs-on: windows-latest
|
11
15
|
strategy:
|
16
|
+
fail-fast: false
|
12
17
|
matrix:
|
13
18
|
ruby: [ '2.6', '2.5', '2.4' ]
|
14
19
|
steps:
|
@@ -21,7 +26,7 @@ jobs:
|
|
21
26
|
- name: Update gems
|
22
27
|
shell: pwsh
|
23
28
|
run: |
|
24
|
-
gem install bundler
|
29
|
+
gem install bundler
|
25
30
|
bundle config --local path vendor/bundle
|
26
31
|
bundle update
|
27
32
|
bundle install --jobs 4 --retry 3
|
@@ -9,17 +9,12 @@ module RelatonNist
|
|
9
9
|
ret = super
|
10
10
|
return if ret.nil?
|
11
11
|
|
12
|
-
keyword_hash_to_bib(ret)
|
13
12
|
commentperiod_hash_to_bib(ret)
|
14
13
|
ret
|
15
14
|
end
|
16
15
|
|
17
16
|
private
|
18
17
|
|
19
|
-
def keyword_hash_to_bib(ret)
|
20
|
-
ret[:keyword]&.map! { |kw| Keyword.new kw }
|
21
|
-
end
|
22
|
-
|
23
18
|
def commentperiod_hash_to_bib(ret)
|
24
19
|
return unless ret[:commentperiod]
|
25
20
|
|
data/lib/relaton_nist/hit.rb
CHANGED
@@ -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
|
@@ -16,17 +13,18 @@ module RelatonNist
|
|
16
13
|
def sort_value
|
17
14
|
@sort_value ||= begin
|
18
15
|
sort_phrase = [hit[:serie], hit[:code], hit[:title]].join " "
|
19
|
-
corr = hit_collection
|
16
|
+
corr = hit_collection&.text&.split&.map do |w|
|
20
17
|
if w =~ /\w+/ &&
|
21
18
|
sort_phrase =~ Regexp.new(Regexp.escape(w), Regexp::IGNORECASE)
|
22
19
|
1
|
23
20
|
else 0
|
24
21
|
end
|
25
|
-
end.
|
22
|
+
end&.sum.to_i
|
26
23
|
corr + case hit[:status]
|
27
|
-
when "final" then
|
28
|
-
when "withdrawn" then
|
29
|
-
when "draft
|
24
|
+
when "final" then 4
|
25
|
+
when "withdrawn" then 3
|
26
|
+
when "draft" then 2
|
27
|
+
when "draft (obsolete)" then 1
|
30
28
|
else 0
|
31
29
|
end
|
32
30
|
end
|
@@ -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
|
-
|
24
|
-
@year = year
|
21
|
+
super ref_nbr, year
|
25
22
|
|
26
23
|
/(?<docid>(SP|FIPS)\s[0-9-]+)/ =~ text
|
27
|
-
|
24
|
+
@array = docid ? from_json(docid, **opts) : from_csrc(**opts)
|
28
25
|
|
29
|
-
|
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
|
|
@@ -66,12 +60,12 @@ module RelatonNist
|
|
66
60
|
serie = h.at("td[1]").text.strip
|
67
61
|
code = h.at("td[2]").text.strip
|
68
62
|
title = link.text
|
69
|
-
|
63
|
+
doc_url = DOMAIN + link[:href]
|
70
64
|
status = h.at("td[4]").text.strip.downcase
|
71
65
|
release_date = Date.strptime h.at("td[5]").text.strip, "%m/%d/%Y"
|
72
66
|
Hit.new(
|
73
67
|
{
|
74
|
-
code: code, serie: serie, title: title, url:
|
68
|
+
code: code, serie: serie, title: title, url: doc_url, status: status,
|
75
69
|
release_date: release_date
|
76
70
|
}, self
|
77
71
|
)
|
@@ -4,7 +4,7 @@ module RelatonNist
|
|
4
4
|
attr_reader :doctype
|
5
5
|
|
6
6
|
# @return [Array<RelatonNist::Keyword>]
|
7
|
-
attr_reader :keyword
|
7
|
+
# attr_reader :keyword
|
8
8
|
|
9
9
|
# @return [RelatonNist::CommentPeriod, NilClass]
|
10
10
|
attr_reader :commentperiod
|
@@ -57,7 +57,7 @@ module RelatonNist
|
|
57
57
|
# @option relation [Array<RelatonBib::BibItemLocality>] :bib_locality
|
58
58
|
def initialize(**args)
|
59
59
|
@doctype = args.delete(:doctype) || "standard"
|
60
|
-
@keyword = args.delete(:keyword) || []
|
60
|
+
# @keyword = args.delete(:keyword) || []
|
61
61
|
@commentperiod = args.delete :commentperiod
|
62
62
|
super
|
63
63
|
end
|
@@ -78,7 +78,7 @@ module RelatonNist
|
|
78
78
|
# @return [Hash]
|
79
79
|
def to_hash
|
80
80
|
hash = super
|
81
|
-
hash["keyword"] = single_element_array(keyword) if keyword&.any?
|
81
|
+
# hash["keyword"] = single_element_array(keyword) if keyword&.any?
|
82
82
|
hash["commentperiod"] = commentperiod.to_hash if commentperiod
|
83
83
|
hash
|
84
84
|
end
|
@@ -3,7 +3,6 @@ require "relaton_nist/nist_bibliographic_item"
|
|
3
3
|
require "relaton_nist/scrapper"
|
4
4
|
require "relaton_nist/hit_collection"
|
5
5
|
require "relaton_nist/xml_parser"
|
6
|
-
require "relaton_nist/keyword"
|
7
6
|
require "relaton_nist/comment_period"
|
8
7
|
require "relaton_nist/document_status"
|
9
8
|
require "relaton_nist/hash_converter"
|
@@ -134,7 +134,7 @@ module RelatonNist
|
|
134
134
|
iter = doc["iteration"] == "initial" ? 1 : doc["iteration"]
|
135
135
|
else
|
136
136
|
case status
|
137
|
-
when "draft (
|
137
|
+
when "draft (obsolete)"
|
138
138
|
stage = "draft-public"
|
139
139
|
subst = "withdrawn"
|
140
140
|
when "retired draft"
|
@@ -445,7 +445,7 @@ module RelatonNist
|
|
445
445
|
else
|
446
446
|
doc.xpath "//span[@id='pub-keywords-container']/span"
|
447
447
|
end
|
448
|
-
kws.map { |kw|
|
448
|
+
kws.map { |kw| kw.is_a?(String) ? kw : kw.text }
|
449
449
|
end
|
450
450
|
|
451
451
|
# @param doc [Nokogiri::HTML::Document]
|
data/lib/relaton_nist/version.rb
CHANGED
@@ -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
|
-
|
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
|
@@ -14,7 +19,6 @@ module RelatonNist
|
|
14
19
|
ext = nistitem.at "./ext"
|
15
20
|
return data unless ext
|
16
21
|
|
17
|
-
data[:keyword] = fetch_keyword(ext)
|
18
22
|
data[:commentperiod] = fetch_commentperiod(ext)
|
19
23
|
data
|
20
24
|
end
|
@@ -39,12 +43,6 @@ module RelatonNist
|
|
39
43
|
extended: cp.at("extended")&.text
|
40
44
|
)
|
41
45
|
end
|
42
|
-
|
43
|
-
def fetch_keyword(item)
|
44
|
-
item.xpath("./keyword").map do |kw|
|
45
|
-
Keyword.new kw.children.first.to_xml
|
46
|
-
end
|
47
|
-
end
|
48
46
|
end
|
49
47
|
end
|
50
48
|
end
|
data/relaton_nist.gemspec
CHANGED
@@ -23,7 +23,6 @@ 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"
|
@@ -35,6 +34,6 @@ Gem::Specification.new do |spec|
|
|
35
34
|
spec.add_development_dependency "webmock"
|
36
35
|
spec.add_development_dependency "ruby-jing"
|
37
36
|
|
38
|
-
spec.add_dependency "relaton-bib", "~> 0.
|
37
|
+
spec.add_dependency "relaton-bib", "~> 0.8.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.
|
4
|
+
version: 0.8.2
|
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-
|
11
|
+
date: 2020-03-24 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
|
@@ -170,14 +156,14 @@ dependencies:
|
|
170
156
|
requirements:
|
171
157
|
- - "~>"
|
172
158
|
- !ruby/object:Gem::Version
|
173
|
-
version: 0.
|
159
|
+
version: 0.8.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.
|
166
|
+
version: 0.8.0
|
181
167
|
- !ruby/object:Gem::Dependency
|
182
168
|
name: rubyzip
|
183
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -223,7 +209,6 @@ files:
|
|
223
209
|
- lib/relaton_nist/hash_converter.rb
|
224
210
|
- lib/relaton_nist/hit.rb
|
225
211
|
- lib/relaton_nist/hit_collection.rb
|
226
|
-
- lib/relaton_nist/keyword.rb
|
227
212
|
- lib/relaton_nist/nist_bibliographic_item.rb
|
228
213
|
- lib/relaton_nist/nist_bibliography.rb
|
229
214
|
- lib/relaton_nist/processor.rb
|
data/lib/relaton_nist/keyword.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module RelatonNist
|
2
|
-
class Keyword
|
3
|
-
include RelatonBib
|
4
|
-
|
5
|
-
# @return [Nokogiri::XML::DocumentFragment]
|
6
|
-
attr_reader :element
|
7
|
-
|
8
|
-
# @param element [String]
|
9
|
-
def initialize(element)
|
10
|
-
@element = Nokogiri::XML.fragment element
|
11
|
-
end
|
12
|
-
|
13
|
-
# @param builder [Nokogiri::XML::Builder]
|
14
|
-
def to_xml(builder)
|
15
|
-
builder.keyword element.to_xml
|
16
|
-
end
|
17
|
-
|
18
|
-
# @return [String]
|
19
|
-
def to_hash
|
20
|
-
element.text
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|