forked from osmocom/wireshark
docbook: rewrite some ruby code according to RuboCop suggestions.
Change-Id: I2d1ea982c1622dbc29f927ee168b552b46e39faa Reviewed-on: https://code.wireshark.org/review/28399 Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
57c108570f
commit
52bcc40d5e
|
@ -22,21 +22,18 @@ class CommaizeBlock < Extensions::BlockProcessor
|
|||
# XXX What's the difference between text, raw, simple, verbatim, etc?
|
||||
parse_content_as :simple
|
||||
|
||||
def process parent, reader, attrs
|
||||
def process(parent, reader, attrs)
|
||||
lines = reader.lines
|
||||
sort = attrs.fetch('sort', 'true') == 'true'
|
||||
|
||||
lines.reject { |line| line.empty? }
|
||||
lines = lines.collect(&:strip)
|
||||
|
||||
if sort
|
||||
lines = lines.sort_by { |line| line.downcase }
|
||||
end
|
||||
lines = lines.reject(&:empty?)
|
||||
lines = lines.map(&:strip)
|
||||
lines = lines.sort_by(&:downcase) if sort
|
||||
|
||||
if lines.length < 2
|
||||
create_paragraph parent, lines, attrs
|
||||
elsif lines.length == 2
|
||||
create_paragraph parent, (lines.join(" and ")), attrs
|
||||
create_paragraph parent, lines.join(" and "), attrs
|
||||
else
|
||||
commaized = lines[0..-2].join(", ")
|
||||
commaized << ", and " + lines[-1]
|
||||
|
|
|
@ -14,7 +14,7 @@ class CVEIdLinkInlineMacro < Extensions::InlineMacroProcessor
|
|||
|
||||
named :cveidlink
|
||||
|
||||
def process parent, cvenum, attrs
|
||||
def process(parent, cvenum, _attrs)
|
||||
cvename = "CVE-#{cvenum}"
|
||||
suffix = ''
|
||||
target = %(https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-#{cvenum})
|
||||
|
|
|
@ -17,12 +17,8 @@ class WSBugLinkInlineMacro < Extensions::InlineMacroProcessor
|
|||
parse_content_as :text
|
||||
name_positional_attributes 'bugtext'
|
||||
|
||||
def process parent, bugnum, attrs
|
||||
bugtext = if (attrs['bugtext'])
|
||||
attrs['bugtext']
|
||||
else
|
||||
%(Bug #{bugnum})
|
||||
end
|
||||
def process(parent, bugnum, attrs)
|
||||
bugtext = attrs['bugtext'] || %(Bug #{bugnum})
|
||||
target = %(https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=#{bugnum})
|
||||
if parent.document.basebackend? 'html'
|
||||
parent.document.register :links, target
|
||||
|
|
|
@ -14,7 +14,7 @@ class WSSALinkInlineMacro < Extensions::InlineMacroProcessor
|
|||
|
||||
named :'wssalink'
|
||||
|
||||
def process parent, sanum, attrs
|
||||
def process(parent, sanum, attrs)
|
||||
satext = "wnpa-sec-#{sanum}"
|
||||
target = %(https://www.wireshark.org/security/wnpa-sec-#{sanum})
|
||||
if parent.document.basebackend? 'html'
|
||||
|
|
Loading…
Reference in New Issue