Sha256: 6a089ad224d4d5fca1bf342ec42891073882e79cc161ed26436e2dee7bfdb857

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

require 'active_record'
require 'delayed_job_active_record'

require 'deep_thought/app'
require 'deep_thought/api'
require 'deep_thought/models/deploy'
require 'deep_thought/models/project'
require 'deep_thought/models/state'
require 'deep_thought/models/user'
require 'deep_thought/deployer'
require 'deep_thought/deployer/shell'
require 'deep_thought/ci_service'
require 'deep_thought/ci_service/janky'
require 'deep_thought/notifier'
require 'deep_thought/scaler'
require 'deep_thought/version'

module DeepThought
  def self.setup(settings)
    env = settings['RACK_ENV']

    if env != "production"
      settings["DATABASE_URL"] ||= "postgres://deep_thought@localhost/deep_thought_#{env}"
    end

    database = URI(settings["DATABASE_URL"])

    connection = {
      :adapter   => "postgresql",
      :encoding  => "unicode",
      :database  => database.path[1..-1],
      :pool      => 5,
      :username  => database.user,
      :password  => database.password,
      :host      => database.host,
      :port      => database.port
    }

    ActiveRecord::Base.establish_connection(connection)

    BCrypt::Engine.cost = 12

    if settings['CI_SERVICE']
      DeepThought::CIService.setup(settings)
    end
  end

  def self.app
    @app ||= Rack::Builder.app {
      map '/' do
        run DeepThought::App
      end

      map '/deploy/' do
        run DeepThought::Api
      end
    }
  end

  DeepThought::Deployer.register_adapter('shell', DeepThought::Deployer::Shell)
  DeepThought::CIService.register_adapter('janky', DeepThought::CIService::Janky)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
deep_thought-0.1.1 lib/deep_thought.rb
deep_thought-0.1.0 lib/deep_thought.rb