module MockleyCrew

Constants

VERSION

Attributes

configuration[W]

Public Class Methods

activated?() click to toggle source
# File lib/mockley_crew.rb, line 74
def self.activated?
  ActiveRecord::Base.connection.instance_variable_get(:@config)[:database].split("/")[0..-2].join("/") == configuration.database_files_path.gsub(/\/$/, "")
end
active_record_path() click to toggle source
# File lib/mockley_crew.rb, line 60
def self.active_record_path
  (`gem which active_record`).split("/")[0..-2].join("/")
end
configuration() click to toggle source
# File lib/mockley_crew.rb, line 24
def self.configuration
  @configuration ||= Configuration.new
end
configure() { |configuration| ... } click to toggle source
# File lib/mockley_crew.rb, line 32
def self.configure
  yield(configuration)
  if configuration.heroku?
    set_sqlite3
  end
end
hack_active_record() click to toggle source
# File lib/mockley_crew.rb, line 47
def self.hack_active_record
  file_path = active_record_path + "/active_record/connection_adapters/sqlite3_adapter.rb"
  file_contents = File.read(file_path)
  new_contents = file_contents.gsub(/gem \"sqlite3\".*$/, "")
   write_to_file(file_path, new_contents)
   require 'active_record/connection_adapters/sqlite3_adapter'
  write_to_file(file_path, file_contents)
end
load_active_record_sqlite3_adapter() click to toggle source
# File lib/mockley_crew.rb, line 56
def self.load_active_record_sqlite3_adapter
  require 'active_record/connection_adapters/sqlite3_adapter'
end
reset_configuration() click to toggle source
# File lib/mockley_crew.rb, line 28
def self.reset_configuration
  @configuration = Configuration.new
end
root() click to toggle source
# File lib/mockley_crew.rb, line 70
def self.root
  File.expand_path '../..', __FILE__
end
set_sqlite3() click to toggle source
# File lib/mockley_crew.rb, line 39
def self.set_sqlite3
  return if defined?(SQLite3)

  $: << "#{Rails.root}/vendor/gems/sqlite3/gems/sqlite3-1.3.13/lib/"
  require 'sqlite3'
  hack_active_record
end
write_to_file(file, contents) click to toggle source
# File lib/mockley_crew.rb, line 64
def self.write_to_file file, contents
  File.open(file, "w+") do |f|
    f.write(contents)
  end
end