relaton-ietf 0.8.0 → 0.9.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: ce626d7ff0f79fd229a0c88fc6a714f2e93534a65ab9c4c3bf3307e31c983b98
4
- data.tar.gz: be63f78277099f2073a880b012ed54774594922b3e6f71eb0417b8e023f72484
3
+ metadata.gz: 47bbfd5981028ba4af2af87312b808def1f0735f04cee90694779a4a9f358083
4
+ data.tar.gz: 0cb202851646c8b524a6fc87ef694a68e25b519968c0b6485c8dc40e7d94f638
5
5
  SHA512:
6
- metadata.gz: 5f4fff5fc1eb31ad0af0ccaf719642642dcb65e58cd0c5f87ebfff16914c1a60f8c734cd2e2bb25954ce5bac29aa9846abf3b67607cc92d99806b38a1bf74897
7
- data.tar.gz: dfd8ce3e812cec5cae6dc7805e13bafc26dcaaa5528db07a9086ec38b474f6d709a9248e1d0c8d139ef7bec7ee65d7eacf65c9b750d2fac83af939c2138228c3
6
+ metadata.gz: e9aa8ad8c6894263665952bb19f620c693882d10bb76c53d7ba18ccd345bc2830d47d51fc94c2101681b5fec82f5b454076425908feefc16bf62a3f89d02535d
7
+ data.tar.gz: 601e5e1c75f47cc31d0356e042c26349adc5d4d5166a5fd12eea5332ec0147c99801f4efe103d279d2bfee6727b88847ea70f2ec33c894f8d6a12de69df5fe28
@@ -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.0.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
@@ -10,7 +10,7 @@ module RelatonIetf
10
10
  # @param keyword [Array<String>]
11
11
  def initialize(**args)
12
12
  @doctype = args.delete :doctype
13
- @keyword = args.delete(:keyword) || []
13
+ # @keyword = args.delete(:keyword) || []
14
14
  super
15
15
  end
16
16
 
@@ -23,7 +23,7 @@ module RelatonIetf
23
23
  if opts[:bibdata]
24
24
  b.ext do
25
25
  b.doctype doctype if doctype
26
- keyword.each { |k| b.keyword k }
26
+ # keyword.each { |k| b.keyword k }
27
27
  end
28
28
  end
29
29
  end
@@ -33,7 +33,7 @@ module RelatonIetf
33
33
  def to_hash
34
34
  hash = super
35
35
  hash["doctype"] = doctype if doctype
36
- hash["keyword"] = single_element_array(keyword) if keyword&.any?
36
+ # hash["keyword"] = single_element_array(keyword) if keyword&.any?
37
37
  hash
38
38
  end
39
39
  end
@@ -45,18 +45,19 @@ module RelatonIetf
45
45
  # @param reference [String]
46
46
  # @param is_relation [TrueClass, FalseClass]
47
47
  # @param url [String, NilClass]
48
+ # @param ver [String, NilClass] Internet Draft version
48
49
  # @return [RelatonIetf::IetfBibliographicItem]
49
- def fetch_rfc(reference, is_relation = false, url = nil)
50
+ def fetch_rfc(reference, is_relation = false, url = nil, ver = nil)
50
51
  return unless reference
51
52
 
