metanorma-ietf 2.2.9 → 2.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ module IsoDoc::Ietf
2
2
  class RfcConvert < ::IsoDoc::Convert
3
3
  def common_rfc_pis(node)
4
4
  rfc_pis = {
5
- artworkdelimiter: node&.at(ns("//pi/artworkdelimiter"))&.text,
5
+ artworkdelimiter: node&.at(ns("//pi/artworkdelimiter"))&.text,
6
6
  artworklines: node&.at(ns("//pi/artworklines"))&.text,
7
7
  authorship: node&.at(ns("//pi/authorship"))&.text,
8
8
  autobreaks: node&.at(ns("//pi/autobreaks"))&.text,
@@ -53,30 +53,32 @@ module IsoDoc::Ietf
53
53
 
54
54
  def rfc_attributes(docxml)
55
55
  t = Time.now.getutc
56
- obs = xpath_comma(docxml.xpath(ns(
57
- "//bibdata/relation[@type = 'obsoletes']/bibitem/docidentifier")))
58
- upd = xpath_comma(docxml.xpath(ns(
59
- "//bibdata/relation[@type = 'updates']/bibitem/docidentifier")))
56
+ obs = xpath_comma(docxml
57
+ .xpath(ns("//bibdata/relation[@type = 'obsoletes']/bibitem/docidentifier")))
58
+ upd = xpath_comma(docxml
59
+ .xpath(ns("//bibdata/relation[@type = 'updates']/bibitem/docidentifier")))
60
60
  {
61
- docName: @meta.get[:doctype] == "Internet Draft" ? @meta.get[:docnumber] : nil,
62
- number: @meta.get[:doctype].casecmp?("rfc") ? @meta.get[:docnumber] : nil,
63
- category: series2category(
64
- docxml&.at(ns("//bibdata/series[@type = 'intended']/title"))&.text),
65
- ipr: docxml&.at(ns("//bibdata/ext/ipr"))&.text,
66
- consensus: docxml&.at(ns("//bibdata/ext/consensus"))&.text,
67
- obsoletes: obs,
68
- updates: upd,
69
- indexInclude: docxml&.at(ns("//bibdata/ext/indexInclude"))&.text,
70
- iprExtract: docxml&.at(ns("//bibdata/ext/iprExtract"))&.text,
71
- sortRefs: docxml&.at(ns("//bibdata/ext/sortRefs"))&.text,
72
- symRefs: docxml&.at(ns("//bibdata/ext/symRefs"))&.text,
73
- tocInclude: docxml&.at(ns("//bibdata/ext/tocInclude"))&.text,
74
- tocDepth: docxml&.at(ns("//bibdata/ext/tocDepth"))&.text,
61
+ docName: @meta.get[:doctype] == "Internet Draft" ? @meta.get[:docnumber] : nil,
62
+ number: @meta.get[:doctype].casecmp?("rfc") ? @meta.get[:docnumber] : nil,
63
+ category: series2category(
64
+ docxml&.at(ns("//bibdata/series[@type = 'intended']/title"))&.text,
65
+ ),
66
+ ipr: docxml&.at(ns("//bibdata/ext/ipr"))&.text,
67
+ consensus: docxml&.at(ns("//bibdata/ext/consensus"))&.text,
68
+ obsoletes: obs,
69
+ updates: upd,
70
+ indexInclude: docxml&.at(ns("//bibdata/ext/indexInclude"))&.text,
71
+ iprExtract: docxml&.at(ns("//bibdata/ext/iprExtract"))&.text,
72
+ sortRefs: docxml&.at(ns("//bibdata/ext/sortRefs"))&.text,
73
+ symRefs: docxml&.at(ns("//bibdata/ext/symRefs"))&.text,
74
+ tocInclude: docxml&.at(ns("//bibdata/ext/tocInclude"))&.text,
75
+ tocDepth: docxml&.at(ns("//bibdata/ext/tocDepth"))&.text,
75
76
  submissionType: docxml&.at(ns(
76
- "//bibdata/series[@type = 'stream']/title"))&.text || "IETF",
77
- 'xml:lang': docxml&.at(ns("//bibdata/language"))&.text,
78
- version: "3",
79
- 'xmlns:xi': "http://www.w3.org/2001/XInclude",
77
+ "//bibdata/series[@type = 'stream']/title",
78
+ ))&.text || "IETF",
79
+ 'xml:lang': docxml&.at(ns("//bibdata/language"))&.text,
80
+ version: "3",
81
+ 'xmlns:xi': "http://www.w3.org/2001/XInclude",
80
82
  }
