relaton-ietf 1.11.3 → 1.11.6

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: 53c7e68edafd4a51e8b08f0b169318d1864a0fba32327f9ceaf2eb7968048c97
4
- data.tar.gz: 8b75d635bbc3e97c9cb7a680ed0c657d50614a5313babe1ac5759dd0e1c584c4
3
+ metadata.gz: bb60963a99c05a4f4ce71a2f896e6f6a4ba4d5aca27affbb5a5f224671e2fa35
4
+ data.tar.gz: 11fedecf896b30c5fedf546eb683ef5f5cfc1c58eab735155a2d5a394b585733
5
5
  SHA512:
6
- metadata.gz: bcdaea6abeb068ad1a23bd9e2ba3f5792c1eeccd06b90586f8307aa005f3204f6cd135ac96b38b5ac60a1a38e70980ec3ff3163255eb5b79254f60bba8be9732
7
- data.tar.gz: 2f2ce84d3898691e786fc598963842f68e36ea0ee2a9ee179d131d00ab1ce724860938e40caedbb4cf06adf1cafceffdbd9109e481ae8142453f804c80349088
6
+ metadata.gz: dfff8e3c6390dbeadc59c8a2e3779520e13042adc3b752556111ac61851bbd30612799bd9c9296d919d88ca79188454ecf292f9afe4979053d67a0a03b699d3a
7
+ data.tar.gz: 0f3224b2e6272bc570bdb9d705c9d3e3dfa3ec8f47019e46dee266ef11f8803a74be0fbbd8c604b9e84ae4fd7b473857dab03aac61a23a0df52a363a260620b7
@@ -10,27 +10,4 @@ on:
10
10
 
11
11
  jobs:
12
12
  rake:
13
- name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
- runs-on: ${{ matrix.os }}
15
- continue-on-error: ${{ matrix.experimental }}
16
- strategy:
17
- fail-fast: false
18
- matrix:
19
- ruby: ['3.0', '2.7', '2.6', '2.5' ]
20
- os: [ ubuntu-latest, windows-latest, macos-latest ]
21
- experimental: [ false ]
22
- steps:
23
- - uses: actions/checkout@v2
24
- with:
25
- submodules: true
26
-
27
- # https://github.com/ruby-debug/debase/issues/89#issuecomment-686827382
28
- - if: matrix.os == 'macos-latest' && matrix.ruby == '2.5'
29
- run: echo BUNDLE_BUILD__DEBASE="--with-cflags=\"-Wno-error=implicit-function-declaration\"" >> $GITHUB_ENV
30
-
31
- - uses: ruby/setup-ruby@v1
32
- with:
33
- ruby-version: ${{ matrix.ruby }}
34
- bundler-cache: true
35
-
36
- - run: bundle exec rake
13
+ uses: relaton/support/.github/workflows/rake.yml@master
data/README.adoc CHANGED
@@ -47,10 +47,10 @@ item = RelatonIetf::IetfBibliography.get 'IETF RFC 8341'
47
47
  ...
48
48
 
49
49
  # Fetch Internet-Draft document
50
- RelatonIetf::IetfBibliography.get 'IETF I-D.abarth-cake-02'
51
- [relaton-ietf] ("IETF I-D.abarth-cake-02") fetching...
52
- [relaton-ietf] ("IETF I-D.abarth-cake-02") found I-D.abarth-cake
53
- => #<RelatonIetf::IetfBibliographicItem:0x00007fa7c81688f8
50
+ RelatonIetf::IetfBibliography.get 'IETF I-D.draft-abarth-cake-01'
51
+ [relaton-ietf] ("IETF I-D.draft-abarth-cake-01") fetching...
52
+ [relaton-ietf] ("IETF I-D.draft-abarth-cake-01") found draft-abarth-cake-01
53
+ => #<RelatonIetf::IetfBibliographicItem:0x00007fdd129bbeb8
54
54
  ...
55
55
 
56
56
  # Return nil if document doesn't exist.
@@ -65,12 +65,12 @@ RelatonIetf::IetfBibliography.get 'IETF 1111'
65
65
  [source,ruby]
66
66
  ----
67
67
  item.to_xml
68
- =>"<bibitem id="RFC8341">
69
- <fetched>2019-06-05</fetched>
70
- <title format="text/plain" language="en" script="Latn">Network Configuration Access Control Model</title>
68
+ =>"<bibitem id="RFC8341" type="standard">
69
+ <fetched>2022-06-10</fetched>
70
+ <title type="main" format="text/plain">Network Configuration Access Control Model</title>
71
71
  <uri type="src">https://www.rfc-editor.org/info/rfc8341</uri>
