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] prefix The type prefix (such as "images")
# @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)
end

View file

@ -18,15 +18,15 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
@ignore = Array(options.ignore) + [/^apple-touch-icon/]
app.use ::Middleman::Middleware::InlineURLRewriter,
:id => :asset_hash,
:url_extensions => options.exts,
:source_extensions => %w(.htm .html .php .css .js),
:ignore => @ignore,
:middleman_app => app,
:proc => method(:rewrite_url)
id: :asset_hash,
url_extensions: options.exts,
source_extensions: %w(.htm .html .php .css .js),
ignore: @ignore,
middleman_app: app,
proc: method(:rewrite_url)
end
def rewrite_url(asset_path, dirpath, request_path)
def rewrite_url(asset_path, dirpath, _request_path)
relative_path = Pathname.new(asset_path).relative?
full_asset_path = if relative_path
@ -68,9 +68,9 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
return if resource.ignored?
# 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'
})
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

View file

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

View file

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

View file

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

View file

@ -12,7 +12,7 @@ module Middleman
@uid = options[:id]
@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]
@ -35,7 +35,7 @@ module Middleman
end
path = ::Middleman::Util.full_path(env['PATH_INFO'], @middleman_app)
if path =~ /(^\/$)|(#{@source_exts_regex_text}$)/
if body = ::Middleman::Util.extract_response_text(response)
dirpath = Pathname.new(File.dirname(path))

View file

@ -1,7 +1,6 @@
module Sprockets
module Sass
module Functions
# Using Middleman::Util#asset_path, return the full path
# for the given +source+ as a Sass String. This supports keyword
# arguments that mirror the +options+.
@ -11,7 +10,7 @@ module Sprockets
# background: url(image-path("image.jpg")); // background: url("/assets/image.jpg");
# background: url(image-path("image.jpg", $digest: true)); // background: url("/assets/image-27a8f1f96afd8d4c67a59eb9447f45bd.jpg");
#
def image_path(source, options = {})
def image_path(source, options={})
p = ::Middleman::Util.asset_path(middleman_context, :images, source.value, map_options(options))
::Sass::Script::String.new p.to_s, :string
end
@ -25,7 +24,7 @@ module Sprockets
# background: image-url("image.jpg"); // background: url("/assets/image.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
if options.respond_to? :value
case options.value
@ -47,7 +46,7 @@ module Sprockets
# src: url(font-path("font.ttf")); // src: url("/assets/font.ttf");
# src: url(font-path("font.ttf", $digest: true)); // src: url("/assets/font-27a8f1f96afd8d4c67a59eb9447f45bd.ttf");
#
def font_path(source, options = {})
def font_path(source, options={})
p = ::Middleman::Util.asset_path(middleman_context, :fonts, source.value, map_options(options))
::Sass::Script::String.new p.to_s, :string
end
@ -61,7 +60,7 @@ module Sprockets
# src: font-url("font.ttf"); // src: url("/assets/font.ttf");
# src: font-url("image.jpg", $digest: true); // src: url("/assets/font-27a8f1f96afd8d4c67a59eb9447f45bd.ttf");
#
def font_url(source, options = {})
def font_url(source, options={})
# Work with the Compass #font_url API
if options.respond_to? :value
case options.value
@ -84,7 +83,7 @@ module Sprockets
# Returns an options hash where the keys are symbolized
# and the values are unwrapped Sass literals.
def map_options(options = {}) # :nodoc:
def map_options(options={}) # :nodoc:
::Sass::Util.map_hash(options) do |key, value|
[key.to_sym, value.respond_to?(:value) ? value.value : value]
end
@ -102,16 +101,16 @@ module Sass::Script::Functions
defined?(@signatures) && @signatures.delete(method)
end
declare :asset_path, [:source], :var_kwargs => true
declare :asset_path, [:source], var_kwargs: true
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 :image_path, [:source], :var_kwargs => true
declare :image_url, [:source], :var_kwargs => true
declare :image_path, [:source], var_kwargs: true
declare :image_url, [:source], var_kwargs: true
declare :image_url, [:source, :only_path]
declare :image_url, [:source, :only_path, :cache_buster]
declare :font_path, [:source], :var_kwargs => true
declare :font_url, [:source], :var_kwargs => true
declare :font_path, [:source], var_kwargs: true
declare :font_url, [:source], var_kwargs: true
declare :font_url, [:source, :only_path]
declare :asset_data_uri, [:source]
end

View file

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

View file

@ -14,7 +14,7 @@ module Middleman
test_expr = parts.join('\\/')
# eponymous reverse-lookup
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
if found

View file

@ -166,7 +166,7 @@ module Middleman
# @param [String] prefix The type prefix (such as "images")
# @param [Hash] options Data to pass through.
# @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
if path.include?('//') or path.start_with?('data:')
path
@ -271,7 +271,7 @@ module Middleman
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|
opening_character = $1
asset_path = $2