81
83
  end
82
84
 
@@ -86,7 +88,7 @@ module IsoDoc::Ietf
86
88
  when "informational", "info" then "info"
87
89
  when "experimental", "exp" then "exp"
88
90
  when "bcp" then "bcp"
89
- when "fyi", "info" then "info"
91
+ when "fyi" then "info"
90
92
  when "full-standard" then "std"
91
93
  when "historic" then "historic"
92
94
  else
@@ -96,17 +98,19 @@ module IsoDoc::Ietf
96
98
 
97
99
  def xpath_comma(xpath)
98
100
  return nil if xpath.empty?
99
- xpath.map { |x| x.text }.join(", ")
101
+
102
+ xpath.map(&:text).join(", ")
100
103
  end
101
104
 
102
105
  def make_link(out, isoxml)
103
- links = isoxml.xpath(ns(
104
- "//bibdata/relation[@type = 'includedIn' or @type = 'describedBy' or "\
105
- "@type = 'derivedFrom' or @type = 'instance']")) || return
106
- links.each do |l|
107
- out.link **{ href: l&.at(ns("./bibitem/docidentifier"))&.text,
108
- rel: rel2iana(l["type"]) }
109
- end
106
+ links = isoxml
107
+ .xpath(ns("//bibdata/relation[@type = 'includedIn' or "\
108
+ "@type = 'describedBy' or @type = 'derivedFrom' or "\
109
+ "@type = 'instance']")) || return
110
+ links.each do |l|
111
+ out.link **{ href: l&.at(ns("./bibitem/docidentifier"))&.text,
112
+ rel: rel2iana(l["type"]) }
113
+ end
110
114
  end
111
115
 
112
116
  def rel2iana(type)
@@ -115,7 +119,7 @@ module IsoDoc::Ietf
115
119
  when "describedBy" then "describedby"
116
120
  when "derivedFrom" then "convertedfrom"
117
121
  when "instance" then "alternate"
118
- else
122
+ else
119
123
  "alternate"
120
124
  end
121
125
  end
@@ -133,17 +137,21 @@ module IsoDoc::Ietf
133
137
  end
134
138
  end
135
139
 
136
- def clause_parse_title(node, div, c1, out, _heading_attrs = {})
137
- return unless c1
140
+ def clause_parse_title(_node, div, clause, _out, _heading_attrs = {})
141
+ return unless clause
142
+
138
143
  div.name do |n|
139
- c1&.children&.each { |c2| parse(c2, n) }
144
+ clause&.children&.each { |c2| parse(c2, n) }
140
145
  end
141
146
  end
142
147
 
143
148
  def clause_parse(node, out)
144
149
  return if node.at(ns(".//references"))
145
- out.section **attr_code( anchor: node["id"], numbered: node["numbered"],
146
- removeInRFC: node["removeInRFC"], toc: node["toc"]) do |div|
150
+
151
+ out.section **attr_code(
152
+ anchor: node["id"], numbered: node["numbered"],
153
+ removeInRFC: node["removeInRFC"], toc: node["toc"]
154
+ ) do |div|
147
155
  clause_parse_title(node, div, node.at(ns("./title")), out)
148
156
  node.children.reject { |c1| c1.name == "title" }.each do |c1|
149
157
  parse(c1, div)
@@ -152,11 +160,12 @@ module IsoDoc::Ietf
152
160
  end
153
161
 
154
162
  def clause(isoxml, out)
