2 namespace :merb_mart do
4 desc "Install MerbMart"
5 task :install => [:preflight, :setup_directories, :copy_assets, :migrate]
7 desc "Test for any dependencies"
8 task :preflight do # see slicetasks.rb
11 desc "Setup directories"
12 task :setup_directories do
13 puts "Creating directories for host application"
14 MerbMart.mirrored_components.each do |type|
15 if File.directory?(MerbMart.dir_for(type))
16 if !File.directory?(dst_path = MerbMart.app_dir_for(type))
17 relative_path = dst_path.relative_path_from(Merb.root)
18 puts "- creating directory :#{type} #{File.basename(Merb.root) / relative_path}"
25 desc "Copy stub files to host application"
27 puts "Copying stubs for MerbMart - resolves any collisions"
28 copied, preserved = MerbMart.mirror_stubs!
29 puts "- no files to copy" if copied.empty? && preserved.empty?
30 copied.each { |f| puts "- copied #{f}" }
31 preserved.each { |f| puts "! preserved override as #{f}" }
34 desc "Copy stub files and views to host application"
35 task :patch => [ "stubs", "freeze:views" ]
37 desc "Copy public assets to host application"
39 puts "Copying assets for MerbMart - resolves any collisions"
40 copied, preserved = MerbMart.mirror_public!
41 puts "- no files to copy" if copied.empty? && preserved.empty?
42 copied.each { |f| puts "- copied #{f}" }
43 preserved.each { |f| puts "! preserved override as #{f}" }
46 desc "Migrate the database"
47 task :migrate do # see slicetasks.rb
50 desc "Freeze MerbMart into your app (only merb_mart/app)"
51 task :freeze => [ "freeze:app" ]
55 desc "Freezes MerbMart by installing the gem into application/gems"
57 ENV["GEM"] ||= "merb_mart"
58 Rake::Task['slices:install_as_gem'].invoke
61 desc "Freezes MerbMart by copying all files from merb_mart/app to your application"
63 puts "Copying all merb_mart/app files to your application - resolves any collisions"
64 copied, preserved = MerbMart.mirror_app!
65 puts "- no files to copy" if copied.empty? && preserved.empty?
66 copied.each { |f| puts "- copied #{f}" }
67 preserved.each { |f| puts "! preserved override as #{f}" }
70 desc "Freeze all views into your application for easy modification"
72 puts "Copying all view templates to your application - resolves any collisions"
73 copied, preserved = MerbMart.mirror_files_for :view
74 puts "- no files to copy" if copied.empty? && preserved.empty?
75 copied.each { |f| puts "- copied #{f}" }
76 preserved.each { |f| puts "! preserved override as #{f}" }
79 desc "Freeze all models into your application for easy modification"
81 puts "Copying all models to your application - resolves any collisions"
82 copied, preserved = MerbMart.mirror_files_for :model
83 puts "- no files to copy" if copied.empty? && preserved.empty?
84 copied.each { |f| puts "- copied #{f}" }
85 preserved.each { |f| puts "! preserved override as #{f}" }
88 desc "Freezes MerbMart as a gem and copies over merb_mart/app"
89 task :app_with_gem => [:gem, :app]
91 desc "Freezes MerbMart by unpacking all files into your application"
93 puts "Unpacking MerbMart files to your application - resolves any collisions"
94 copied, preserved = MerbMart.unpack_slice!
95 puts "- no files to copy" if copied.empty? && preserved.empty?
96 copied.each { |f| puts "- copied #{f}" }
97 preserved.each { |f| puts "! preserved override as #{f}" }