72
- <docidentifier type="IETF">RFC 8341</docidentifier>
73
- <docidentifier type=\"rfc-anchor\">RFC8341</docidentifier>
72
+ <docidentifier type="IETF" primary="true">RFC 8341</docidentifier>
73
+ <docidentifier type="IETF" scope="anchor">RFC8341</docidentifier>
74
74
  <docidentifier type="DOI">10.17487/RFC8341</docidentifier>
75
75
  ....
76
76
  </bibitem>"
@@ -79,13 +79,15 @@ With `bibdata: true` option XML output wrapped with `bibdata` element and `ext`
79
79
  [source,ruby]
80
80
  ----
81
81
  item.to_xml bibdata: true
82
- =>"<bibdata>
83
- <fetched>2019-06-05</fetched>
84
- <title format="text/plain" language="en" script="Latn">Network Configuration Access Control Model</title>
82
+ =>"<bibdata type="standard">
83
+ <fetched>2022-06-10</fetched>
84
+ <title type="main" format="text/plain">Network Configuration Access Control Model</title>
85
85
  <uri type="src">https://www.rfc-editor.org/info/rfc8341</uri>
86
86
  ...
87
87
  <ext>
88
- <doctype>rfc</doctype>
88
+ <editorialgroup>
89
+ <committee>netconf</committee>
90
+ </editorialgroup>
89
91
  </ext>
90
92
  </bibdata>"
91
93
  ----
@@ -94,6 +94,7 @@ module RelatonIetf
94
94
  if series != match[:series]
95
95
  bib_versions = versions.select { |ref| ref.include? match[:series] }
96
96
  create_series match[:series], bib_versions
97
+ series = match[:series]
97
98
  end
98
99
  lv = bib_versions.select { |ref| ref.match(/\d+$/).to_s.to_i < match[:ver].to_i }
99
100
  hv = bib_versions.select { |ref| ref.match(/\d+$/).to_s.to_i > match[:ver].to_i }
@@ -103,7 +104,6 @@ module RelatonIetf
103
104
  bib.relation << version_relation(hv.first, "updatedBy") if hv.any?
104
105
  save_doc bib, check_duplicate: false
105
106
  end
106
- series = match[:series]
107
107
  end
108
108
  end
109
109
  end
@@ -114,14 +114,18 @@ module RelatonIetf
114
114
  # @param [String] ref reference
115
115
  # @param [Array<String>] versions list of versions
116
116
  #
117
- def create_series(ref, versions)
117
+ def create_series(ref, versions) # rubocop:disable Metrics/AbcSize
118
118
  return if versions.size < 2
119
119
 
120
+ vs = versions.sort_by { |v| v.match(/\d+$/).to_s.to_i }
120
121
  fref = RelatonBib::FormattedRef.new content: ref
121
- rel = versions.map do |v|
122
- version_relation v, "includes"
123
- end
124
- save_doc IetfBibliographicItem.new(formattedref: fref, relation: rel)
122
+ docid = RelatonBib::DocumentIdentifier.new type: "Internet-Draft", id: ref, primary: true
123
+ rel = vs.map { |v| version_relation v, "includes" }
124
+ last_v = HashConverter.hash_to_bib YAML.load_file("#{@output}/#{vs.last}.#{@ext}")
125
+ bib = IetfBibliographicItem.new(
126
+ title: last_v[:title], abstract: last_v[:abstract], formattedref: fref, docid: [docid], relation: rel,
127
+ )
128
+ save_doc bib
125
129
  end
126
130
 
127
131
  #
@@ -134,7 +138,8 @@ module RelatonIetf
134
138
  #
135
139
  def version_relation(ref, type)
136
140
  fref = RelatonBib::FormattedRef.new content: ref
137
- bibitem = IetfBibliographicItem.new formattedref: fref
141
+ docid = RelatonBib::DocumentIdentifier.new type: "Internet-Draft", id: ref, primary: true
142
+ bibitem = IetfBibliographicItem.new formattedref: fref, docid: [docid]
138
143
  RelatonBib::DocumentRelation.new(type: type, bibitem: bibitem)
139
144
  end
140
145
 
@@ -9,6 +9,16 @@ module RelatonIetf
9
9
  def bib_item(item)
10
10
  IetfBibliographicItem.new(**item)
11
11
  end
12
+
13
+ # @param ret [Hash]
14
+ def editorialgroup_hash_to_bib(ret)
15
+ return unless ret[:editorialgroup]
16
+
17
+ technical_committee = array(ret[:editorialgroup]).map do |wg|
18
+ Committee.new RelatonBib::WorkGroup.new(**wg)
19
+ end
20
+ ret[:editorialgroup] = RelatonBib::EditorialGroup.new technical_committee
21
+ end
12
22
  end
