Class: Rack::ErrorToSlack::Message
- Inherits:
-
Object
- Object
- Rack::ErrorToSlack::Message
- Defined in:
- lib/rack/error_to_slack/message.rb
Overview
Message Class
Instance Method Summary collapse
-
#initialize(env, err_msg, err_location) ⇒ Message
constructor
A new instance of Message.
- #send ⇒ Object
Constructor Details
#initialize(env, err_msg, err_location) ⇒ Message
Returns a new instance of Message.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rack/error_to_slack/message.rb', line 9 def initialize(env, err_msg, err_location) @data = { 'text': "#{username} encountered an error " \ "while `#{env['REQUEST_METHOD']} #{env['PATH_INFO']}` " \ "on branch `#{branch}`\n" \ "```#{err_msg}```\n" \ "`#{err_location.gsub(/^#{root_path}/, '').tr('`', "'")}`", 'username': slackname, 'icon_emoji': emoji } end |
Instance Method Details
#send ⇒ Object
21 22 23 24 |
# File 'lib/rack/error_to_slack/message.rb', line 21 def send request_url = ErrorToSlack.configuration.webhook_url Net::HTTP.post_form(URI.parse(request_url), 'payload' => @data.to_json) end |