Module: DeepThought

Defined in:
lib/deep_thought.rb,
lib/deep_thought/api.rb,
lib/deep_thought/app.rb,
lib/deep_thought/git.rb,
lib/deep_thought/tasks.rb,
lib/deep_thought/scaler.rb,
lib/deep_thought/version.rb,
lib/deep_thought/deployer.rb,
lib/deep_thought/notifier.rb,
lib/deep_thought/ci_service.rb,
lib/deep_thought/models/user.rb,
lib/deep_thought/models/state.rb,
lib/deep_thought/models/deploy.rb,
lib/deep_thought/deployer/shell.rb,
lib/deep_thought/models/project.rb,
lib/deep_thought/ci_service/janky.rb,
lib/deep_thought/deployer/deployer.rb,
lib/deep_thought/ci_service/ci_service.rb

Defined Under Namespace

Modules: CIService, Deployer, Git, Notifier, Scaler, Tasks Classes: Api, App, Deploy, Project, ProjectConfigNotFoundError, State, User

Constant Summary collapse

VERSION =
"0.2.1"

Class Method Summary collapse

Class Method Details

.appObject



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/deep_thought.rb', line 49

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

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

.setup(settings) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/deep_thought.rb', line 19

def self.setup(settings)
  env = settings['RACK_ENV'] ||= 'development'

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

  database = URI(settings["DATABASE_URL"])
  settings["DATABASE_ADAPTER"] ||= "postgresql"

  connection = {
    :adapter   => settings["DATABASE_ADAPTER"],
    :encoding  => "utf8",
    :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