relaton-nist 0.3.8 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,7 +27,7 @@ module RelatonNist
27
27
  item_data[:fetched] = Date.today.to_s
28
28
  item_data[:type] = "standard"
29
29
  item_data[:title] = titles
30
- item_data[:doctype] = doctype
30
+ item_data[:doctype] = "standard" # doctype
31
31
 
32
32
  NistBibliographicItem.new(**item_data)
33
33
  end
@@ -47,6 +47,7 @@ module RelatonNist
47
47
  docstatus: fetch_status(json, hit_data[:status]),
48
48
  copyright: fetch_copyright(json["published-date"]),
49
49
  relation: fetch_relations_json(json),
50
+ place: ["Gaithersburg, MD"],
50
51
  keyword: fetch_keywords(json),
51
52
  commentperiod: fetch_commentperiod_json(json),
52
53
  }
@@ -86,7 +87,12 @@ module RelatonNist
86
87
  # @return [Array<Nokogiri::HTML::Document, String>]
87
88
  def get_page(url)
88
89
  uri = URI url
89
- resp = Net::HTTP.get_response(uri) # .encode("UTF-8")
90
+ resp = Net::HTTP.get_response(uri)
91
+ %r{(?<=newLocation = 'https://' \+ window.location.hostname \+ ')(?<path>[^']+)} =~ resp.body
92
+ if path
93
+ uri = URI HitCollection::DOMAIN + path
94
+ resp = Net::HTTP.get_response(uri)
95
+ end
90
96
  Nokogiri::HTML(resp.body)
91
97
  rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
92
98
  Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
@@ -103,7 +109,7 @@ module RelatonNist
103
109
  else
104
110
  doc.at(
105
111
  "//div[contains(@class, 'publications-detail')]/h3",
106
- )&.text&.strip
112
+ )&.text&.strip.sub(/(?<=\w)\([^\)]+\)$/) { |m| " " + m.upcase}.squeeze " "
107
113
  end
108
114
  item_ref ||= "?"
109
115
  [RelatonBib::DocumentIdentifier.new(id: item_ref, type: "NIST")]
@@ -137,7 +143,7 @@ module RelatonNist
137
143
  when "withdrawn"
138
144
  stage = "final"
139
145
  subst = "withdrawn"
140
- when "draft"
146
+ when /^draft/
141
147
  stage = "draft-public"
142
148
  subst = "active"
143
149
  else
@@ -351,9 +357,9 @@ module RelatonNist
351
357
  links << { type: "uri", content: doc["uri"] } if doc["uri"]
352
358
  doi = "https://doi.org/" + doc["doi"] if doc["doi"]
353
359
  else
354
- pub = doc.at "//p/strong[.='Publication:']"
355
- pdf = pub.at "./following-sibling::a[.=' Local Download']"
356
- doi = pub.at("./following-sibling::a[contains(.,'(DOI)')]")&.attr :href
360
+ pub = doc.at "//p/strong[contains(., 'Publication:')]"
361
+ pdf = pub&.at "./following-sibling::a[.=' Local Download']"
362
+ doi = pub&.at("./following-sibling::a[contains(.,'(DOI)')]")&.attr :href
357
363
  links << { type: "pdf", content: pdf[:href] } if pdf
358
364
  end
359
365
  links << { type: "doi", content: doi } if doi
@@ -416,10 +422,12 @@ module RelatonNist
416
422
  else idx + 1
417
423
  end
418
424
 
