module Fakecrm

dynamic_require 'fakecrm/resource' dynamic_require 'fakecrm/initialize'

workaround circular reference

workaround circular reference

Constants

Configuration
VERSION

Public Class Methods

embedded!() click to toggle source
# File lib/fakecrm/embedded.rb, line 2
def self.embedded!
  require 'fakecrm/configuration'

  port = 4000 + rand(10000)
  url  = "http://localhost:#{port}/crm"

  if defined?(Infopark::Crm)
    Infopark::Crm.configure do |configuration|
      configuration.url = url
      configuration.login = "root"
      configuration.api_key = "deadbeef"
    end
  end

  pid = fork do
    require 'fakecrm'
    Fakecrm::Configuration.port = port
    Fakecrm::Configuration.database = 'sqlite::memory:'
    Fakecrm::Configuration.silent = true
    self.run!
    exit!
  end
  sleep(1)
  at_exit do
    begin
      Process.kill("INT", pid)
      Process.wait(pid)
    rescue Errno::ESRCH, Errno::ECHILD
    end
  end

  return [port, pid]
end
logger() click to toggle source
# File lib/fakecrm.rb, line 27
def self.logger
  Application.instance.logger
end
run!() click to toggle source
# File lib/fakecrm.rb, line 31
def self.run!
  Application.instance.run!
end