13
23
  end
14
24
  end
@@ -6,7 +6,7 @@ module RelatonIetf
6
6
  def initialize # rubocop:disable Lint/MissingSuper
7
7
  @short = :relaton_ietf
8
8
  @prefix = "IETF"
9
- @defaultprefix = /^(IETF|RFC|BCP)\s/
9
+ @defaultprefix = /^(IETF|RFC|BCP|FYI|STD)\s/
10
10
  @idtype = "IETF"
11
11
  @datasets = %w[ietf-rfcsubseries ietf-internet-drafts ietf-rfc-entries]
12
12
  end
@@ -243,7 +243,8 @@ module RelatonIetf
243
243
  types = { "updates" => "updates", "obsoleted-by" => "obsoletedBy"}
244
244
  @doc.xpath("./xmlns:updates/xmlns:doc-id|./xmlns:obsoleted-by/xmlns:doc-id").map do |r|
245
245
  fref = RelatonBib::FormattedRef.new(content: r.text)
246
- bib = IetfBibliographicItem.new(formattedref: fref)
246
+ docid = RelatonBib::DocumentIdentifier.new type: "IETF", id: r.text, primary: true
247
+ bib = IetfBibliographicItem.new(formattedref: fref, docid: [docid])
247
248
  RelatonBib::DocumentRelation.new(type: types[r.parent.name], bibitem: bib)
248
249
  end
249
250
  end
@@ -30,6 +30,11 @@ module RelatonIetf
30
30
  new(doc, doc_id.text, is_also).parse
31
31
  end
32
32
 
33
+ #
34
+ # Parse document
35
+ #
36
+ # @return [RelatonIetf::IetfBibliographicItem] bib item
37
+ #
33
38
  def parse
