Class: Minicron::Hub::App

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/minicron/hub/app.rb,
lib/minicron/hub/controllers/index.rb,
lib/minicron/hub/controllers/api/jobs.rb,
lib/minicron/hub/controllers/api/hosts.rb,
lib/minicron/hub/controllers/api/schedule.rb,
lib/minicron/hub/controllers/api/executions.rb,
lib/minicron/hub/controllers/api/job_execution_outputs.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApp

Called on class initilisation, sets up the database and requires all the application files


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/minicron/hub/app.rb', line 60

def initialize
  super

  # Initialize the db
  Minicron::Hub::App.setup_db

  # Load all our model serializers
  Dir[File.dirname(__FILE__) + '/serializers/*.rb'].each do |serializer|
    require serializer
  end

  # Load all our models
  Dir[File.dirname(__FILE__) + '/models/*.rb'].each do |model|
    require model
  end

  # Load all our controllers
  Dir[File.dirname(__FILE__) + '/controllers/**/*.rb'].each do |controller|
    require controller
  end
end

Class Method Details

.setup_dbObject

Used to set up the database connection


83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/minicron/hub/app.rb', line 83

def self.setup_db
  # Configure the database
  case Minicron.config['database']['type']
  when 'mysql'
    set :database,
        :adapter => 'mysql2',
        :host => Minicron.config['database']['host'],
        :database => Minicron.config['database']['database'],
        :username => Minicron.config['database']['username'],
        :password => Minicron.config['database']['password']

  else
    fail Exception, "The database #{Minicron.config['database']['type']} is not supported"
  end
end