Sha256: 3a970f72304f4487c671f33247476532c8a6d2a21ab2f4c7b8b34f3d342ea7a4

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bivouac-0.1.3 lib/bivouac/template/Rakefile.rb
bivouac-0.1.4 lib/bivouac/template/Rakefile.rb
bivouac-0.1.5 lib/bivouac/template/Rakefile.rb