-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reorganized the tasks so that rewrite:clear deletes all of the rewrit…
…ten .rb files, rewrite:all rewrites all .rr files, and rewrite:prepare now does both. This garbage collects .rb files that are orphaned.
- Loading branch information
Showing
2 changed files
with
18 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
namespace :rewrite do | ||
|
||
desc "prepare for deployment by rewriting all .rr fils to .rb files" | ||
task :prepare => :environment do | ||
desc "rewrite all .rr files to .rb files" | ||
task :all => :environment do | ||
`find #{RAILS_ROOT} -name "*.rr"`.each do |rr_path| | ||
RewriteRails.rewrite_file(rr_path.strip) | ||
end | ||
end | ||
|
||
desc "clear all cached .rb files" | ||
task :clear => :environment do | ||
rewritten_folder = File.expand_path(RewriteRails.cache_folder_name()) | ||
if rewritten_folder != File.expand_path(RAILS_ROOT) | ||
`find #{rewritten_folder} -name "*.rb"`.each do |rb_path| | ||
File.delete(rb_path.strip) | ||
end | ||
else | ||
raise "You cannot clear cached files if you are rewriting to the rails root: you will delete all .rb files as well" | ||
end | ||
end | ||
|
||
desc "prepare for deployment by rewriting all .rr files to .rb files" | ||
task :prepare => [:clear, :all] | ||
|
||
end |