Sha256: b285a53359afe0bc74c767fb703b7339e4dd5bd6a212ce36c62788ab474fc871

Contents?: true

Size: 688 Bytes

Versions: 3

Compression:

Stored size: 688 Bytes

Contents

require 'fileutils'
require 'pathname'

class Combustion::Databases::SQLite < Combustion::Databases::Base
  private

  def create
    if exists?
      $stderr.puts "#{config['database']} already exists"
      return
    end

    establish_connection configuration
    connection
  rescue Exception => error
    $stderr.puts error, *(error.backtrace)
    $stderr.puts "Couldn't create database for #{configuration.inspect}"
  end

  def drop
    FileUtils.rm_f file if exists?
  end

  def exists?
    File.exist? file
  end

  def file
    @file ||= path.absolute? ? path.to_s : File.join(Rails.root, path)
  end

  def path
    @path ||= Pathname.new configuration['database']
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
combustion-0.7.0 lib/combustion/databases/sqlite.rb
combustion-0.6.0 lib/combustion/databases/sqlite.rb
combustion-0.5.5 lib/combustion/databases/sqlite.rb