class SlackbotNotifier
Attributes
development_room[RW]
production[RW]
slackbot_url[RW]
message[R]
room[R]
Public Class Methods
new(room = 'general')
click to toggle source
# File lib/slackbot_notifier.rb, line 4 def initialize(room = 'general') @room = SlackbotNotifier.production ? room : SlackbotNotifier.development_room end
Public Instance Methods
http()
click to toggle source
# File lib/slackbot_notifier.rb, line 17 def http @http ||= Net::HTTP.new(uri.host, uri.port).tap { |h| h.use_ssl = uri.scheme == 'https' } end
notify(message)
click to toggle source
# File lib/slackbot_notifier.rb, line 8 def notify(message) @message = message http.request request end
request()
click to toggle source
# File lib/slackbot_notifier.rb, line 21 def request @request ||= Net::HTTP::Post.new(uri.request_uri).tap do |r| r.body = message r.content_type = 'text/xml' end end
uri()
click to toggle source
# File lib/slackbot_notifier.rb, line 13 def uri @uri ||= URI "#{SlackbotNotifier.slackbot_url}&channel=%23#{room}" end