From 8989e27769c94a20647bec2e2959c040b5c8ce47 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Mon, 16 Jun 2014 09:05:24 -0700 Subject: [PATCH] Rubocop auto fix --- .../core_extensions/default_helpers.rb | 2 +- .../middleman-core/extensions/asset_hash.rb | 20 ++++++++-------- .../middleman-core/extensions/asset_host.rb | 14 +++++------ .../middleman-core/extensions/cache_buster.rb | 14 +++++------ .../extensions/relative_assets.rb | 12 +++++----- .../middleware/inline_url_rewriter.rb | 4 ++-- .../renderers/sass_functions.rb | 23 +++++++++---------- .../lib/middleman-core/renderers/slim.rb | 2 +- .../sitemap/extensions/traversal.rb | 2 +- middleman-core/lib/middleman-core/util.rb | 4 ++-- 10 files changed, 48 insertions(+), 49 deletions(-) diff --git a/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb b/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb index 0388f7f7..99120528 100644 --- a/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb +++ b/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb @@ -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 diff --git a/middleman-core/lib/middleman-core/extensions/asset_hash.rb b/middleman-core/lib/middleman-core/extensions/asset_hash.rb index ab8f4fac..1fd9426d 100644 --- a/middleman-core/lib/middleman-core/extensions/asset_hash.rb +++ b/middleman-core/lib/middleman-core/extensions/asset_hash.rb @@ -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 diff --git a/middleman-core/lib/middleman-core/extensions/asset_host.rb b/middleman-core/lib/middleman-core/extensions/asset_host.rb index 9a872b5d..ff687895 100644 --- a/middleman-core/lib/middleman-core/extensions/asset_host.rb +++ b/middleman-core/lib/middleman-core/extensions/asset_host.rb @@ -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 diff --git a/middleman-core/lib/middleman-core/extensions/cache_buster.rb b/middleman-core/lib/middleman-core/extensions/cache_buster.rb index b6ffd1d9..f1d22610 100644 --- a/middleman-core/lib/middleman-core/extensions/cache_buster.rb +++ b/middleman-core/lib/middleman-core/extensions/cache_buster.rb @@ -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 diff --git a/middleman-core/lib/middleman-core/extensions/relative_assets.rb b/middleman-core/lib/middleman-core/extensions/relative_assets.rb index 474f914a..f8666924 100644 --- a/middleman-core/lib/middleman-core/extensions/relative_assets.rb +++ b/middleman-core/lib/middleman-core/extensions/relative_assets.rb @@ -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) diff --git a/middleman-core/lib/middleman-core/middleware/inline_url_rewriter.rb b/middleman-core/lib/middleman-core/middleware/inline_url_rewriter.rb index d0fbc115..88142b4a 100644 --- a/middleman-core/lib/middleman-core/middleware/inline_url_rewriter.rb +++ b/middleman-core/lib/middleman-core/middleware/inline_url_rewriter.rb @@ -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)) diff --git a/middleman-core/lib/middleman-core/renderers/sass_functions.rb b/middleman-core/lib/middleman-core/renderers/sass_functions.rb index e7d955ac..90583aee 100644 --- a/middleman-core/lib/middleman-core/renderers/sass_functions.rb +++ b/middleman-core/lib/middleman-core/renderers/sass_functions.rb @@ -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 diff --git a/middleman-core/lib/middleman-core/renderers/slim.rb b/middleman-core/lib/middleman-core/renderers/slim.rb index 46ecaa08..d3ec7541 100644 --- a/middleman-core/lib/middleman-core/renderers/slim.rb +++ b/middleman-core/lib/middleman-core/renderers/slim.rb @@ -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! diff --git a/middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb b/middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb index fe0dfb55..3b409765 100644 --- a/middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb +++ b/middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb @@ -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 diff --git a/middleman-core/lib/middleman-core/util.rb b/middleman-core/lib/middleman-core/util.rb index 80800ac2..6e65e818 100644 --- a/middleman-core/lib/middleman-core/util.rb +++ b/middleman-core/lib/middleman-core/util.rb @@ -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