Rubocop tweaks
This commit is contained in:
parent
4be3fcfd31
commit
c87e2e026e
9 changed files with 22 additions and 26 deletions
|
@ -31,7 +31,7 @@ HashSyntax:
|
|||
EnforcedStyle: ruby19
|
||||
SpaceAroundEqualsInParameterDefault:
|
||||
EnforcedStyle: no_space
|
||||
Blocks:
|
||||
BlockDelimiters:
|
||||
Enabled: false
|
||||
PerlBackrefs:
|
||||
Enabled: false
|
||||
|
|
|
@ -75,7 +75,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
|
|||
# Render through the Rack interface so middleware and mounted apps get a shot
|
||||
response = @rack_client.get(URI.escape(resource.destination_path),
|
||||
'bypass_inline_url_rewriter_asset_hash' => 'true'
|
||||
)
|
||||
)
|
||||
|
||||
raise "#{resource.path} should be in the sitemap!" unless response.status == 200
|
||||
|
||||
|
|
|
@ -152,8 +152,8 @@ class Middleman::Extensions::Lorem < ::Middleman::Extension
|
|||
color = options[:color]
|
||||
|
||||
if options[:random_color]
|
||||
background_color = hex.shuffle[0...6].join
|
||||
color = hex.shuffle[0...6].join
|
||||
background_color = hex.sample(6).join
|
||||
color = hex.sample(6).join
|
||||
end
|
||||
|
||||
src << "/#{background_color.sub(/^#/, '')}" if background_color
|
||||
|
|
|
@ -89,6 +89,7 @@ module Middleman
|
|||
File.fnmatch(value, validator)
|
||||
else
|
||||
# If some unknown thing, don't ignore
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -74,7 +74,7 @@ module Middleman
|
|||
locals: md.delete(:locals) || {},
|
||||
page: md.delete(:data) || {},
|
||||
options: md
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -63,7 +63,7 @@ module Middleman
|
|||
url = ::Middleman::Util.url_for(@store.app, @request_path,
|
||||
relative: false,
|
||||
find_resource: true
|
||||
)
|
||||
)
|
||||
|
||||
if output
|
||||
output.call(path, url)
|
||||
|
|
|
@ -14,6 +14,8 @@ module Middleman
|
|||
extend Forwardable
|
||||
include Contracts
|
||||
|
||||
Matcher = Or[Regexp, RespondTo[:call]]
|
||||
|
||||
# A reference to the current app.
|
||||
Contract IsA['Middleman::Application']
|
||||
attr_reader :app
|
||||
|
@ -246,28 +248,24 @@ module Middleman
|
|||
# Backwards compatible change handler.
|
||||
#
|
||||
# @param [nil,Regexp] matcher A Regexp to match the change path against
|
||||
# Contract Maybe[Regexp] => Any
|
||||
Contract Maybe[Matcher] => Any
|
||||
def changed(matcher=nil, &block)
|
||||
on_change :source do |updated, _removed|
|
||||
updated.select { |f|
|
||||
matcher.nil? ? true : matches?(matcher, f)
|
||||
}.each do |f|
|
||||
block.call(f[:relative_path])
|
||||
end
|
||||
updated
|
||||
.select { |f| matcher.nil? ? true : matches?(matcher, f) }
|
||||
.each { |f| block.call(f[:relative_path]) }
|
||||
end
|
||||
end
|
||||
|
||||
# Backwards compatible delete handler.
|
||||
#
|
||||
# @param [nil,Regexp] matcher A Regexp to match the change path against
|
||||
# Contract Maybe[Regexp] => Any
|
||||
Contract Maybe[Matcher] => Any
|
||||
def deleted(matcher=nil, &block)
|
||||
on_change :source do |_updated, removed|
|
||||
removed.select { |f|
|
||||
matcher.nil? ? true : matches?(matcher, f)
|
||||
}.each do |f|
|
||||
block.call(f[:relative_path])
|
||||
end
|
||||
removed
|
||||
.select { |f| matcher.nil? ? true : matches?(matcher, f) }
|
||||
.each { |f| block.call(f[:relative_path]) }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -287,7 +285,7 @@ module Middleman
|
|||
# @param [Regexp, #call] validator The match validator.
|
||||
# @param [Middleman::SourceFile] file The file to check.
|
||||
# @return [Boolean]
|
||||
Contract Or[Regexp, RespondTo[:call]], SourceFile => Bool
|
||||
Contract Matcher, SourceFile => Bool
|
||||
def matches?(validator, file)
|
||||
path = file[:relative_path]
|
||||
if validator.is_a? Regexp
|
||||
|
|
|
@ -252,7 +252,7 @@ module Middleman
|
|||
|
||||
Contract Pathname => Pathname
|
||||
def strip_extensions(p)
|
||||
p = p.sub_ext('') while ::Tilt[p.to_s] || p.extname === '.html'
|
||||
p = p.sub_ext('') while ::Tilt[p.to_s] || p.extname == '.html'
|
||||
Pathname(p.to_s + '.*')
|
||||
end
|
||||
|
||||
|
@ -262,9 +262,9 @@ module Middleman
|
|||
# @return [Boolean]
|
||||
Contract IsA['Middleman::SourceFile'] => Bool
|
||||
def valid?(file)
|
||||
globally_valid = @validator.call(file) && !globally_ignored?(file)
|
||||
return false unless @validator.call(file) && !globally_ignored?(file)
|
||||
|
||||
globally_valid && if @only.empty?
|
||||
if @only.empty?
|
||||
!@ignored.call(file)
|
||||
else
|
||||
@only.any? { |reg| reg.match(file[:relative_path].to_s) }
|
||||
|
|
|
@ -87,13 +87,11 @@ module Middleman
|
|||
end
|
||||
end
|
||||
|
||||
def method_missing(key, *args)
|
||||
def method_missing(key, *_args)
|
||||
if key?(key.to_sym)
|
||||
self[key.to_sym]
|
||||
elsif key?(key.to_s)
|
||||
self[key.to_s]
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -131,7 +129,6 @@ module Middleman
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
# Normalize a path to not include a leading slash
|
||||
# @param [String] path
|
||||
# @return [String]
|
||||
|
|
Loading…
Reference in a new issue