relaton-nist 0.4.0 → 0.7.0

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: b8ecd59e55592824d0fc5dbdf74153a3239bc692d8c85245302487fb15b06a43
4
- data.tar.gz: 3e2f8467fcf4fec8c84ded04a6f3b56fe6c12e158efd0194ecc9e141b5c0e1fe
3
+ metadata.gz: c87f09763dbcc319401cbc3b2c86de4a1cdd60743f00db8526d2a28e52a71dfd
4
+ data.tar.gz: 9d690b4c771ae2f7256c6dd0770022b7709e00f08ee4efa625cbb144d3ba80b6
5
5
  SHA512:
6
- metadata.gz: 23774ffcc458ffb19987383373313f4829b73115765100e123727ec961c6e8410c50d42382b18eb5715b8b204d172ceeb278ffbc967835e26bdc2ed802048124
7
- data.tar.gz: 15def1a57fdd91e48166238ce6a2da7691ceccf7157ce7aa8c687bcfa82e91482e4f2ebf2ea009c9aa94659307f7cab4afe78ceae9b20d38ffcfc80339b48623
6
+ metadata.gz: ad3251b6140a8b79de2a952eed6ba721011efe3d77dff8f195147e0a0819356a6dcd52b48868d883bbb8572d32ff27216ec29bc76f942e2da51c2f69f5a687e7
7
+ data.tar.gz: a6f32c9121980c23c324e6a1c7daead5baf266401dcad3efab1dfe0f46e6d886b21c84fe9750df2ed1a14f3cfc2377183b497e95c84f739c8277e727514459f2
@@ -1,14 +1,19 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
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: [push]
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 -v "~> 2" --force
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 !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
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: [push]
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 -v "~> 2"
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 !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
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: [push]
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 -v "~> 2"
29
+ gem install bundler
25
30
  bundle config --local path vendor/bundle
26
31
  bundle update
27
32
  bundle install --jobs 4 --retry 3
data/.gitignore CHANGED
@@ -12,3 +12,5 @@
12
12
  # rspec failure tracking
13
13
  .rspec_status
14
14
  pubs-export.json
15
+ Gemfile.lock
16
+ .byebug_history
data/README.adoc CHANGED
@@ -1,9 +1,12 @@
1
1
  = RelatonNist: retrieve NIST Standards for bibliographic use using the BibliographicItem model
2
2
 
3
3
  image:https://img.shields.io/gem/v/relaton-nist.svg["Gem Version", link="https://rubygems.org/gems/relaton-nist"]
4
- image:https://img.shields.io/travis/metanorma/relaton-nist/master.svg["Build Status", link="https://travis-ci.com/metanorma/relaton-nist"]
5
- image:https://ci.appveyor.com/api/projects/status/vk85u3df4f3kertr?svg=true["Appveyor Build Status", link="https://ci.appveyor.com/project/ribose/relaton-nist"]
6
- image:https://codeclimate.com/github/metanorma/relaton-nist/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/relaton-nist"]
4
+ image:https://github.com/relaton/relaton-nist/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/relaton/relaton-nist/actions?workflow=macos"]
5
+ image:https://github.com/relaton/relaton-nist/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/relaton/relaton-nist/actions?workflow=windows"]
6
+ image:https://github.com/relaton/relaton-nist/workflows/ubuntu/badge.svg["Build Status (Ubuntu)", link="https://github.com/relaton/relaton-nist/actions?workflow=ubuntu"]
7
+ image:https://codeclimate.com/github/relaton/relaton-nist/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/relaton/relaton-nist"]
8
+ image:https://img.shields.io/github/issues-pr-raw/relaton/relaton-nist.svg["Pull Requests", link="https://github.com/relaton/relaton-nist/pulls"]
9
+ image:https://img.shields.io/github/commits-since/relaton/relaton-nist/latest.svg["Commits since latest",link="https://github.com/relaton/relaton-nist/releases"]
7
10
 
8
11
 
9
12
  RelatonNist is a Ruby gem that implements the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model].
data/grammars/biblio.rng CHANGED
@@ -638,9 +638,9 @@
638
638
  <zeroOrMore>
