Sha256: cd3bf00380338edfee51409ed85b38fc8a692652a3fde5f9e663e358865d5665

Contents?: true

Size: 689 Bytes

Versions: 2

Compression:

Stored size: 689 Bytes

Contents

require 'rubygems'
require 'activerecord'

module Sweeetsie
  class << self
    def boot(enviornment)
      ActiveRecord::Base.establish_connection(db[environment])

      ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), 'log', "#{environment}.log"))

      Dir[File.join(%W|#{File.dirname(__FILE__)} models ** *.rb |)].each {|r| load r}
    end

    def migrations
      File.join(File.dirname(__FILE__), 'db', 'migrate')
    end

    def db
      YAML::load(File.read(File.join(File.dirname(__FILE__), 'database.yml')))
    end

    def up!(version=nil)
      ActiveRecord::Migration.migrate migrations, version
    end

    def down!
      up!
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sweetsie-0.0.2 templates/project/initialize.rb
sweetsie-0.0.1 templates/project/initialize.rb