Permalink
Browse files

nuke task improvements

* nuke now assumes singular inflection for model files of given name
* fixtures are nuked as well
* now nuking test/unit/helpers tests along with the model
* list of deleted files now prints to command line
* removed usage of 'git rm' as unecessary & dnw w/files untracked by git

Signed-off-by: Brian Hogan / New Auburn Personal Computer Services <bphogan@gmail.com>
  • Loading branch information...
1 parent 6e4057a commit b5ad6834f8b947a21a9b6d936fd0f58bcba02386 @csmosx csmosx committed with Jul 29, 2009
Showing with 16 additions and 19 deletions.
  1. +16 −19 tasks/nuke.rake
View
@@ -5,7 +5,7 @@ namespace :nuke do
root = t.name.gsub("nuke:", "").split(/:/)
type = root[0]
- file = root[1].underscore
+ file = root[1].classify.tableize
puts "Nuking #{type} named #{file}"
@@ -30,40 +30,37 @@ namespace :nuke do
end
def nuke_view(f)
- remove "app/views/#{f}"
- remove "spec/views/#{f}"
-
+ remove "app/views/#{f}"
+ remove "spec/views/#{f}"
end
def nuke_model(f)
- remove "app/models/#{f}.rb"
- remove "spec/models/#{f}_spec.rb"
- remove "test/unit/#{f}_test.rb"
+ s = f.singularize
+ remove "app/models/#{s}.rb"
+ remove "spec/models/#{s}_spec.rb"
+ remove "test/unit/#{s}_test.rb"
+ remove "test/fixtures/#{f}.yaml" #plural
+ remove "test/unit/helpers/#{f}_helper_test.rb" #plural
end
def nuke_helper(f)
remove "app/helpers/#{f}_helper.rb"
remove "spec/helpers/#{f}_helper_spec.rb"
-
end
+
def nuke_controller(f)
remove "app/controllers/#{f}_controller.rb"
remove "spec/controllers/#{f}_controller_spec.rb"
remove "test/functional/#{f}_controller_test.rb"
end
def remove(file)
- scm = if File.exist?(".svn")
- "svn rm"
- elsif File.exist?(".git")
- "git rm -r --ignore-unmatch"
- else
- ""
- end
-
+ return unless File.exist?(file)
+
+ scm = File.exist?(".svn") ? "svn rm" : ""
rm_cmd = scm.blank? ? "rm -rf" : "#{scm}"
- puts `#{rm_cmd} #{file}`
+ puts 'delete '.rjust(12) + file
+ `#{rm_cmd} #{file}`
end
-
-end
+end

0 comments on commit b5ad683

Please sign in to comment.