Sha256: 0f0567ea3262aa721f1b516d5a4bff804c470700e9440561e8e712a0ae3f9cf2

Contents?: true

Size: 1009 Bytes

Versions: 3

Compression:

Stored size: 1009 Bytes

Contents

require File.expand_path("#{File.dirname(__FILE__)}/../active_wrapper")

module ActiveWrapper
  class Tasks
    
    def initialize(options={}, &block)
      
      task :environment do
        $db, $log = ActiveWrapper.setup(options)
        yield if block
      end
      
      namespace :db do
        desc "Create the database"
        task :create do
          $db.create_db
        end
        
        desc "Drop the database"
        task :drop do
          $db.drop_db
        end
        
        desc "Migrate the database with optional VERSION"
        task :migrate => :environment do
          $db.migrate(ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
        end
        
        desc "Generate a migration with given NAME"
        task :migration => :environment do
          $db.generate_migration(ENV['NAME'])
        end
      end
      
      namespace :log do
        desc "Clear all logs"
        task :clear => :environment do
          $log.clear
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
winton-active_wrapper-0.1.7 lib/active_wrapper/tasks.rb
winton-active_wrapper-0.1.8 lib/active_wrapper/tasks.rb
winton-active_wrapper-0.1.9 lib/active_wrapper/tasks.rb