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'"
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
17 desc "Updates Sitealizer to the latest version"
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"
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")
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"