Rubocop auto fix

This commit is contained in:
Thomas Reynolds 2014-06-16 09:05:24 -07:00
parent c6543b7c27
commit 8989e27769
10 changed files with 48 additions and 49 deletions

View file

@ -170,7 +170,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
# @param [String] path The path (such as "photo.jpg") # @param [String] path The path (such as "photo.jpg")
# @param [String] prefix The type prefix (such as "images") # @param [String] prefix The type prefix (such as "images")
# @return [String] The fully qualified asset url # @return [String] The fully qualified asset url
def asset_url(path, prefix='', options={}) def asset_url(_path, prefix='', options={})
::Middleman::Util.asset_url(app, prefix, options) ::Middleman::Util.asset_url(app, prefix, options)
end end

View file

@ -18,15 +18,15 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
@ignore = Array(options.ignore) + [/^apple-touch-icon/] @ignore = Array(options.ignore) + [/^apple-touch-icon/]
app.use ::Middleman::Middleware::InlineURLRewriter, app.use ::Middleman::Middleware::InlineURLRewriter,
:id => :asset_hash, id: :asset_hash,
:url_extensions => options.exts, url_extensions: options.exts,
:source_extensions => %w(.htm .html .php .css .js), source_extensions: %w(.htm .html .php .css .js),
:ignore => @ignore, ignore: @ignore,
:middleman_app => app, middleman_app: app,
:proc => method(:rewrite_url) proc: method(:rewrite_url)
end end
def rewrite_url(asset_path, dirpath, request_path) def rewrite_url(asset_path, dirpath, _request_path)
relative_path = Pathname.new(asset_path).relative? relative_path = Pathname.new(asset_path).relative?
full_asset_path = if relative_path full_asset_path = if relative_path
@ -68,9 +68,9 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
return if resource.ignored? return if resource.ignored?
# Render through the Rack interface so middleware and mounted apps get a shot # Render through the Rack interface so middleware and mounted apps get a shot
response = @rack_client.get(URI.escape(resource.destination_path), { response = @rack_client.get(URI.escape(resource.destination_path),
'bypass_inline_url_rewriter_asset_hash' => 'true' 'bypass_inline_url_rewriter_asset_hash' => 'true'
}) )
raise "#{resource.path} should be in the sitemap!" unless response.status == 200 raise "#{resource.path} should be in the sitemap!" unless response.status == 200

View file

@ -8,15 +8,15 @@ class Middleman::Extensions::AssetHost < ::Middleman::Extension
def after_configuration def after_configuration
app.use ::Middleman::Middleware::InlineURLRewriter, app.use ::Middleman::Middleware::InlineURLRewriter,
:id => :asset_host, id: :asset_host,
:url_extensions => options.exts, url_extensions: options.exts,
:source_extensions => options.sources, source_extensions: options.sources,
:ignore => options.ignore, ignore: options.ignore,
:middleman_app => app, middleman_app: app,
:proc => method(:rewrite_url) proc: method(:rewrite_url)
end end
def rewrite_url(asset_path, dirpath, request_path) def rewrite_url(asset_path, dirpath, _request_path)
relative_path = Pathname.new(asset_path).relative? relative_path = Pathname.new(asset_path).relative?
full_asset_path = if relative_path full_asset_path = if relative_path

View file

@ -12,15 +12,15 @@ class Middleman::Extensions::CacheBuster < ::Middleman::Extension
def after_configuration def after_configuration
app.use ::Middleman::Middleware::InlineURLRewriter, app.use ::Middleman::Middleware::InlineURLRewriter,
:id => :cache_buster, id: :cache_buster,
:url_extensions => options.exts, url_extensions: options.exts,
:source_extensions => options.sources, source_extensions: options.sources,
:ignore => options.ignore, ignore: options.ignore,
:middleman_app => app, middleman_app: app,
:proc => method(:rewrite_url) proc: method(:rewrite_url)
end end
def rewrite_url(asset_path, dirpath, request_path) def rewrite_url(asset_path, _dirpath, _request_path)
asset_path + '?' + Time.now.strftime('%s') asset_path + '?' + Time.now.strftime('%s')
end end
end end

View file

@ -12,12 +12,12 @@ class Middleman::Extensions::RelativeAssets < ::Middleman::Extension
def after_configuration def after_configuration
app.use ::Middleman::Middleware::InlineURLRewriter, app.use ::Middleman::Middleware::InlineURLRewriter,
:id => :asset_hash, id: :asset_hash,
:url_extensions => options.exts, url_extensions: options.exts,
:source_extensions => options.sources, source_extensions: options.sources,
:ignore => options.ignore, ignore: options.ignore,
:middleman_app => app, middleman_app: app,
:proc => method(:rewrite_url) proc: method(:rewrite_url)
end end
def rewrite_url(asset_path, dirpath, request_path) def rewrite_url(asset_path, dirpath, request_path)

