Class: PuppetHerald::App::Configuration

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/puppet-herald/app/configuration.rb

Overview

A configuration for application

Class Method Summary collapse

Class Method Details

.api?(req) ⇒ Boolean

Is request part of the API

Parameters:

  • req (Sinatra::Request)

    a request to check

Returns:

  • (Boolean)

    true, if given request point to part of the API



46
47
48
# File 'lib/puppet-herald/app/configuration.rb', line 46

def api?(req)
  (req.path.start_with?('/api') || req.path.start_with?('/version.json'))
end

.configure_app(options = {}) ⇒ nil

Configure the application

Parameters:

  • options (Hash) (defaults to: {})

    optional parameters

Returns:

  • (nil)


24
25
26
27
28
29
30
31
# File 'lib/puppet-herald/app/configuration.rb', line 24

def configure_app(options = {})
  cron = options.fetch(:cron, true)
  dbmigrate = options.fetch(:dbmigrate, true)
  setup_database_logger
  dbmigrate! if dbmigrate
  enable_cron if cron
  nil
end

.deconfigure_app(options = {}) ⇒ nil

De-configure the application

Parameters:

  • options (Hash) (defaults to: {})

    optional parameters

Returns:

  • (nil)


37
38
39
40
41
# File 'lib/puppet-herald/app/configuration.rb', line 37

def deconfigure_app(options = {})
  cron = options.fetch(:cron, true)
  disable_cron if cron
  nil
end