lib/robut/plugin.rb in robut-0.4.0 vs lib/robut/plugin.rb in robut-0.5.0
- old
+ new
@@ -38,9 +38,28 @@
# the plugin, along with blocks of actions to perform. Each
# element is a [regexp, options, action, description] array.
def matchers
@matchers ||= []
end
+
+ # Allows you to define http methods that this plugin should respond to.
+ # This is useful if you're want to accept generic post data for Robut to
+ # display in all rooms (e.g. Heroku deploy hooks, GitHub post receive
+ # hooks, etc).
+ #
+ # http do
+ # post '/heroku' do
+ # payload = Hashie::Mash.new(params)
+ # say "#{payload.user} deployed #{payload.head} to #{payload.app}", nil
+ # halt 200
+ # end
+ # end
+ #
+ # The action is run in the context of a Sinatra app (+Robut::Web+). So
+ # anything that Sinatra provides is available within the block.
+ def http(&block)
+ Robut::Web.class_eval &block
+ end
end
class << self
# A list of all available plugin classes. When you require a new
# plugin class, you should add it to this list if you want it to