View file

@ -12,7 +12,7 @@ module Middleman
@uid = options[:id] @uid = options[:id]
@proc = options[:proc] @proc = options[:proc]
raise "InlineURLRewriter requires a :proc to call with inline URL results" unless @proc raise 'InlineURLRewriter requires a :proc to call with inline URL results' unless @proc
@exts = options[:url_extensions] @exts = options[:url_extensions]

View file

@ -1,7 +1,6 @@
module Sprockets module Sprockets
module Sass module Sass
module Functions module Functions
# Using Middleman::Util#asset_path, return the full path # Using Middleman::Util#asset_path, return the full path
# for the given +source+ as a Sass String. This supports keyword # for the given +source+ as a Sass String. This supports keyword
# arguments that mirror the +options+. # arguments that mirror the +options+.
@ -25,7 +24,7 @@ module Sprockets
# background: image-url("image.jpg"); // background: url("/assets/image.jpg"); # background: image-url("image.jpg"); // background: url("/assets/image.jpg");
# background: image-url("image.jpg", $digest: true); // background: url("/assets/image-27a8f1f96afd8d4c67a59eb9447f45bd.jpg"); # background: image-url("image.jpg", $digest: true); // background: url("/assets/image-27a8f1f96afd8d4c67a59eb9447f45bd.jpg");
# #
def image_url(source, options = {}, cache_buster = nil) def image_url(source, options={}, _cache_buster=nil)
# Work with the Compass #image_url API # Work with the Compass #image_url API
if options.respond_to? :value if options.respond_to? :value
case options.value case options.value
@ -102,16 +101,16 @@ module Sass::Script::Functions
defined?(@signatures) && @signatures.delete(method) defined?(@signatures) && @signatures.delete(method)
end end
declare :asset_path, [:source], :var_kwargs => true declare :asset_path, [:source], var_kwargs: true
declare :asset_path, [:source, :kind] declare :asset_path, [:source, :kind]
declare :asset_url, [:source], :var_kwargs => true declare :asset_url, [:source], var_kwargs: true
declare :asset_url, [:source, :kind] declare :asset_url, [:source, :kind]
declare :image_path, [:source], :var_kwargs => true declare :image_path, [:source], var_kwargs: true
declare :image_url, [:source], :var_kwargs => true declare :image_url, [:source], var_kwargs: true
declare :image_url, [:source, :only_path] declare :image_url, [:source, :only_path]
declare :image_url, [:source, :only_path, :cache_buster] declare :image_url, [:source, :only_path, :cache_buster]
declare :font_path, [:source], :var_kwargs => true declare :font_path, [:source], var_kwargs: true
declare :font_url, [:source], :var_kwargs => true declare :font_url, [:source], var_kwargs: true
declare :font_url, [:source, :only_path] declare :font_url, [:source, :only_path]
declare :asset_data_uri, [:source] declare :asset_data_uri, [:source]
end end

View file

@ -33,7 +33,7 @@ module Middleman
app.after_configuration do app.after_configuration do
context_hack = { context_hack = {
context: self.template_context_class.new(self) context: template_context_class.new(self)
} }
::Slim::Embedded::SassEngine.disable_option_validator! ::Slim::Embedded::SassEngine.disable_option_validator!

View file

@ -14,7 +14,7 @@ module Middleman
test_expr = parts.join('\\/') test_expr = parts.join('\\/')
# eponymous reverse-lookup # eponymous reverse-lookup
found = @store.resources.find do |candidate| found = @store.resources.find do |candidate|
candidate.path =~ %r!^#{test_expr}(?:\.[a-zA-Z0-9]+|\/)$! candidate.path =~ %r{^#{test_expr}(?:\.[a-zA-Z0-9]+|\/)$}
end end
if found if found

View file

@ -166,7 +166,7 @@ module Middleman
# @param [String] prefix The type prefix (such as "images") # @param [String] prefix The type prefix (such as "images")
# @param [Hash] options Data to pass through. # @param [Hash] options Data to pass through.
# @return [String] The fully qualified asset url # @return [String] The fully qualified asset url
def asset_url(app, path, prefix='', options={}) def asset_url(app, path, prefix='', _options={})
# Don't touch assets which already have a full path # Don't touch assets which already have a full path
if path.include?('//') or path.start_with?('data:') if path.include?('//') or path.start_with?('data:')
path path
@ -271,7 +271,7 @@ module Middleman
end end
end end
def rewrite_paths(body, path, exts, &block) def rewrite_paths(body, _path, exts, &_block)
body.dup.gsub(/([=\'\"\(]\s*)([^\s\'\"\)]+(#{Regexp.union(exts)}))/) do |match| body.dup.gsub(/([=\'\"\(]\s*)([^\s\'\"\)]+(#{Regexp.union(exts)}))/) do |match|
opening_character = $1 opening_character = $1
asset_path = $2 asset_path = $2