Sha256: 9c0bdd94f502b4e21db5937f0a22170e243dd01ca2617f8cc018d3e2a3b47bf8

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 KB

Contents

require 'rubygems'
require 'camping'
require 'camping/session'
require 'bivouac'

include Bivouac
ENV['BIVOUAC_ROOT'] = File.expand_path( File.dirname(__FILE__) )

task :environment do
  Camping.goes :<%= @appname %>
  
  # Load models from app/models
  files( 'models' ) { |file| require( file ) }
  
  # Load create
  files( '../db' ) { |file| require( file ) }

  # Load database schema from db/migrate
  files( '../db/migrate' ) { |file| require( file ) }
  
  require "#{ENV['BIVOUAC_ROOT']}/config/environment.rb"
  config = Bivouac::Environment.new( )
  database_connection = config.environment.db
  if database_connection[:adapter] =~ /sqlite/
    database_connection[:database] = ENV['BIVOUAC_ROOT'] + "/" + database_connection[:database]
  end
  <%= @appname %>::Models::Base.establish_connection database_connection
end

namespace :db do
  desc "Migrate the database through scripts in db/migrate."
  task :migrate => :environment do
    if <%= @appname %>.respond_to? :create
      <%= @appname %>.create
    else
      puts "Nothing to do!"
    end
  end
  
  desc "Clear the sessions table"
  namespace :sessions do
    task :clear => :environment do
      session_table = 'session'
      session_table = Inflector.pluralize(session_table) if ActiveRecord::Base.pluralize_table_names
      ActiveRecord::Base.connection.execute "DELETE FROM #{session_table}"
    end
  end
end

namespace :plugin do
  desc "List plugins"
  task :list do
    Dir.glob( filePath( __FILE__, 'plugins/**' ) ).each do |p|
      pn = p.gsub( /.*\//, "" )
      print "  - #{pn} : "
      Rake::Task["plugin:#{pn}:desc"].invoke
    end
  end
  
  Dir.glob( filePath( __FILE__, 'plugins/**/tasks/**.rake' ) ).each { |p| load p }  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bivouac-0.1.6 lib/bivouac/template/Rakefile.rb