52
53
  ietf_item(
53
54
  is_relation: is_relation,
54
55
  id: reference[:anchor],
55
56
  type: "standard",
56
- docid: docids(reference),
57
+ docid: docids(reference, ver),
57
58
  status: status(reference),
58
59
  language: [language(reference)],
59
- link: link(reference, url),
60
+ link: link(reference, url, ver),
60
61
  title: titles(reference),
61
62
  abstract: abstracts(reference),
62
63
  contributor: contributors(reference),
@@ -77,10 +78,20 @@ module RelatonIetf
77
78
  anchor =~ /I-D/ ? "internet-draft" : "rfc"
78
79
  end
79
80
 
80
- def link(reference, url)
81
+ # @param reference [Nokogiri::XML::Element]
82
+ # @param url [String]
83
+ # @param ver [String, NilClass] Internet Draft version
84
+ # @return [Array<Hash>]
85
+ def link(reference, url, ver)
81
86
  l = []
82
87
  l << { type: "xml", content: url } if url
83
88
  l << { type: "src", content: reference[:target] } if reference[:target]
89
+ if reference[:anchor] =~ /^I-D/
90
+ reference.xpath("format").each do |f|
91
+ c = ver ? f[:target].sub(/(?<=-)\d{2}(?=\.)/, ver) : f[:target]
92
+ l << { type: f[:type], content: c }
93
+ end
94
+ end
84
95
  l
85
96
  end
86
97
 
@@ -99,10 +110,13 @@ module RelatonIetf
99
110
  uri = nil
100
111
  error = nil
101
112
  uri_nums.each do |n|
113
+ /(?<=-)(?<ver>\d{2})$/ =~ ref
114
+ ref.sub! /-\d{2}/, "" if ver && n == "3"
115
+
102
116
  uri = "#{RFC_URI_PATTERN}#{n}/reference.#{ref.sub(/\s|\u00a0/, ".")}.xml"
103
117
  begin
104
118
  doc = Nokogiri::XML get_page(uri)
105
- resp = fetch_rfc doc.at("//reference"), is_relation, uri
119
+ resp = fetch_rfc doc.at("//reference"), is_relation, uri, ver
106
120
  return resp if resp
107
121
  rescue RelatonBib::RequestError => e
108
122
  error = e
@@ -289,9 +303,12 @@ module RelatonIetf
289
303
  #
290
304
  # Extract document identifiers from reference
291
305
  #
306
+ # @param reference [Nokogiri::XML::Element]
307
+ # @param ver [String, NilClass] Internet Draft version
308
+ #
292
309
  # @return [Array<RelatonBib::DocumentIdentifier>]
293
310
  #
294
- def docids(reference)
311
+ def docids(reference, ver)
295
312
  id = (reference[:anchor] || reference[:docName]).sub(/^(RFC)/, "\\1 ")
296
313
  ret = []
297
314
  ret << RelatonBib::DocumentIdentifier.new(type: "IETF", id: id)
@@ -299,9 +316,11 @@ module RelatonIetf
299
316
  ret << RelatonBib::DocumentIdentifier.new(type: "rfc-anchor", id: id)
300
317
  end
301
318
  ret + reference.xpath("./seriesInfo").map do |si|
302
- next unless si[:name] == "DOI"
319
+ next unless ["DOI", "Internet-Draft"].include? si[:name]
303
320
 
304
- RelatonBib::DocumentIdentifier.new(id: si[:value], type: si[:name])
321
+ id = si[:value]
322
+ id.sub! /(?<=-)\d{2}$/, ver if ver && si[:name] == "Internet-Draft"
323
+ RelatonBib::DocumentIdentifier.new(id: id, type: si[:name])
305
324
  end.compact
306
325
  end
307
326
 
@@ -1,3 +1,3 @@
1
1
  module RelatonIetf
2
- VERSION = "0.8.0".freeze
2
+ VERSION = "0.9.0".freeze
3
3
  end
@@ -40,5 +40,5 @@ Gem::Specification.new do |spec|
40
40
  spec.add_development_dependency "webmock"
41
41
  spec.add_development_dependency "ruby-jing"
42
42
 
43
- spec.add_dependency "relaton-bib", "~> 0.5.0"
43
+ spec.add_dependency "relaton-bib", "~> 0.6.0"
44
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-ietf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.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: 2020-01-11 00:00:00.000000000 Z
11
+ date: 2020-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debase
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 0.5.0
159
+ version: 0.6.0
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 0.5.0
166
+ version: 0.6.0
167
167
  description: "RelatonIetf: retrieve IETF Standards for bibliographic use \nusing the
168
168
  BibliographicItem model.\n\nFormerly known as rfcbib.\n"
169
169
  email: