From 397ccd2c1ea09cd10224ec44cfd7cd2351d7088b Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sat, 6 Apr 2013 14:48:00 -0700 Subject: [PATCH] Fix a bunch of Ruby warnings, including a bug in the not_found method --- middleman-core/lib/middleman-core/cli.rb | 4 ++-- .../lib/middleman-core/core_extensions/front_matter.rb | 2 +- .../lib/middleman-core/core_extensions/rendering.rb | 6 +++--- .../lib/middleman-core/core_extensions/request.rb | 2 +- .../lib/middleman-core/core_extensions/routing.rb | 4 ++-- middleman-core/lib/middleman-core/preview_server.rb | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/middleman-core/lib/middleman-core/cli.rb b/middleman-core/lib/middleman-core/cli.rb index 0c1df0c9..fe85fc77 100644 --- a/middleman-core/lib/middleman-core/cli.rb +++ b/middleman-core/lib/middleman-core/cli.rb @@ -39,8 +39,8 @@ module Middleman klass.start(["-h", task].compact, :shell => self.shell) else list = [] - Thor::Util.thor_classes_in(Middleman::Cli).each do |klass| - list += klass.printable_tasks(false) + Thor::Util.thor_classes_in(Middleman::Cli).each do |thor_class| + list += thor_class.printable_tasks(false) end list.sort!{ |a,b| a[0] <=> b[0] } diff --git a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb index 25210333..9a0b3c44 100644 --- a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb +++ b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb @@ -149,7 +149,7 @@ module Middleman::CoreExtensions elsif result = parse_json_front_matter(content) data, content = result end - rescue => e + rescue # Probably a binary file, move on end end diff --git a/middleman-core/lib/middleman-core/core_extensions/rendering.rb b/middleman-core/lib/middleman-core/core_extensions/rendering.rb index 2b155c7b..77fae43f 100644 --- a/middleman-core/lib/middleman-core/core_extensions/rendering.rb +++ b/middleman-core/lib/middleman-core/core_extensions/rendering.rb @@ -150,7 +150,7 @@ module Middleman opts[:template_body] = content if content content = render_individual_file(path, locs, opts, context) path = File.basename(path, File.extname(path)) - rescue LocalJumpError => e + rescue LocalJumpError raise "Tried to render a layout (calls yield) at #{path} like it was a template. Non-default layouts need to be in #{source}/layouts." end end @@ -298,9 +298,9 @@ module Middleman # Find all the engines which handle this extension in tilt. Look for # config variables of that name and merge it extension_class = ::Tilt[ext] - ::Tilt.mappings.each do |ext, engines| + ::Tilt.mappings.each do |mapping_ext, engines| next unless engines.include? extension_class - engine_options = config[ext.to_sym] || {} + engine_options = config[mapping_ext.to_sym] || {} options.merge!(engine_options) end diff --git a/middleman-core/lib/middleman-core/core_extensions/request.rb b/middleman-core/lib/middleman-core/core_extensions/request.rb index a8bc3a36..f4126b7c 100644 --- a/middleman-core/lib/middleman-core/core_extensions/request.rb +++ b/middleman-core/lib/middleman-core/core_extensions/request.rb @@ -288,7 +288,7 @@ module Middleman # Halt request and return 404 def not_found(res, path) - res.status == 404 + res.status = 404 res.write "

File Not Found

#{path}

" res.finish end diff --git a/middleman-core/lib/middleman-core/core_extensions/routing.rb b/middleman-core/lib/middleman-core/core_extensions/routing.rb index ba5c7e7b..d0bf6c6d 100644 --- a/middleman-core/lib/middleman-core/core_extensions/routing.rb +++ b/middleman-core/lib/middleman-core/core_extensions/routing.rb @@ -54,7 +54,7 @@ module Middleman if url.is_a?(Regexp) || url.include?("*") # Use the metadata loop for matching against paths at runtime - sitemap.provides_metadata_for_path url do |url| + sitemap.provides_metadata_for_path(url) do |_| { :options => opts, :blocks => blocks } end @@ -77,7 +77,7 @@ module Middleman end # Setup a metadata matcher for rendering those options - sitemap.provides_metadata_for_path url do |url| + sitemap.provides_metadata_for_path(url) do |_| { :options => opts, :blocks => blocks } end end diff --git a/middleman-core/lib/middleman-core/preview_server.rb b/middleman-core/lib/middleman-core/preview_server.rb index f75888a8..fa35983d 100644 --- a/middleman-core/lib/middleman-core/preview_server.rb +++ b/middleman-core/lib/middleman-core/preview_server.rb @@ -149,7 +149,7 @@ module Middleman begin ::WEBrick::HTTPServer.new(http_opts) - rescue Errno::EADDRINUSE => e + rescue Errno::EADDRINUSE logger.error "== Port #{port} is unavailable. Either close the instance of Middleman already running on #{port} or start this Middleman on a new port with: --port=#{port.to_i+1}" exit(1) end