639
639
  <ref name="license"/>
640
640
  </zeroOrMore>
641
- <optional>
641
+ <zeroOrMore>
642
642
  <ref name="bclassification"/>
643
- </optional>
643
+ </zeroOrMore>
644
644
  <zeroOrMore>
645
645
  <ref name="bkeyword"/>
646
646
  </zeroOrMore>
@@ -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
 
@@ -16,17 +16,18 @@ module RelatonNist
16
16
  def sort_value
17
17
  @sort_value ||= begin
18
18
  sort_phrase = [hit[:serie], hit[:code], hit[:title]].join " "
19
- corr = hit_collection.text.split.map do |w|
19
+ corr = hit_collection&.text&.split&.map do |w|
20
20
  if w =~ /\w+/ &&
21
21
  sort_phrase =~ Regexp.new(Regexp.escape(w), Regexp::IGNORECASE)
22
22
  1
23
23
  else 0
24
24
  end
25
- end.sum
25
+ end&.sum.to_i
26
26
  corr + case hit[:status]
27
- when "final" then 3
28
- when "withdrawn" then 2
29
- when "draft (withdrawn)" then 1
27
+ when "final" then 4
28
+ when "withdrawn" then 3
29
+ when "draft" then 2
30
+ when "draft (obsolete)" then 1
30
31
  else 0
31
32
  end
32
33
  end
@@ -66,12 +66,12 @@ module RelatonNist
66
66
  serie = h.at("td[1]").text.strip
67
67
  code = h.at("td[2]").text.strip
68
68
  title = link.text
69
- url = DOMAIN + link[:href]
69
+ doc_url = DOMAIN + link[:href]
70
70
  status = h.at("td[4]").text.strip.downcase
71
71
  release_date = Date.strptime h.at("td[5]").text.strip, "%m/%d/%Y"
72
72
  Hit.new(
73
73
  {
74
- code: code, serie: serie, title: title, url: url, status: status,
74
+ code: code, serie: serie, title: title, url: doc_url, status: status,
75
75
  release_date: release_date
76
76
  }, self
77
77
  )
@@ -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"
@@ -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")]
@@ -128,7 +134,7 @@ module RelatonNist
128
134
  iter = doc["iteration"] == "initial" ? 1 : doc["iteration"]
129
135
  else
130
136
  case status
131
- when "draft (withdrawn)"
137
+ when "draft (obsolete)"
132
138
  stage = "draft-public"
133
139
  subst = "withdrawn"
134
140
  when "retired draft"
@@ -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(
@@ -437,7 +445,7 @@ module RelatonNist
437
445
  else
438
446
  doc.xpath "//span[@id='pub-keywords-container']/span"
439
447
  end
440
- kws.map { |kw| Keyword.new kw.is_a?(String) ? kw : kw.text }
448
+ kws.map { |kw| kw.is_a?(String) ? kw : kw.text }
441
449
  end
442
450
 
443
451
  # @param doc [Nokogiri::HTML::Document]
@@ -1,3 +1,3 @@
1
1
  module RelatonNist
2
- VERSION = "0.4.0".freeze
2
+ VERSION = "0.7.0".freeze
3
3
  end
@@ -14,7 +14,6 @@ module RelatonNist
14
14
  ext = nistitem.at "./ext"
15
15
  return data unless ext
16
16
 
17
- data[:keyword] = fetch_keyword(ext)
18
17
  data[:commentperiod] = fetch_commentperiod(ext)
19
18
  data
20
19
  end
@@ -39,12 +38,6 @@ module RelatonNist
39
38
  extended: cp.at("extended")&.text
40
39
  )
41
40
  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
41
  end
49
42
  end
50
43
  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"
@@ -36,6 +35,6 @@ Gem::Specification.new do |spec|
36
35
  spec.add_development_dependency "webmock"
37
36
  spec.add_development_dependency "ruby-jing"
38
37
 
39
- spec.add_dependency "relaton-bib", "~> 0.4.0"
38
+ spec.add_dependency "relaton-bib", "~> 0.7.0"
40
39
  spec.add_dependency "rubyzip"
