From ca963420547b3ab83fe6d2fe351d1eff6e489a18 Mon Sep 17 00:00:00 2001 From: Filip Tepper Date: Thu, 4 Feb 2010 23:09:46 +0800 Subject: [PATCH 1/5] grep skips .svn directories --- lib/application_checker.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/application_checker.rb b/lib/application_checker.rb index 799fe93..c17f1c5 100644 --- a/lib/application_checker.rb +++ b/lib/application_checker.rb @@ -225,9 +225,9 @@ module Rails value = "" # Specifically double quote for finding 'test_help' command = if double_quote - "grep -r \"#{text}\" #{where}" + "grep -r --exclude=\*.svn\* \"#{text}\" #{where}" else - "grep -r '#{text}' #{where}" + "grep -r --exclude=\*.svn\* '#{text}' #{where}" end Open3.popen3(command) do |stdin, stdout, stderr| From 4ce16b80b717875480be8bc9f132c8da7d6ad48d Mon Sep 17 00:00:00 2001 From: Jack Dempsey Date: Thu, 4 Feb 2010 23:27:37 +0800 Subject: [PATCH 2/5] try to only catch conditions when a find is involved --- lib/application_checker.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/application_checker.rb b/lib/application_checker.rb index c17f1c5..aac6a00 100644 --- a/lib/application_checker.rb +++ b/lib/application_checker.rb @@ -23,7 +23,7 @@ module Rails # Check for deprecated ActiveRecord calls def check_ar_methods files = [] - ["find(:all", "find(:first", ":conditions =>", ":joins =>"].each do |v| + ["find(:all", "find(:first", "find.*:conditions =>", ":joins =>"].each do |v| lines = grep_for(v, "app/") files += extract_filenames(lines) || [] end From 035b8168e6cb58b2eaee9037a3a95530b8349450 Mon Sep 17 00:00:00 2001 From: Jack Dempsey Date: Thu, 4 Feb 2010 23:34:56 +0800 Subject: [PATCH 3/5] fix location of tasks to silence deprecation warning --- {tasks => lib/tasks}/rails_upgrade_tasks.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename {tasks => lib/tasks}/rails_upgrade_tasks.rake (97%) diff --git a/tasks/rails_upgrade_tasks.rake b/lib/tasks/rails_upgrade_tasks.rake similarity index 97% rename from tasks/rails_upgrade_tasks.rake rename to lib/tasks/rails_upgrade_tasks.rake index cda6aa1..e9cb01d 100644 --- a/tasks/rails_upgrade_tasks.rake +++ b/lib/tasks/rails_upgrade_tasks.rake @@ -1,4 +1,4 @@ -$:.unshift(File.dirname(__FILE__) + "/../lib") +$:.unshift(File.dirname(__FILE__) + "/../../lib") require 'routes_upgrader' require 'gemfile_generator' require 'application_checker' @@ -72,4 +72,4 @@ namespace :rails do puts end end -end \ No newline at end of file +end From 00a7255a8852b52abacb4c0a176967fd8854a1e1 Mon Sep 17 00:00:00 2001 From: James Conroy-Finn Date: Sat, 6 Feb 2010 00:21:46 +0800 Subject: [PATCH 4/5] ApplicationChecker compatibility and bug fix - Ruby 1.8 returns method names as strings whereas 1.9 returns symbols so remove both within run method. - Wrap culprits in Array to ensure we can enumerate over them. --- lib/application_checker.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/application_checker.rb b/lib/application_checker.rb index aac6a00..094c429 100644 --- a/lib/application_checker.rb +++ b/lib/application_checker.rb @@ -15,7 +15,8 @@ module Rails # Run all the check methods def run - the_methods = (self.public_methods - Object.methods) - ["run", "initialize"] + # Ruby 1.8 returns method names as strings whereas 1.9 uses symbols + the_methods = (self.public_methods - Object.methods) - [:run, :initialize, "run", "initialize"] the_methods.each {|m| send m } end @@ -299,7 +300,7 @@ module Rails puts "More information: #{more_info_url}" puts puts "The culprits: " - culprits.each do |c| + Array(culprits).each do |c| puts "\t- #{c}" end puts @@ -312,7 +313,7 @@ module Rails puts "#{BOLD}More information:#{CLEAR} #{CYAN}#{more_info_url}" puts puts "#{WHITE}The culprits: " - culprits.each do |c| + Array(culprits).each do |c| puts "#{YELLOW}\t- #{c}" end ensure From 0a87d0543041b7c7c09abef864b548ffa2064d5d Mon Sep 17 00:00:00 2001 From: Jesse Storimer Date: Sat, 6 Feb 2010 01:58:55 +0800 Subject: [PATCH 5/5] App::Application.routes => App::Application.routes.draw --- lib/routes_upgrader.rb | 2 +- test/routes_upgrader_test.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/routes_upgrader.rb b/lib/routes_upgrader.rb index 48b9cf9..a3aa263 100644 --- a/lib/routes_upgrader.rb +++ b/lib/routes_upgrader.rb @@ -327,7 +327,7 @@ module Rails r.to_route_code end.join("\n") - "#{app_name.classify}::Application.routes do\n#{@new_code}\nend\n" + "#{app_name.classify}::Application.routes.draw do\n#{@new_code}\nend\n" end private diff --git a/test/routes_upgrader_test.rb b/test/routes_upgrader_test.rb index 7765960..e9b7ca9 100644 --- a/test/routes_upgrader_test.rb +++ b/test/routes_upgrader_test.rb @@ -40,7 +40,7 @@ class RoutesUpgraderTest < ActiveSupport::TestCase end " - new_routes_code = "MyApplication::Application.routes do + new_routes_code = "MyApplication::Application.routes.draw do match '/home' => 'home#index' match '/login' => 'sessions#new', :as => :login resources :hats @@ -101,7 +101,7 @@ end end " - new_routes_code = "MyApplication::Application.routes do + new_routes_code = "MyApplication::Application.routes.draw do match '/' => 'home#index' end " @@ -122,7 +122,7 @@ end end " - new_routes_code = "MyApplication::Application.routes do + new_routes_code = "MyApplication::Application.routes.draw do match '/:controller(/:action(/:id))' end "