diff options
author | francis <francis> | 2007-10-31 19:48:26 +0000 |
---|---|---|
committer | francis <francis> | 2007-10-31 19:48:26 +0000 |
commit | 28fb182fa965467b73ad0b9bea506de8050305d3 (patch) | |
tree | ada24e870bcbca97addfdd6a065c49a44c091e90 /vendor/plugins/rake_tasks/lib | |
parent | fd677a19af54b1b10aa21c9cdb908ea9a5a40341 (diff) |
Add spec:check as a rake task to show what classes we don't have test for at all. Annoying really that rspec rcov doesn't show this in its report.
Diffstat (limited to 'vendor/plugins/rake_tasks/lib')
-rw-r--r-- | vendor/plugins/rake_tasks/lib/convert.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/vendor/plugins/rake_tasks/lib/convert.rb b/vendor/plugins/rake_tasks/lib/convert.rb new file mode 100644 index 000000000..d74b1be40 --- /dev/null +++ b/vendor/plugins/rake_tasks/lib/convert.rb @@ -0,0 +1,47 @@ +module Convert + # allows different paths for searching to be set + def self.view_path=(path) + @@view_path = path + end + + def self.view_path + @@view_path ||= RAILS_ROOT+'/app/views/' + end + + # Given a file extension will search for all files recursively in a directory + # and move the files using the move command or subversion move command + # + # Example: + # + # Convert::Mover.find(:rhtml).each do |rhtml| + # rhtml.move :erb, :scm => :svn + # end + # + # This will find all .rhtml files within the views directory and move each file + # to a erb extension using subversion + class Mover + + def self.find(file_extension) + files = File.join(Convert::view_path,'**', "*.#{file_extension}") + Dir.glob(files).collect do |path| + self.new(path, file_extension) + end + end + + def initialize(file_path, file_extension) + @file_path = file_path + @file_extension = file_extension + end + + def move_command(move_to_extension, options = {}) + original_path = File.expand_path(@file_path) + new_path = original_path.gsub(".#{@file_extension}", ".#{move_to_extension}") + + "#{options[:scm]} mv #{original_path} #{new_path}".lstrip + end + + def move(move_to_extension, options = {}) + system self.move_command(move_to_extension, options) + end + end +end
\ No newline at end of file |