class Tug::Slack

Attributes

url[RW]

Public Class Methods

new(options) click to toggle source
# File lib/tug/notify/slack.rb, line 6
def initialize(options)
  @url = options[:webhook_url]
end

Public Instance Methods

notify(text) click to toggle source
# File lib/tug/notify/slack.rb, line 10
def notify(text)
  unless @url.nil?
    IO.popen("curl #{@url} -X POST -# #{params(text)}") do |pipe|
      puts pipe.read
    end
  end
end

Private Instance Methods

params(text) click to toggle source
# File lib/tug/notify/slack.rb, line 20
def params(text)
  "-F payload='#{payload(text).to_json}'"
end
payload(text) click to toggle source
# File lib/tug/notify/slack.rb, line 24
def payload(text)
  {
    "text" => text,
    "color"=> "good",
  }
end