Fix a bunch of Ruby warnings, including a bug in the not_found method

This commit is contained in:
Ben Hollis 2013-04-06 14:48:00 -07:00
parent 1d869b0c08
commit 397ccd2c1e
6 changed files with 10 additions and 10 deletions

View file

@ -39,8 +39,8 @@ module Middleman
klass.start(["-h", task].compact, :shell => self.shell) klass.start(["-h", task].compact, :shell => self.shell)
else else
list = [] list = []
Thor::Util.thor_classes_in(Middleman::Cli).each do |klass| Thor::Util.thor_classes_in(Middleman::Cli).each do |thor_class|
list += klass.printable_tasks(false) list += thor_class.printable_tasks(false)
end end
list.sort!{ |a,b| a[0] <=> b[0] } list.sort!{ |a,b| a[0] <=> b[0] }

View file

@ -149,7 +149,7 @@ module Middleman::CoreExtensions
elsif result = parse_json_front_matter(content) elsif result = parse_json_front_matter(content)
data, content = result data, content = result
end end
rescue => e rescue
# Probably a binary file, move on # Probably a binary file, move on
end end
end end

View file

@ -150,7 +150,7 @@ module Middleman
opts[:template_body] = content if content opts[:template_body] = content if content
content = render_individual_file(path, locs, opts, context) content = render_individual_file(path, locs, opts, context)
path = File.basename(path, File.extname(path)) 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." 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
end end
@ -298,9 +298,9 @@ module Middleman
# Find all the engines which handle this extension in tilt. Look for # Find all the engines which handle this extension in tilt. Look for
# config variables of that name and merge it # config variables of that name and merge it
extension_class = ::Tilt[ext] extension_class = ::Tilt[ext]
::Tilt.mappings.each do |ext, engines| ::Tilt.mappings.each do |mapping_ext, engines|
next unless engines.include? extension_class next unless engines.include? extension_class
engine_options = config[ext.to_sym] || {} engine_options = config[mapping_ext.to_sym] || {}
options.merge!(engine_options) options.merge!(engine_options)
end end

View file

@ -288,7 +288,7 @@ module Middleman
# Halt request and return 404 # Halt request and return 404
def not_found(res, path) def not_found(res, path)
res.status == 404 res.status = 404
res.write "<html><body><h1>File Not Found</h1><p>#{path}</p></body>" res.write "<html><body><h1>File Not Found</h1><p>#{path}</p></body>"
res.finish res.finish
end end

View file

@ -54,7 +54,7 @@ module Middleman
if url.is_a?(Regexp) || url.include?("*") if url.is_a?(Regexp) || url.include?("*")
# Use the metadata loop for matching against paths at runtime # 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 } { :options => opts, :blocks => blocks }
end end
@ -77,7 +77,7 @@ module Middleman
end end
# Setup a metadata matcher for rendering those options # 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 } { :options => opts, :blocks => blocks }
end end
end end

View file

@ -149,7 +149,7 @@ module Middleman
begin begin
::WEBrick::HTTPServer.new(http_opts) ::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}" 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) exit(1)
end end