From 3d400ed03acffda1396202953ba57a197c16a244 Mon Sep 17 00:00:00 2001 From: Seth Thomas Rasmussen Date: Mon, 1 Feb 2010 22:07:54 -0500 Subject: [PATCH 1/4] fix gemfile generator, a joint effort of loincloth and bakineggs --- lib/gemfile_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gemfile_generator.rb b/lib/gemfile_generator.rb index 0798d8b..72dc8f6 100644 --- a/lib/gemfile_generator.rb +++ b/lib/gemfile_generator.rb @@ -66,7 +66,7 @@ git "git://github.com/rails/rack.git" gem "rails", "3.0.pre" STR - preamble + "\n" + generate_upgraded_code + preamble + generate_upgraded_code end # Get Gemfile call for all the gems From 49df0bb77a7d3c2a081df0aa919a938656d4fef5 Mon Sep 17 00:00:00 2001 From: Seth Thomas Rasmussen Date: Mon, 1 Feb 2010 23:47:44 -0500 Subject: [PATCH 2/4] failing test --- test/application_checker_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/application_checker_test.rb b/test/application_checker_test.rb index cbab14a..34bb2d5 100644 --- a/test/application_checker_test.rb +++ b/test/application_checker_test.rb @@ -119,6 +119,13 @@ class ApplicationCheckerTest < ActiveSupport::TestCase assert @checker.alerts.has_key?("Known broken plugins") end + def test_ignoring_comments + make_file("config/", "routes.rb", "# map.connect 'fail'") + @checker.check_routes + + assert !@checker.alerts.has_key?("Old router API") + end + def teardown clear_files From 685d28e6e44f20c6a5b7a567a7b99dfb2ce6c289 Mon Sep 17 00:00:00 2001 From: Seth Thomas Rasmussen Date: Tue, 2 Feb 2010 16:10:53 -0500 Subject: [PATCH 3/4] no, you don't --- lib/application_checker.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/application_checker.rb b/lib/application_checker.rb index e058702..140be5b 100644 --- a/lib/application_checker.rb +++ b/lib/application_checker.rb @@ -231,9 +231,10 @@ module Rails def extract_filenames_from_grep(output) return nil if output.empty? - # I hate rescue nil as much as the next guy but I have a reason here at least... fnames = output.split("\n").map do |fn| - fn.match(/^(.+?):/)[1] rescue nil + if m = fn.match(/^(.+?):/) + m[1] + end end.compact fnames.uniq From 8ea7166feba4e8a32ba1b9b7e4ee4970aaf42c66 Mon Sep 17 00:00:00 2001 From: Seth Thomas Rasmussen Date: Thu, 4 Feb 2010 22:21:58 -0500 Subject: [PATCH 4/4] ignore comments --- lib/application_checker.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/application_checker.rb b/lib/application_checker.rb index 140be5b..a768756 100644 --- a/lib/application_checker.rb +++ b/lib/application_checker.rb @@ -185,11 +185,16 @@ module Rails # If they're on Windows, they probably don't have grep. @probably_has_grep ||= (Config::CONFIG['host_os'].downcase =~ /mswin|windows|mingw/).nil? - if @probably_has_grep + lines = if @probably_has_grep find_with_grep(text, base_path + where) else find_with_rak(text, base_path + where) end + + # ignore comments + lines.gsub! /^\s*#.+$/m, "" + + lines end # Sets a base path for finding files; mostly for testing