module BubBot

Constants

VERSION

Attributes

configuration[RW]

Public Class Methods

call(env) click to toggle source

From a config.ru file you can do `run BubBot`. TODO: maybe not. That would skip the running background thread.

Handle an individual web request. You shouldn't call this method directly. Instead, give BubBot to Rack and let it call this method.

# File lib/bub_bot.rb, line 22
def call(env)
  (@web_server ||= WebServer.new).call(env)
end
configure() { |configuration| ... } click to toggle source

Used for setting config options:

BubBot.configure do |config|
  config.bot_name 'lillian'
  config.redis_host 'localhost:6379'
end
# File lib/bub_bot.rb, line 53
def configure
  self.configuration ||= Configuration.new
  yield configuration
end
start() click to toggle source

This method starts a listening web server. Call from the cli or wherever else you want to kick off a running BubBot process.

# File lib/bub_bot.rb, line 28
def start
  puts 'Booting BubBot'
  Thread.new do
    loop do
      #puts "Checking for servers to shutdown"
      # TODO: actually do that ^
      sleep 10# * 60
    end
  end

  app = Rack::Builder.new do
    # if development (TODO)
      use Rack::Reloader
    # end
    run BubBot
  end.to_app

  Rack::Handler::Thin.run(app, BubBot.configuration.rack_options_hash)
end