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.1"
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
-
.call(env) ⇒ Object
From a config.ru file you can do ‘run BubBot`.
-
.configure {|configuration| ... } ⇒ Object
Used for setting config options: BubBot.configure do |config| config.bot_name ‘lillian’ config.redis_host ‘localhost:6379’ end.
-
.start ⇒ Object
This method starts a listening web server.
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
12 13 14 |
# File 'lib/bub_bot.rb', line 12 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.
18 19 20 |
# File 'lib/bub_bot.rb', line 18 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
49 50 51 52 |
# File 'lib/bub_bot.rb', line 49 def configure self.configuration ||= Configuration.new yield configuration end |
.start ⇒ Object
This method starts a listening web server. Call from the cli or wherever else you want to kick off a running BubBot process.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/bub_bot.rb', line 24 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.) end |