]> projects.mako.cc - selectricity-live/blob - vendor/plugins/sitealizer/lib/tasks/sitealizer.rake
minor changes to the election show page, still having trouble figuring out how to...
[selectricity-live] / vendor / plugins / sitealizer / lib / tasks / sitealizer.rake
1 namespace :sitealizer do
2   desc "Removes the old 'sitemeter' and import the stored stats to Sitealizer"
3   task :remove_sitemeter => :environment do
4     ActiveRecord::Schema.drop_table('sitealizer') if SiteTracker.count == 0
5     if ActiveRecord::Schema.tables.include?('sitemeter') && !ActiveRecord::Schema.tables.include?('sitealizer')
6       ActiveRecord::Schema.rename_table('sitemeter','sitealizer')
7       puts "Sitealizer => Completed renaming table from 'sitemeter' to 'sitealizer'" 
8     end
9     ['/public/images/sitemeter','/vendor/plugins/sitemeter'].each do |path|
10       if File.exists?(RAILS_ROOT + path)
11         FileUtils.rm_rf(RAILS_ROOT + path)
12         puts "Sitealizer => Completed removing 'sitemeter' files from " + path 
13       end
14     end
15   end
16   
17   desc "Updates Sitealizer to the latest version"
18   task :update do
19     $verbose = false
20     `svn --version` rescue nil
21     unless !$?.nil? && $?.success?
22       $stderr.puts "ERROR: Must have subversion (svn) available in the PATH to update your Sitealizer plugin"
23       exit 1
24     end
25     FileUtils.rm_rf(RAILS_ROOT+"vendor/plugins/sitealizer")
26     system("svn export http://opensvn.csie.org/sitealizer vendor/plugins/sitealizer")
27     system("ruby vendor/plugins/sitealizer/install.rb")
28   end
29   
30   desc "Removes the Sitealizer plugin"
31   task :uninstall => :environment do
32     ActiveRecord::Schema.drop_table('sitealizer') if ActiveRecord::Schema.tables.include?('sitealizer')
33     FileUtils.rm_rf(RAILS_ROOT+'/vendor/plugins/sitemeter') if File.exists?(RAILS_ROOT+'/vendor/plugins/sitemeter')
34     puts "Sitealizer => plugin uninstalled\n\n"
35   end
36 end

Benjamin Mako Hill || Want to submit a patch?