Class: Blooper::Application

Inherits:
Logger::Application
  • Object
show all
Defined in:
lib/blooper.rb

Constant Summary collapse

DATE_FORMAT =
'%Y/%m/%d %H:%M:%S'
LOGGER_LEVEL =
Logger::INFO

Instance Method Summary collapse

Constructor Details

#initializeApplication

Returns a new instance of Application.



24
25
26
27
28
# File 'lib/blooper.rb', line 24

def initialize
  super('Blooper')
  self.level = $VERBOSE && Logger::DEBUG || LOGGER_LEVEL
  self.logger.formatter = formatter
end

Instance Method Details

#runObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/blooper.rb', line 30

def run
  @log.info('Establishing the database connection')
  DB.instance
  @log.info('A database connection has been established')
  Input.each do |tuple|
    begin
      tuple.save
      @log.debug('Data was saved')
    rescue Sequel::DatabaseDisconnectError
      @log.warn('A database connection has been lost, reconnecting...')
      DB.instance.connect
      retry
    rescue Sequel::Error => error
      @log.error(error.message.gsub(/\n.*/s, ''))
      next
    end
  end
end