Module: Ambo

Defined in:
lib/ambo.rb,
lib/ambo/task.rb,
lib/ambo/state.rb,
lib/ambo/store.rb,
lib/ambo/loader.rb,
lib/ambo/runner.rb,
lib/ambo/context.rb,
lib/ambo/version.rb,
lib/ambo/tasks/periodic.rb,
lib/ambo/contexts/twitter.rb,
lib/ambo/concerns/loggable.rb,
lib/ambo/contexts/periodic.rb,
lib/ambo/deliveries/twitter.rb

Overview

Main module for the AMBo framework

Defined Under Namespace

Modules: Contexts, Deliveries, Loggable, Task, Tasks Classes: Context, Loader, Runner, State, Store

Constant Summary collapse

Error =
Class.new(StandardError)
LoaderError =
Class.new(Error)
LOG_OUTPUT =
defined?(Minitest) ? 'log/test.log' : $stdout
BEEP_BOOPS =
%w[beep boop].freeze
VERSION =
'0.0.1-alpha1'

Class Method Summary collapse

Class Method Details

.load(path) ⇒ Object


50
51
52
# File 'lib/ambo.rb', line 50

def self.load(path)
  Loader.new(path).load!
end

.loggerObject


36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ambo.rb', line 36

def self.logger
  @logger ||= Logger.new(LOG_OUTPUT).tap do |l|
    level = ENV.fetch('AMBO_LOG_LEVEL') { 'DEBUG' }.upcase.to_sym

    l.level = Logger.const_get(level)
    l.formatter = proc do |severity, datetime, progname, msg|
      progname ||= 'Ambo'
      time_str = datetime.utc.strftime('%d/%b/%Y:%H:%M:%S %z')

      "[#{severity}] [#{progname}] [#{time_str}] #{msg}\n"
    end
  end
end

.random_beep_boopsObject

:nodoc:


62
63
64
65
66
# File 'lib/ambo.rb', line 62

def self.random_beep_boops # :nodoc:
  BEEP_BOOPS.sample.capitalize.tap do |str|
    str << " #{BEEP_BOOPS.sample}" while str.size < 30 && rand > 0.25
  end
end

.safely_require(gem_name) ⇒ Object


54
55
56
57
58
# File 'lib/ambo.rb', line 54

def self.safely_require(gem_name)
  require gem_name
rescue LoadError => _e
  logger.debug "The gem #{gem_name} is not available"
end