Sha256: 768432e188d209acc01b1e42e7d473594162c6b7b5e228afa2aefa3c2d4b9766

Contents?: true

Size: 721 Bytes

Versions: 2

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true

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 StandardError => 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

2 entries across 2 versions & 1 rubygems

Version Path
combustion-0.9.0 lib/combustion/databases/sqlite.rb
combustion-0.8.0 lib/combustion/databases/sqlite.rb