155
- isoxml.xpath("//xmlns:preface/child::*[not(name() = 'abstract' or name() = 'foreword')] "\
163
+ isoxml.xpath("//xmlns:preface/child::*"\
164
+ "[not(name() = 'abstract' or name() = 'foreword')] "\
156
165
  "| //xmlns:sections/child::*").each do |c|
157
- #cdup = c.dup
158
- #cdup.xpath(ns(".//references")).each { |r| r.remove }
159
- #cdup.at("./*[local-name() != 'title'][normalize-space(text()) != '']") or next
166
+ # cdup = c.dup
167
+ # cdup.xpath(ns(".//references")).each { |r| r.remove }
168
+ # cdup.at("./*[local-name() != 'title'][normalize-space(text()) != '']") or next
160
169
  clause_parse(c, out)
161
170
  end
162
171
  end
@@ -1,11 +1,14 @@
1
1
  require "metanorma/processor"
2
2
  require "tempfile"
3
3
 
4
+ require "isodoc/ietf/rfc_convert"
5
+
4
6
  module Metanorma
5
7
  module Ietf
6
- class Processor < Metanorma::Processor
8
+ RfcConvert = ::IsoDoc::Ietf::RfcConvert
7
9
 
8
- def initialize
10
+ class Processor < Metanorma::Processor
11
+ def initialize # rubocop:disable Lint/MissingSuper
9
12
  @short = :ietf
10
13
  @input_format = :asciidoc
11
14
  @asciidoctor_backend = :ietf
@@ -18,7 +21,7 @@ module Metanorma
18
21
  rfc: "rfc.xml",
19
22
  html: "html",
20
23
  txt: "txt",
21
- pdf: "pdf"
24
+ pdf: "pdf",
22
25
  }
23
26
  end
24
27
 
@@ -26,15 +29,15 @@ module Metanorma
26
29
  "Metanorma::Ietf #{::Metanorma::Ietf::VERSION}"
27
30
  end
28
31
 
29
- def extract_options(isodocxml)
32
+ def extract_options(_isodocxml)
30
33
  {}
31
34
  end
32
35
 
33
36
  # From mislav: https://stackoverflow.com/questions/2108727
34
37
  # /which-in-ruby-checking-if-program-exists-in-path-from-ruby
35
38
  def which(cmd)
36
- exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
37
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
39
+ exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
40
+ ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
38
41
  exts.each do |ext|
39
42
  exe = File.join(path, "#{cmd}#{ext}")
40
43
  return exe if File.executable?(exe) && !File.directory?(exe)
@@ -43,49 +46,43 @@ module Metanorma
43
46
  nil
44
47
  end
45
48
 
46
- def use_presentation_xml(ext)
49
+ def use_presentation_xml(_ext)
47
50
  false
48
51
  end
49
52
 
50
- def xml2rfc_present?
51
- !which("xml2rfc").nil?
53
+ def check_xml2rfc_present?(format)
54
+ if which("xml2rfc").nil?
55
+ raise "[metanorma-ietf] Fatal: unable to generate #{format}," \
56
+ " the command `xml2rfc` is not found in path."
57
+ end
52
58
  end
53
59
 
54
- def output(isodoc_node, inname, outname, format, options={})
60
+ def output(isodoc_node, inname, outname, format, options = {})
55
61
  case format
56
62
  when :rfc
57
63
  outname ||= inname.sub(/\.xml$/, ".rfc.xml")
58
- IsoDoc::Ietf::RfcConvert.new(options).convert(inname, isodoc_node, nil, outname)
64
+ RfcConvert.new(options).convert(inname, isodoc_node, nil, outname)
59
65
  @done_rfc = true
60
-
61
66
  when :txt, :pdf, :html
62
- unless xml2rfc_present?
63
- warn "[metanorma-ietf] Error: unable to generate #{format}, the command `xml2rfc` is not found in path."
64
- return
65
- end
67
+ xml2rfc(isodoc_node, inname, outname, format, options)
68
+ else
69
+ super
70
+ end
71
+ end
66
72
 
67
- rfcname = inname.sub(/\.xml$/, ".rfc.xml")
68
- unless @done_rfc && File.exist?(rfcname)
69
- output(isodoc_node, inname, rfcname, :rfc, options)
70
- end
73
+ def xml2rfc(isodoc_node, inname, outname, format, options)
74
+ check_xml2rfc_present?(format)
71
75
 
72
- outext = case format
73
- when :txt then ".txt"
74
- when :pdf then ".pdf"
75
- when :html then ".html"
76
- end
76
+ rfcname = inname.sub(/\.xml$/, ".rfc.xml")
77
+ unless @done_rfc && File.exist?(rfcname)
78
+ output(isodoc_node, inname, rfcname, :rfc, options)
79
+ end
77
80
 