41
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.4.0
4
+ version: 0.7.0
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-12-11 00:00:00.000000000 Z
11
+ date: 2020-02-17 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
@@ -184,14 +170,14 @@ dependencies:
184
170
  requirements:
185
171
  - - "~>"
186
172
  - !ruby/object:Gem::Version
187
- version: 0.4.0
173
+ version: 0.7.0
188
174
  type: :runtime
189
175
  prerelease: false
190
176
  version_requirements: !ruby/object:Gem::Requirement
191
177
  requirements:
192
178
  - - "~>"
193
179
  - !ruby/object:Gem::Version
194
- version: 0.4.0
180
+ version: 0.7.0
195
181
  - !ruby/object:Gem::Dependency
196
182
  name: rubyzip
197
183
  requirement: !ruby/object:Gem::Requirement
@@ -220,7 +206,6 @@ files:
220
206
  - ".rspec"
221
207
  - ".rubocop.yml"
222
208
  - Gemfile
223
- - Gemfile.lock
224
209
  - LICENSE.txt
225
210
  - README.adoc
226
211
  - Rakefile
@@ -238,7 +223,6 @@ files:
238
223
  - lib/relaton_nist/hash_converter.rb
239
224
  - lib/relaton_nist/hit.rb
240
225
  - lib/relaton_nist/hit_collection.rb
241
- - lib/relaton_nist/keyword.rb
242
226
  - lib/relaton_nist/nist_bibliographic_item.rb
243
227
  - lib/relaton_nist/nist_bibliography.rb
244
228
  - lib/relaton_nist/processor.rb
data/Gemfile.lock DELETED
@@ -1,91 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- relaton-nist (0.4.0)
5
- relaton-bib (~> 0.4.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.7)
29
- mini_portile2 (~> 2.4.0)
30
- optout (0.0.2)
31
- pry (0.12.2)
32
- coderay (~> 1.1.0)
33
- method_source (~> 0.9.0)
34
- pry-byebug (3.7.0)
35
- byebug (~> 11.0)
36
- pry (~> 0.10)
37
- public_suffix (4.0.1)
38
- rake (10.5.0)
39
- relaton-bib (0.4.0)
40
- addressable
41
- nokogiri
42
- rspec (3.8.0)
43
- rspec-core (~> 3.8.0)
44
- rspec-expectations (~> 3.8.0)
45
- rspec-mocks (~> 3.8.0)
46
- rspec-core (3.8.1)
47
- rspec-support (~> 3.8.0)
48
- rspec-expectations (3.8.4)
49
- diff-lcs (>= 1.2.0, < 2.0)
50
- rspec-support (~> 3.8.0)
51
- rspec-mocks (3.8.1)
52
- diff-lcs (>= 1.2.0, < 2.0)
53
- rspec-support (~> 3.8.0)
54
- rspec-support (3.8.2)
55
- ruby-debug-ide (0.7.0)
56
- rake (>= 0.8.1)
57
- ruby-jing (0.0.1)
58
- optout (>= 0.0.2)
59
- rubyzip (2.0.0)
60
- safe_yaml (1.0.5)
61
- simplecov (0.16.1)
62
- docile (~> 1.1)
63
- json (>= 1.8, < 3)
64
- simplecov-html (~> 0.10.0)
65
- simplecov-html (0.10.2)
66
- vcr (5.0.0)
67
- webmock (3.6.0)
68
- addressable (>= 2.3.6)
69
- crack (>= 0.3.2)
70
- hashdiff (>= 0.4.0, < 2.0.0)
71
-
72
- PLATFORMS
73
- ruby
74
-
75
- DEPENDENCIES
76
- bundler (~> 2.0)
77
- byebug
78
- debase
79
- equivalent-xml (~> 0.6)
80
- pry-byebug
81
- rake (~> 10.0)
82
- relaton-nist!
83
- rspec (~> 3.0)
84
- ruby-debug-ide
85
- ruby-jing
86
- simplecov
87
- vcr
88
- webmock
89
-
90
- BUNDLED WITH
91
- 2.0.2
@@ -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