Skip to content

Commit

Permalink
Asciidoctor: Drop a few hash rockets (#774)
Browse files Browse the repository at this point in the history
It looks like it is more idiomatic in ruby to avoid hash rockets where
possible. This drops *some* of them.
  • Loading branch information
nik9000 authored Apr 3, 2019
1 parent 7e2cb42 commit 36066e4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
4 changes: 2 additions & 2 deletions resources/asciidoctor/lib/care_admonition/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def initialize(role)

def process(parent, _target, attrs)
Asciidoctor::Block.new(parent, :admonition,
:source => attrs[:passtext],
:attributes => {
source: attrs[:passtext],
attributes: {
'role' => @role,
'name' => 'warning',
'style' => 'warning',
Expand Down
14 changes: 8 additions & 6 deletions resources/asciidoctor/lib/change_admonition/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ def process(parent, _target, attrs)
# We can *almost* go through the standard :admonition conversion but
# that won't render the revisionflag or the revision. So we have to
# go with this funny compound pass thing.
admon = Asciidoctor::Block.new(parent, :pass, :content_model => :compound)
admon = Asciidoctor::Block.new(parent, :pass, content_model: :compound)
admon << Asciidoctor::Block.new(admon, :pass,
:source => "<#{@tag} revisionflag=\"#{@revisionflag}\" revision=\"#{version}\">",
:attributes => { 'revisionflag' => @revisionflag })
attributes: { 'revisionflag' => @revisionflag },
source: "<#{@tag} " \
"revisionflag=\"#{@revisionflag}\" " \
"revision=\"#{version}\">")
admon << Asciidoctor::Block.new(admon, :paragraph,
:source => attrs[:passtext],
:subs => Asciidoctor::Substitutors::NORMAL_SUBS)
admon << Asciidoctor::Block.new(admon, :pass, :source => "</#{@tag}>")
source: attrs[:passtext],
subs: Asciidoctor::Substitutors::NORMAL_SUBS)
admon << Asciidoctor::Block.new(admon, :pass, source: "</#{@tag}>")
end
end

Expand Down
3 changes: 2 additions & 1 deletion resources/asciidoctor/lib/edit_me/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def block.title
edit_urls = @document.attributes['edit_urls']
edit_url = edit_urls.find { |e| path.start_with? e[:toplevel] }
unless edit_url
logger.warn message_with_context "couldn't find edit url for #{path}", :source_location => source_location
logger.warn message_with_context "couldn't find edit url for #{path}",
source_location: source_location
return super
end
url = edit_url[:url]
Expand Down
2 changes: 1 addition & 1 deletion resources/asciidoctor/lib/lang_override/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ class LangOverride < Asciidoctor::Extensions::BlockMacroProcessor
named :lang_override
name_positional_attributes :override
def process(parent, _target, attrs)
Asciidoctor::Block.new(parent, :pass, :source => "// #{attrs[:override]}")
Asciidoctor::Block.new(parent, :pass, source: "// #{attrs[:override]}")
end
end
24 changes: 12 additions & 12 deletions resources/asciidoctor/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ def convert(input, extra_attributes = {}, warnings_matcher = eq(''))
}
attributes.merge! extra_attributes
result = Asciidoctor.convert input,
:safe => :unsafe, # Used to include "funny" files.
:backend => :docbook45,
:logger => logger,
:doctype => :book,
:attributes => attributes,
:sourcemap => true
safe: :unsafe, # Used to include "funny" files.
backend: :docbook45,
logger: logger,
doctype: :book,
attributes: attributes,
sourcemap: true
warnings_string = logger.messages
.map { |l| "#{l[:severity]}: #{l[:message].inspect}" }
.join("\n")
Expand All @@ -56,12 +56,12 @@ def convert(input, extra_attributes = {}, warnings_matcher = eq(''))
}
attributes.merge! convert_attributes if defined?(convert_attributes)
Asciidoctor.convert input,
:safe => :unsafe, # Used to include "funny" files.
:backend => :docbook45,
:logger => convert_logger,
:doctype => :book,
:attributes => attributes,
:sourcemap => true
safe: :unsafe, # Used to include "funny" files.
backend: :docbook45,
logger: convert_logger,
doctype: :book,
attributes: attributes,
sourcemap: true
end
let(:logs) do
convert_logger.messages
Expand Down

0 comments on commit 36066e4

Please sign in to comment.