Module: BubBot

Defined in:
lib/bub_bot.rb,
lib/bub_bot/version.rb

Defined Under Namespace

Modules: Slack Classes: CLI, Configuration, DeployManager, RedisConnection, ServerManager, WebServer

Constant Summary collapse

VERSION =
"0.2.7"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



16
17
18
# File 'lib/bub_bot.rb', line 16

def configuration
  @configuration
end

Class Method Details

.call(env) ⇒ Object

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.



22
23
24
# File 'lib/bub_bot.rb', line 22

def call(env)
  (@web_server ||= WebServer.new).call(env)
end

.configure {|configuration| ... } ⇒ Object

Used for setting config options:

BubBot.configure do |config|
  config.bot_name 'lillian'
  config.redis_host 'localhost:6379'
end

Yields:



53
54
55
56
# File 'lib/bub_bot.rb', line 53

def configure
  self.configuration ||= Configuration.new
  yield configuration
end

.startObject

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



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# 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