lib/asciidoctor/abstract_node.rb in asciidoctor-2.0.15 vs lib/asciidoctor/abstract_node.rb in asciidoctor-2.0.16
- old
+ new
@@ -2,11 +2,12 @@
module Asciidoctor
# Public: An abstract base class that provides state and methods for managing a
# node of AsciiDoc content. The state and methods on this class are common to
# all content segments in an AsciiDoc document.
class AbstractNode
- include Substitutors, Logging
+ include Logging
+ include Substitutors
# Public: Get the Hash of attributes for this node
attr_reader :attributes
# Public: Get the Symbol context for this node
@@ -63,11 +64,11 @@
# Public: Associate this Block with a new parent Block
#
# parent - The Block to set as the parent of this Block
#
- # Returns the value of the parent argument
+ # Returns the the specified Block parent
def parent= parent
@parent, @document = parent, parent.document
end
# Public: Get the value of the specified attribute. If the attribute is not found on this node, fallback_name is set,
@@ -153,11 +154,11 @@
#
# This method sets the specified option on this node by setting the <name>-option attribute.
#
# name - the String name of the option
#
- # Returns Nothing
+ # Returns nothing
def set_option name
@attributes[%(#{name}-option)] = ''
nil
end
@@ -218,11 +219,11 @@
# Public: Sets the value of the role attribute on this node.
#
# names - A single role name, a space-separated String of role names, or an Array of role names
#
- # Returns the value of the names argument
+ # Returns the specified String role name or Array of role names
def role= names
@attributes['role'] = (::Array === names) ? (names.join ' ') : names
end
# Public: Adds the given role directly to this node.
@@ -460,12 +461,12 @@
start = ::File.join doc.base_dir, start unless doc.path_resolver.root? start
else
start = doc.base_dir
end
else
- start = doc.base_dir unless start
- jail = doc.base_dir unless jail
+ start ||= doc.base_dir
+ jail ||= doc.base_dir
end
doc.path_resolver.system_path target, start, jail, opts
end
# Public: Normalize the web path using the PathResolver.
@@ -540,11 +541,11 @@
contents = ::OpenURI.open_uri(target, URI_READ_MODE) {|f| f.read }
end
rescue
logger.warn %(could not retrieve contents of #{opts[:label] || 'asset'} at URI: #{target}) if opts.fetch :warn_on_failure, true
end
- else
- logger.warn %(cannot retrieve contents of #{opts[:label] || 'asset'} at URI: #{target} (allow-uri-read attribute not enabled)) if opts.fetch :warn_on_failure, true
+ elsif opts.fetch :warn_on_failure, true
+ logger.warn %(cannot retrieve contents of #{opts[:label] || 'asset'} at URI: #{target} (allow-uri-read attribute not enabled))
end
else
target = normalize_system_path target, opts[:start], nil, target_name: (opts[:label] || 'asset')
contents = read_asset target, normalize: opts[:normalize], warn_on_failure: (opts.fetch :warn_on_failure, true), label: opts[:label]
end