$:.push("#{File.dirname(__FILE__)}")
require 'evm_application'

namespace :evm do
  desc "Start the ManageIQ EVM Application"
  task :start => ["db:verify_local", :environment] do
    EvmApplication.start
  end

  desc "Restart the ManageIQ EVM Application"
  task :restart => ["db:verify_local", :environment] do
    EvmApplication.stop
    EvmApplication.start
  end

  desc "Stop the ManageIQ EVM Application"
  task :stop => :environment do
    EvmApplication.stop
  end

  desc "Kill the ManageIQ EVM Application"
  task :kill => :environment do
    EvmApplication.kill
  end

  desc "Report Status of the ManageIQ EVM Application"
  task :status => :environment do
    EvmApplication.status
  end

  task :update_start do
    EvmApplication.update_start
  end

  task :update_stop => :environment do
    EvmApplication.update_stop
  end

  task :compile_assets do
    ENV["DATABASE_URL"] ||= "postgresql://user:pass@127.0.0.1/dbname"
    Rake::Task["assets:clean"].invoke
    Rake::Task["assets:precompile"].invoke
  end
end

$:.push("#{File.dirname(__FILE__)}")
require 'evm_application'

namespace :evm do
  desc "Start the ManageIQ EVM Application"
  task :start => ["db:verify_local", :environment] do
    EvmApplication.start
  end

  desc "Restart the ManageIQ EVM Application"
  task :restart => ["db:verify_local", :environment] do
    EvmApplication.stop
    EvmApplication.start
  end

  desc "Stop the ManageIQ EVM Application"
  task :stop => :environment do
    EvmApplication.stop
  end

  desc "Kill the ManageIQ EVM Application"
  task :kill => :environment do
    EvmApplication.kill
  end

  desc "Report Status of the ManageIQ EVM Application"
  task :status => :environment do
    EvmApplication.status
  end

  task :update_start do
    EvmApplication.update_start
  end

  task :update_stop => :environment do
    EvmApplication.update_stop
  end

  task :compile_assets do
    ENV["DATABASE_URL"] ||= "postgresql://user:pass@127.0.0.1/dbname"
    Rake::Task["assets:clobber"].invoke
    Rake::Task["assets:precompile"].invoke
  end
end

Use assets:clobber to remove assets before precompile.
Use assets:clobber to remove assets before precompile.

We're not concerned with doing rolling deploys so let's just blow away the public/assets directory before precompile.

From: http://edgeguides.rubyonrails.org/command_line.html

"You can precompile the assets in app/assets using rake assets:precompile, and remove older compiled assets using rake assets:clean. The assets:clean task allows for rolling deploys that may still be linking to an old asset while the new assets are being built.

If you want to clear public/assets completely, you can use rake assets:clobber."
