Permalink
Browse files

1.2.1 updates - added removal of empty helpers

  • Loading branch information...
1 parent eabdec2 commit fdd84f73bb5e1e932aaccfa3a3e6ea9d1207211b @napcs committed Jan 4, 2011
Showing with 48 additions and 2 deletions.
  1. +4 −0 CHANGES
  2. +26 −2 README.rdoc
  3. +18 −0 tasks/nuke.rake
View
4 CHANGES
@@ -1,3 +1,7 @@
+1.2.1
+ * Added task to remove empty helpers
+ * Added installation steps for Rails 3 and Rails 2
+
1.2.0
* Fixed deprecation warning for activerecord in Rails 2.3
* Changed db:test:clone to db:test:prepare for migrate, up, and down methods.
View
28 README.rdoc
@@ -1,5 +1,5 @@
=LazyDeveloper
-Copyright (C) 2007-2009 Brian P. Hogan and Kevin Gisi
+Copyright (C) 2007-2011 Brian P. Hogan and Kevin Gisi
Developers are lazy. I know I am. If I have to do things over and over, I want
them to be automated. Maybe that's efficient and not lazy. However, lazy is a
@@ -8,6 +8,22 @@ shorter word and it's funnier to call this plugin LazyDeveloper.
This plugin provides some useful Rake tasks that will make your life a little
easier. I use them in many of my projects and I invite you to do the same.
+= Installation
+
+This plugin supports Rails 2 and Rails 3.
+
+== Rails 3 installation
+
+ rails plugin install git@github.com:napcs/lazy_developer.git
+
+== Rails 2 installation
+
+Rails 2 support is in the rails2 branch. Install it like this:
+
+ ruby script/plugin install git@github.com:napcs/lazy_developer.git -r rails2
+
+
+
= Usage
== Databases
@@ -22,7 +38,7 @@ or through the command line.
rake db:migrate:up
rake db:migrate:down
-are all supported. As of version 1.2.0, this task calls rake db:test:prepare whenever invoked.
+are all supported. This task calls rake db:test:prepare whenever invoked.
=== rake db:migrate:compact
Uses schema.rb to construct a brand new clean migration and moves all of your existing migrations out of the way. This might at first seem to violate the spirit of migrations, but honestly sometimes large projects have a LOT of migrations and it can get difficult to manage these files.
@@ -86,6 +102,14 @@ The nuke tasks can be quite granular.
The only thing these tasks won't do is remove migrations, and that's cos I think that's dangerous
+=== Nuking Empty Helpers
+
+When you create controllers, Rails insists on creating a helper to go with them, and most of the time those files are empty. You can get rid of those with
+
+ rake nuke:empty_helpers
+
+It'll take care of the tests for you too.
+
== Subversion
View
18 tasks/nuke.rake
@@ -1,5 +1,6 @@
namespace :nuke do
+
rule /^nuke/ do |t|
Rake::Task['environment'].invoke
@@ -25,6 +26,9 @@ namespace :nuke do
nuke_controller(file)
when "helper", "h"
nuke_helper(file)
+ when "empty_helpers"
+ remove_empty_helpers
+
end
end
@@ -64,4 +68,18 @@ namespace :nuke do
`#{rm_cmd} #{file}`
end
+ def remove_empty_helpers
+ helpers = Dir.chdir("app/helpers"){Dir.glob("*")}
+
+ helpers.each do |helper|
+ helpername = helper.gsub(".rb", "").camelize.constantize
+ unless helpername.instance_methods.any?
+ puts "#{helpername} and its test were removed as the module has no methods."
+ FileUtils.rm "app/helpers/#{helper}"
+ FileUtils.rm "spec/helpers/#{helper.gsub(".rb", "")}_spec.rb" if File.exist?("spec")
+
+ end
+ end
+ end
+
end

0 comments on commit fdd84f7

Please sign in to comment.