module MattermostNotification
a simple helper that post message to Mattermost channel
Constants
- VERSION
Public Class Methods
configure() { |self| ... }
click to toggle source
# File lib/mattermost_notification.rb, line 20 def self.configure(&_block) yield self end
post(body)
click to toggle source
# File lib/mattermost_notification.rb, line 9 def self.post(body) raise 'body is `nil`' unless body raise 'channel_url is `nil`' unless channel_url.present? uri = URI channel_url request = Net::HTTP::Post.new uri request.set_form_data(payload: { text: body }.to_json) Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') { |http| http.request request } end