34
39
  IetfBibliographicItem.new(
35
40
  docnumber: docnumber,
@@ -44,14 +49,19 @@ module RelatonIetf
44
49
  end
45
50
 
46
51
  #
47
- # Document id
52
+ # Document number
48
53
  #
49
- # @return [Strinng] document id
54
+ # @return [Strinng] document number
50
55
  #
51
56
  def docnumber
52
57
  @doc_id
53
58
  end
54
59
 
60
+ #
61
+ # Create docidentifiers
62
+ #
63
+ # @return [Array<RelatonBib::DocumentIdentifier>] docidentifiers
64
+ #
55
65
  def parse_docid
56
66
  [
57
67
  RelatonBib::DocumentIdentifier.new(type: "IETF", id: pub_id, primary: true),
@@ -59,30 +69,55 @@ module RelatonIetf
59
69
  ]
60
70
  end
61
71
 
72
+ #
73
+ # Create pub_id
74
+ #
75
+ # @return [String] pub_id
76
+ #
62
77
  def pub_id
63
78
  "#{@name.upcase} #{@shortnum}"
64
79
  end
65
80
 
81
+ #
82
+ # Create anchor
83
+ #
84
+ # @return [String] anchor
85
+ #
66
86
  def anchor
67
87
  "#{@name.upcase}#{@shortnum}"
68
88
  end
69
89
 
90
+ #
91
+ # Create link
92
+ #
93
+ # @return [Array<RelatonBib::TypedUri>]
94
+ #
70
95
  def parse_link
71
96
  [RelatonBib::TypedUri.new(type: "src", content: "https://www.rfc-editor.org/info/#{@name}#{@shortnum}")]
72
97
  end
73
98
 
99
+ #
100
+ # Create formatted reference
101
+ #
102
+ # @return [RelatonBib::FormattedRef]
103
+ #
74
104
  def formattedref
75
105
  RelatonBib::FormattedRef.new(
76
106
  content: anchor, language: "en", script: "Latn",
77
107
  )
78
108
  end
79
109
 
110
+ #
111
+ # Create relations
112
+ #
113
+ # @return [Array<Hash>] relations
114
+ #
80
115
  def parse_relation
81
- @is_also.each_with_object([]) do |ref, a|
82
- # bib = IetfBibliography.get ref.sub(/^(RFC)(\d+)/, '\1 \2')
83
- ref_doc = @doc.at "/xmlns:rfc-index/xmlns:rfc-entry[xmlns:doc-id[text()='#{ref}']]"
84
- bib = RfcEntry.parse ref_doc
85
- a << { type: "includes", bibitem: bib } if bib
116
+ @is_also.map do |ref|
117
+ fref = RelatonBib::FormattedRef.new content: ref
118
+ docid = RelatonBib::DocumentIdentifier.new(type: "IETF", id: ref, primary: true)
119
+ bib = IetfBibliographicItem.new formattedref: fref, docid: [docid]
120
+ { type: "includes", bibitem: bib }
86
121
  end
87
122
  end
88
123
  end
@@ -5,7 +5,9 @@ module RelatonIetf
5
5
  module Scrapper
6
6
  extend Scrapper
7
7
 
8
- GH_URL = "https://raw.githubusercontent.com/relaton/relaton-data-ietf/master/data/reference."
8
+ IDS = "https://raw.githubusercontent.com/ietf-ribose/relaton-data-ids/main/data/"
9
+ RFC = "https://raw.githubusercontent.com/ietf-ribose/relaton-data-rfcs/main/data/"
10
+ RSS = "https://raw.githubusercontent.com/ietf-ribose/relaton-data-rfcsubseries/main/data/"
9
11
 
10
12
  # @param text [String]
11
13
  # @param is_relation [TrueClass, FalseClass]
@@ -13,8 +15,7 @@ module RelatonIetf
13
15
  def scrape_page(text, is_relation: false)
14
16
  # Remove initial "IETF " string if specified
15
17
  ref = text.gsub(/^IETF /, "")
16
- /^(?:RFC|BCP|FYI|STD)\s(?<num>\d+)/ =~ ref
17
- ref.sub!(/(?<=^(?:RFC|BCP|FYI|STD)\s)(\d+)/, num.rjust(4, "0")) if num
18
+ ref.sub!(/(?<=^(?:RFC|BCP|FYI|STD))\s(\d+)/) { $1.rjust 4, "0" }
18
19
  rfc_item ref, is_relation
19
20
  rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
20
21
  Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
@@ -28,17 +29,19 @@ module RelatonIetf
28
29
  # @param is_relation [Boolen, nil]
29
30
  # @return [RelatonIetf::IetfBibliographicItem]
30
31
  def rfc_item(ref, is_relation)
31
- /(?<=-)(?<ver>\d{2})$/ =~ ref
32
- if /^I-D/.match? ref
33
- ref.sub!(/-\d{2}/, "") if ver
34
- ref.sub!(/(?<=I-D\.)draft-/, "")
35
- end
36
-
37
- uri = "#{GH_URL}#{ref.sub(/\s|\u00a0/, '.')}.xml"
38
- # doc = Nokogiri::XML get_page(uri)
39
- # r = doc.at("/referencegroup", "/reference")
40
- # fetch_rfc r, is_relation: is_relation, url: uri, ver: ver
41
- BibXMLParser.parse get_page(uri), is_relation: is_relation, ver: ver
32
+ ghurl = case ref
33
+ when /^RFC/ then RFC
34
+ when /^(?:BCP|FYI|STD)/ then RSS
35
+ when /^I-D/
36
+ ref.sub!(/^I-D\./, "")
37
+ IDS
38
+ else return
39
+ end
40
+
41
+ uri = "#{ghurl}#{ref.sub(/\s|\u00a0/, '.')}.yaml"
42
+ # BibXMLParser.parse get_page(uri), is_relation: is_relation, ver: ver
43
+ resp = get_page uri
44
+ IetfBibliographicItem.from_hash YAML.safe_load(resp) if resp
42
45
  end
43
46
 
44
47
  # @param uri [String]
@@ -1,3 +1,3 @@
1
1
  module RelatonIetf
2
- VERSION = "1.11.3".freeze
2
+ VERSION = "1.11.6".freeze
3
3
  end
@@ -11,6 +11,21 @@ module RelatonIetf
11
11
  def bib_item(item_hash)
12
12
  IetfBibliographicItem.new(**item_hash)
13
13
  end
14
+
15
+ # @param ext [Nokogiri::XML::Element]
16
+ # @return [RelatonBib::EditorialGroup, nil]
17
+ def fetch_editorialgroup(ext)
18
+ return unless ext && (eg = ext.at "editorialgroup")
19
+
20
+ eg = eg.xpath("committee").map do |tc|
21
+ wg = RelatonBib::WorkGroup.new(
22
+ name: tc.text, number: tc[:number]&.to_i, type: tc[:type],
23
+ identifier: tc[:identifier], prefix: tc[:prefix]
24
+ )
25
+ Committee.new wg
26
+ end
27
+ RelatonBib::EditorialGroup.new eg if eg.any?
28
+ end
14
29
  end
15
30
  end
16
31
  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: 1.11.3
4
+ version: 1.11.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-05 00:00:00.000000000 Z
11
+ date: 2022-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml