relaton-ietf 1.9.5 → 1.9.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: 662721a37445e18e6d5c2cce9f99cc3a62fe3d59a20870d00bf2f840bb645fd7
4
- data.tar.gz: 4129066b66f1fc0391ac2d06db9735dfe86c288be0004276be0092e06e2cf461
3
+ metadata.gz: 05d7da0539d628af6e8dbe016497f640fe1a238c164e280e6d9bae3152de3bb5
4
+ data.tar.gz: 4d7da3f63909c912630f6b2d2ac7c2224219662a6cd8ce840f4156bb59072e18
5
5
  SHA512:
6
- metadata.gz: 797bacba502406e48b573ab58ca9ec413dd8e51b5fef5c28b4676e7ba233cb2e4db3ffffefcff233a2f8a440bee9296083c11420684f9307a4b2bbf7e85c68b5
7
- data.tar.gz: e0fcc1ac666e54a869aec07fa5fe6fd5397b04e6afced205cbee57366310b7fccf23840b1d724a30e7c8f2781fb8d97f4a5ad36f9637510b5466f0ba14c1621b
6
+ metadata.gz: 688aefaa75847bfbb3dd9dc41dd91367b0e5749d78f2ef0f93296270d25165b69708a5a20367231df67525d536755f5eeef9c9f1f242a3e7b895381fac41f427
7
+ data.tar.gz: adc30f681ff6be584b9025aaad6d14ffa728a1bb82b10caac5d88a14954017dfc9a6328fd34c9f13176c3e9a2a3496b676d18d8405070bf00b92c5b15536f380
@@ -17,7 +17,7 @@ module RelatonIetf
17
17
  def initialize(source, output, format)
18
18
  @source = source
19
19
  @output = output
20
- @format = source == "ietf-rfcsubseries" ? "rfcxml" : format
20
+ @format = format
21
21
  @ext = @format.sub(/^bib|^rfc/, "")
22
22
  @files = []
23
23
  end
@@ -99,7 +99,6 @@ module RelatonIetf
99
99
  c = case @format
100
100
  when "xml" then entry.to_xml(bibdata: true)
101
101
  when "yaml" then entry.to_hash.to_yaml
102
- when "rfcxml" then entry.to_xml
103
102
  else entry.send("to_#{@format}")
104
103
  end
105
104
  file = file_name entry
@@ -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 = /^RFC /
9
+ @defaultprefix = /^(IETF|RFC|BCP)\s/
10
10
  @idtype = "IETF"
11
11
  @datasets = %w[ietf-rfcsubseries ietf-internet-drafts ietf-rfc-entries]
12
12
  end
@@ -3,8 +3,9 @@ module RelatonIetf
3
3
  #
4
4
  # Document parser initalization
5
5
  #
6
+ # @param [String] name document type name
6
7
  # @param [String] doc_id document id
7
- # @param [Array<String>] is_also also document ids
8
+ # @param [Array<String>] is_also included document ids
8
9
  #
9
10
  def initialize(name, doc_id, is_also)
10
11
  @name = name
@@ -13,15 +14,6 @@ module RelatonIetf
13
14
  @is_also = is_also
14
15
  end
15
16
 
16
- #
17
- # Document id
18
- #
19
- # @return [Strinng] document id
20
- #
21
- def docnumber
22
- @doc_id
23
- end
24
-
25
17
  #
26
18
  # Initialize document parser and run it
27
19
  #
@@ -35,26 +27,61 @@ module RelatonIetf
35
27
  return unless doc_id && is_also.any?
36
28
 
37
29
  name = doc.name.split("-").first
38
- new(name, doc_id.text, is_also)
30
+ new(name, doc_id.text, is_also).parse
31
+ end
32
+
33
+ def parse
34
+ IetfBibliographicItem.new(
35
+ docnumber: docnumber,
36
+ type: "standard",
37
+ docid: parse_docid,
38
+ language: ["en"],
39
+ script: ["Latn"],
40
+ link: parse_link,
41
+ formattedref: formattedref,
42
+ relation: parse_relation,
43
+ )
39
44
  end
40
45
 
41
46
  #
42
- # Render document as XML
47
+ # Document id
43
48
  #
44
- # @return [String] XML
49
+ # @return [Strinng] document id
45
50
  #
46
- def to_xml # rubocop:disable Metrics/MethodLength
47
- Nokogiri::XML::Builder.new do |xml|
48
- anchor = "#{@name.upcase}#{@shortnum}"
49
- url = "https://www.rfc-editor.org/info/#{@name}#{@shortnum}"
50
- xml.referencegroup("xmlns:xi" => "http://www.w3.org/2001/XInclude",
51
- anchor: anchor, target: url) do
52
- @is_also.each do |did|
53
- num = did[-4..-1]
54
- xml["xi"].send("include", href: "https://www.rfc-editor.org/refs/bibxml/reference.RFC.#{num}.xml")
55
- end
56
- end
57
- end.doc.root.to_xml
51
+ def docnumber
52
+ @doc_id
53
+ end
54
+
55
+ def parse_docid
56
+ [
57
+ RelatonBib::DocumentIdentifier.new(type: "IETF", id: pub_id),
58
+ RelatonBib::DocumentIdentifier.new(type: "rfc-anchor", id: anchor),
59
+ ]
60
+ end
61
+
62
+ def pub_id
63
+ "IETF #{@name.upcase} #{@shortnum}"
64
+ end
65
+
66
+ def anchor
67
+ "#{@name.upcase}#{@shortnum}"
68
+ end
69
+
70
+ def parse_link
71
+ [RelatonBib::TypedUri.new(type: "src", content: "https://www.rfc-editor.org/info/#{@name}#{@shortnum}")]
72
+ end
73
+
74
+ def formattedref
75
+ RelatonBib::FormattedRef.new(
76
+ content: anchor, language: "en", script: "Latn",
77
+ )
78
+ end
79
+
80
+ def parse_relation
81
+ @is_also.map do |ref|
82
+ bib = IetfBibliography.get ref.sub(/^(RFC)(\d+)/, '\1 \2')
83
+ { type: "includes", bibitem: bib }
84
+ end
58
85
  end
59
86
  end
60
87
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonIetf
2
- VERSION = "1.9.5".freeze
2
+ VERSION = "1.9.6".freeze
3
3
  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.9.5
4
+ version: 1.9.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: 2021-12-23 00:00:00.000000000 Z
11
+ date: 2021-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml