Major update of Selectricity to work with Rails 2.2.2 from 1.2!
[selectricity-live] / lib / tasks / rails.rake
diff --git a/lib/tasks/rails.rake b/lib/tasks/rails.rake
new file mode 100644 (file)
index 0000000..99d3321
--- /dev/null
@@ -0,0 +1,32 @@
+desc "Checks your app and gently warns you if you are using deprecated code." 
+task :deprecated => :environment do
+  deprecated = {
+    '@params'    => 'Use params[] instead',
+    '@session'   => 'Use session[] instead',
+    '@flash'     => 'Use flash[] instead',
+    '@request'   => 'Use request[] instead',
+    '@env' => 'Use env[] instead',
+    'find_all'   => 'Use find(:all) instead',
+    'find_first' => 'Use find(:first) instead',
+    'render_partial' => 'Use render :partial instead',
+    'component'  => 'Use of components are frowned upon',
+    'paginate'   => 'The default paginator is slow. Writing your own may be faster',
+    'start_form_tag'   => 'Use form_for instead',
+    'end_form_tag'   => 'Use form_for instead',
+    ':post => true'   => 'Use :method => :post instead'
+  }
+
+  deprecated.each do |key, warning|
+    puts '--> ' + key
+    output = `cd '#{File.expand_path('app', RAILS_ROOT)}' && grep -n --exclude=*.svn* -r '#{key}' *`
+    unless output =~ /^$/
+      puts "  !! " + warning + " !!" 
+      puts '  ' + '.' * (warning.length + 6)
+      puts output
+    else
+      puts "  Clean! Cheers for you!" 
+    end
+    puts
+  end
+end
+

Benjamin Mako Hill || Want to submit a patch?