Removed Hoe code, dependency.
[merb_radiant.git] / lib / tasks / extensions.rake
blob123692506bd2e616af12d6b5f9479e39eeec19a4
1 require 'rake/testtask'
3 namespace :db do
4   namespace :migrate do
5     desc "Run all Radiant extension migrations"
6     task :extensions => :environment do
7       require 'radiant/extension_migrator'
8       MerbRadiant::ExtensionMigrator.migrate_extensions
9     end
10   end
11   namespace :remigrate do
12     desc "Migrate down and back up all Radiant extension migrations"
13     task :extensions => :environment do
14       require 'highline/import'
15       if agree("This task will destroy any data stored by extensions in the database. Are you sure you want to \ncontinue? [yn] ")
16         require 'radiant/extension_migrator'
17         MerbRadiant::Extension.descendants.map(&:migrator).each {|m| m.migrate(0) }
18         Rake::Task['db:migrate:extensions'].invoke
19       end
20     end
21   end
22 end
24 namespace :test do
25   desc "Runs tests on all available Radiant extensions, pass EXT=extension_name to test a single extension"
26   task :extensions => "db:test:prepare" do
27     extension_roots = MerbRadiant::Extension.descendants.map(&:root)
28     if ENV["EXT"]
29       extension_roots = extension_roots.select {|x| /\/(\d+_)?#{ENV["EXT"]}$/ === x }
30       if extension_roots.empty?
31         puts "Sorry, that extension is not installed."
32       end
33     end
34     extension_roots.each do |directory|
35       if File.directory?(File.join(directory, 'test'))
36         chdir directory do
37           if RUBY_PLATFORM =~ /win32/
38             system "rake.cmd test MERB_RADIANT_ENV_FILE=#{RAILS_ROOT}/config/environment"
39           else
40             system "rake test MERB_RADIANT_ENV_FILE=#{RAILS_ROOT}/config/environment"
41           end
42         end
43       end
44     end
45   end
46 end
48 namespace :spec do
49   desc "Runs specs on all available Radiant extensions, pass EXT=extension_name to test a single extension"
50   task :extensions => "db:test:prepare" do
51     extension_roots = MerbRadiant::Extension.descendants.map(&:root)
52     if ENV["EXT"]
53       extension_roots = extension_roots.select {|x| /\/(\d+_)?#{ENV["EXT"]}$/ === x }
54       if extension_roots.empty?
55         puts "Sorry, that extension is not installed."
56       end
57     end
58     extension_roots.each do |directory|
59       if File.directory?(File.join(directory, 'spec'))
60         chdir directory do
61           if RUBY_PLATFORM =~ /win32/
62             system "rake.cmd spec MERB_RADIANT_ENV_FILE=#{RAILS_ROOT}/config/environment"
63           else
64             system "rake spec MERB_RADIANT_ENV_FILE=#{RAILS_ROOT}/config/environment"
65           end
66         end
67       end
68     end
69   end
70 end
72 # Load any custom rakefiles from extensions
73 [Merb.root, MERB_RADIANT_ROOT].uniq.each do |root|
74   Dir[root + '/vendor/extensions/**/tasks/**/*.rake'].sort.each { |ext| load ext }
75 end