Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cleaned up rake task a little

  • Loading branch information...
commit c4003a925edb5f35e889ff259250dd1d5e8da55d 1 parent 582be57
Ryan Heath authored
Showing with 6 additions and 8 deletions.
  1. +6 −8 tasks/form_assistant_tasks.rake
14 tasks/form_assistant_tasks.rake
View
@@ -1,20 +1,18 @@
-desc "provides example field partials (with and without errors) to app/views/forms"
+desc "copies basic form templates to app/views/forms"
namespace :form_assistant do
task :install do
- RAILS_ROOT = Object.const_defined?(:Rails) && Rails.respond_to?(:root) ? Rails.root : RAILS_ROOT
PLUGIN_ROOT = File.join(File.dirname(__FILE__), '..')
- VIEW_PATH = File.join(RAILS_ROOT, 'app', 'views')
- DESTINATION = File.join(VIEW_PATH, 'forms')
-
+ DESTINATION = File.join(Rails.root, 'app/views', 'forms')
+
FileUtils.mkpath(DESTINATION) unless File.directory?(DESTINATION)
forms = Dir[File.join(PLUGIN_ROOT, 'forms/*')].select { |f| File.file?(f) }
longest_filename = forms.inject([]) { |sizes, f| sizes << f.gsub(PLUGIN_ROOT, '').length }.max
forms.each do |partial|
file_to_copy = File.join(DESTINATION, '/', File.basename(partial))
- puts " - form_assistant%-#{longest_filename}s copied to %s" %
- [partial.gsub(PLUGIN_ROOT, ''), DESTINATION.gsub(RAILS_ROOT, '')]
- FileUtils.cp [partial], DESTINATION
+ puts " - form_assistant%-#{longest_filename}s copied to %s" %
+ [partial.gsub(PLUGIN_ROOT, ''), DESTINATION.gsub(Rails.root, '')]
+ FileUtils.cp [partial], DESTINATION
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.