lib/nanoc/base/compilation/compiler_dsl.rb in nanoc-3.7.3 vs lib/nanoc/base/compilation/compiler_dsl.rb in nanoc-3.7.4
- old
+ new
@@ -149,11 +149,11 @@
#
# @example Using custom filter arguments for a layout
#
# layout '/custom/', :haml, :format => :html5
def layout(identifier, filter_name, params = {})
- @rules_collection.layout_filter_mapping[identifier_to_regex(identifier)] = [ filter_name, params ]
+ @rules_collection.layout_filter_mapping[identifier_to_regex(identifier)] = [filter_name, params]
end
# Creates a pair of compilation and routing rules that indicate that the
# specified item(s) should be copied to the output folder as-is. The items
# are selected using an identifier, which may either be a string
@@ -245,27 +245,27 @@
# 'rules/content.rb'
#
# include_rules 'rules/assets'
# include_rules 'rules/content'
def include_rules(name)
- filename = [ "#{name}", "#{name}.rb", "./#{name}", "./#{name}.rb" ].find { |f| File.file?(f) }
+ filename = ["#{name}", "#{name}.rb", "./#{name}", "./#{name}.rb"].find { |f| File.file?(f) }
raise Nanoc::Errors::NoRulesFileFound.new if filename.nil?
@rules_collection.parse(filename)
end
- private
+ private
# Converts the given identifier, which can contain the '*' or '+'
# wildcard characters, matching zero or more resp. one or more
# characters, to a regex. For example, 'foo/*/bar' is transformed
# into /^foo\/(.*?)\/bar$/ and 'foo+' is transformed into /^foo(.+?)/.
def identifier_to_regex(identifier)
if identifier.is_a? String
# Add leading/trailing slashes if necessary
new_identifier = identifier.dup
new_identifier[/^/] = '/' if identifier[0, 1] != '/'
- new_identifier[/$/] = '/' unless [ '*', '/' ].include?(identifier[-1, 1])
+ new_identifier[/$/] = '/' unless ['*', '/'].include?(identifier[-1, 1])
/^#{new_identifier.gsub('*', '(.*?)').gsub('+', '(.+?)')}$/
else
identifier
end