78
- outflag = case format
79
- when :txt then "--text"
80
- when :pdf then "--pdf"
81
- when :html then "--html"
82
- end
81
+ outext = { txt: ".txt", pdf: ".pdf", html: ".html" }[format]
82
+ outflag = { txt: "--text", pdf: "--pdf", html: "--html" }[format]
83
83
 
84
- outname ||= inname.sub(/\.xml$/, outext)
85
- system("xml2rfc #{outflag} #{rfcname} -o #{outname}")
86
- else
87
- super
88
- end
84
+ outname ||= inname.sub(/\.xml$/, outext)
85
+ system("xml2rfc #{outflag} #{rfcname} -o #{outname}")
89
86
  end
90
87
  end
91
88
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ietf
3
- VERSION = "2.2.9".freeze
3
+ VERSION = "2.3.3".freeze
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- lib = File.expand_path("../lib", __FILE__)
3
+ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require "metanorma/ietf/version"
6
6
 
@@ -35,18 +35,19 @@ Gem::Specification.new do |spec|
35
35
  spec.require_paths = ["lib"]
36
36
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
37
37
 
38
- spec.add_dependency "metanorma-standoc", "~> 1.8.0"
39
- spec.add_dependency "isodoc", "~> 1.5.0"
38
+ spec.add_dependency "isodoc", "~> 1.6.0"
40
39
  spec.add_dependency "mathml2asciimath"
41
- spec.add_dependency "nokogiri", "~> 1.10.4"
40
+ spec.add_dependency "metanorma-standoc", "~> 1.9.0"
41
+ spec.add_dependency "nokogiri", "~> 1.11.6"
42
+ spec.add_dependency "open-uri"
42
43
 
43
44
  spec.add_development_dependency "byebug"
44
45
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
45
46
  spec.add_development_dependency "guard", "~> 2.14"
46
47
  spec.add_development_dependency "guard-rspec", "~> 4.7"
47
- spec.add_development_dependency "rake", "~> 12.0"
48
+ spec.add_development_dependency "rake", "~> 13.0"
48
49
  spec.add_development_dependency "rspec", "~> 3.6"
49
- spec.add_development_dependency "rubocop", "~> 0.50"
50
+ spec.add_development_dependency "rubocop", "~> 1.5.2"
50
51
  spec.add_development_dependency "simplecov", "~> 0.15"
51
52
  spec.add_development_dependency "timecop", "~> 0.9"
52
53
  spec.add_development_dependency "vcr", "~> 5.0.0"
metadata CHANGED
@@ -1,71 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ietf
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.9
4
+ version: 2.3.3
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-02-22 00:00:00.000000000 Z
11
+ date: 2021-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: metanorma-standoc
14
+ name: isodoc
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.8.0
19
+ version: 1.6.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.8.0
26
+ version: 1.6.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: isodoc
28
+ name: mathml2asciimath
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.5.0
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 1.5.0
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: mathml2asciimath
42
+ name: metanorma-standoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 1.9.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 1.9.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: nokogiri
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.10.4
61
+ version: 1.11.6
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.10.4
68
+ version: 1.11.6
69
+ - !ruby/object:Gem::Dependency
70
+ name: open-uri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: byebug
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +142,14 @@ dependencies:
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: '12.0'
145
+ version: '13.0'
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: '12.0'
152
+ version: '13.0'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: rspec
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +170,14 @@ dependencies:
156
170
  requirements:
157
171
  - - "~>"
158
172
  - !ruby/object:Gem::Version
159
- version: '0.50'
173
+ version: 1.5.2
160
174
  type: :development
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
178
  - - "~>"
165
179
  - !ruby/object:Gem::Version
166
- version: '0.50'
180
+ version: 1.5.2
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: simplecov
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -242,8 +256,6 @@ files:
242
256
  - ".hound.yml"
243
257
  - ".oss-guides.rubocop.yml"
244
258
  - ".rspec"
245
- - ".rubocop.ribose.yml"
246
- - ".rubocop.tb.yml"
247
259
  - ".rubocop.yml"
248
260
  - CODE_OF_CONDUCT.md
249
261
  - Gemfile