419
- content = s.text.match(/^[^\(]+/).to_s.strip.gsub " ", " "
425
+ content = s.text.match(/^[^\(]+/).to_s.strip.squeeze " "
420
426
 
421
- ref = case content.match(/\w+/).to_s
422
- when "Draft" then content.match(/(?<=Draft\s).+/).to_s + " (#{iter}PD)"
427
+ ref = case s.text
428
+ when /^Draft/ then content.match(/(?<=Draft\s).+/).to_s + " (#{iter}PD)"
429
+ when /\(Draft\)/ then content + " (#{iter}PD)"
430
+ else content
423
431
  end
424
432
 
425
433
  fref = RelatonBib::FormattedRef.new(
@@ -1,3 +1,3 @@
1
1
  module RelatonNist
2
- VERSION = "0.3.8".freeze
2
+ VERSION = "0.5.1".freeze
3
3
  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 "bundler", "~> 2.0"
27
26
  spec.add_development_dependency "byebug"
28
27
  spec.add_development_dependency "debase"
29
28
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
@@ -34,7 +33,8 @@ Gem::Specification.new do |spec|
34
33
  spec.add_development_dependency "simplecov"
35
34
  spec.add_development_dependency "vcr"
36
35
  spec.add_development_dependency "webmock"
36
+ spec.add_development_dependency "ruby-jing"
37
37
 
38
- spec.add_dependency "relaton-bib", "~> 0.3.0"
38
+ spec.add_dependency "relaton-bib", "~> 0.5.0"
39
39
  spec.add_dependency "rubyzip"
40
40
  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.3.8
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-31 00:00:00.000000000 Z
11
+ date: 2020-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '2.0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '2.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: byebug
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -164,20 +150,34 @@ dependencies:
164
150
  - - ">="
165
151
  - !ruby/object:Gem::Version
166
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: ruby-jing
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: relaton-bib
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: 0.3.0
173
+ version: 0.5.0
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: 0.3.0
180
+ version: 0.5.0
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rubyzip
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -199,18 +199,24 @@ executables: []
199
199
  extensions: []
200
200
  extra_rdoc_files: []
201
201
  files:
202
+ - ".github/workflows/macos.yml"
203
+ - ".github/workflows/ubuntu.yml"
204
+ - ".github/workflows/windows.yml"
202
205
  - ".gitignore"
203
206
  - ".rspec"
204
207
  - ".rubocop.yml"
205
- - ".travis.yml"
206
208
  - Gemfile
207
- - Gemfile.lock
208
209
  - LICENSE.txt
209
210
  - README.adoc
210
211
  - Rakefile
211
- - appveyor.yml
212
212
  - bin/console
213
213
  - bin/setup
214
+ - grammars/basicdoc.rng
215
+ - grammars/biblio.rng
216
+ - grammars/isodoc.rng
217
+ - grammars/isostandard.rng
218
+ - grammars/nist.rng
219
+ - grammars/reqt.rng
214
220
  - lib/relaton_nist.rb
215
221
  - lib/relaton_nist/comment_period.rb
216
222
  - lib/relaton_nist/document_status.rb
data/.travis.yml DELETED
@@ -1,18 +0,0 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
3
- language: ruby
4
- cache: bundler
5
- os:
6
- - linux
7
- - osx
8
- rvm:
9
- - 2.6
10
- - 2.5
11
- - 2.4
12
- - ruby-head
13
- before_install:
14
- - gem install bundler -v "~> 2"
15
- - bundle update
16
- matrix:
17
- allow_failures:
18
- - rvm: ruby-head
data/Gemfile.lock DELETED
@@ -1,87 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- relaton-nist (0.3.8)
5
- relaton-bib (~> 0.3.0)
6
- rubyzip
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- addressable (2.7.0)
12
- public_suffix (>= 2.0.2, < 5.0)
13
- byebug (11.0.1)
14
- coderay (1.1.2)
15
- crack (0.4.3)
16
- safe_yaml (~> 1.0.0)
17
- debase (0.2.2)
18
- debase-ruby_core_source (>= 0.10.2)
19
- debase-ruby_core_source (0.10.5)
20
- diff-lcs (1.3)
21
- docile (1.3.2)
22
- equivalent-xml (0.6.0)
23
- nokogiri (>= 1.4.3)
24
- hashdiff (0.4.0)
25
- json (2.2.0)
26
- method_source (0.9.2)
27
- mini_portile2 (2.4.0)
28
- nokogiri (1.10.4)
29
- mini_portile2 (~> 2.4.0)
30
- pry (0.12.2)
31
- coderay (~> 1.1.0)
32
- method_source (~> 0.9.0)
33
- pry-byebug (3.7.0)
34
- byebug (~> 11.0)
35
- pry (~> 0.10)
36
- public_suffix (4.0.1)
37
- rake (10.5.0)
38
- relaton-bib (0.3.12)
39
- addressable
40
- nokogiri
41
- rspec (3.8.0)
42
- rspec-core (~> 3.8.0)
43
- rspec-expectations (~> 3.8.0)
44
- rspec-mocks (~> 3.8.0)
45
- rspec-core (3.8.1)
46
- rspec-support (~> 3.8.0)
47
- rspec-expectations (3.8.4)
48
- diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.8.0)
50
- rspec-mocks (3.8.1)
51
- diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.8.0)
53
- rspec-support (3.8.2)
54
- ruby-debug-ide (0.7.0)
55
- rake (>= 0.8.1)
56
- rubyzip (2.0.0)
57
- safe_yaml (1.0.5)
58
- simplecov (0.16.1)
59
- docile (~> 1.1)
60
- json (>= 1.8, < 3)
61
- simplecov-html (~> 0.10.0)
62
- simplecov-html (0.10.2)
63
- vcr (5.0.0)
64
- webmock (3.6.0)
65
- addressable (>= 2.3.6)
66
- crack (>= 0.3.2)
67
- hashdiff (>= 0.4.0, < 2.0.0)
68
-
69
- PLATFORMS
70
- ruby
71
-
72
- DEPENDENCIES
73
- bundler (~> 2.0)
74
- byebug
75
- debase
76
- equivalent-xml (~> 0.6)
77
- pry-byebug
78
- rake (~> 10.0)
79
- relaton-nist!
80
- rspec (~> 3.0)
81
- ruby-debug-ide
82
- simplecov
83
- vcr
84
- webmock
85
-
86
- BUNDLED WITH
87
- 2.0.1
data/appveyor.yml DELETED
@@ -1,37 +0,0 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
3
- version: '{build}'
4
-
5
- cache:
6
- - vendor/bundle
7
-
8
- environment:
9
- matrix:
10
- - RUBY_VERSION: 26
11
- - RUBY_VERSION: 25
12
- - RUBY_VERSION: 24
13
- - RUBY_VERSION: _trunk
14
-
15
- matrix:
16
- allow_failures:
17
- - RUBY_VERSION: _trunk
18
-
19
- install:
20
- - ps: . { iwr -useb https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/appveyor.ps1 } | iex
21
- - refreshenv
22
-
23
- build_script:
24
- - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
25
- - set GIT_TERMINAL_PROMPT=0
26
- - gem install bundler -v "~> 2"
27
- - bundle config --local path vendor/bundle
28
- - bundle update
29
- - bundle install
30
-
31
- before_test:
32
- - ruby -v
33
- - gem -v
34
- - bundle -v
35
-
36
- test_script:
37
- - bundle exec rake