Class: Tug::Slack

Inherits:
Object
  • Object
show all
Defined in:
lib/tug/notify/slack.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Slack

Returns a new instance of Slack.



6
7
8
# File 'lib/tug/notify/slack.rb', line 6

def initialize(options)
  @url = options[:webhook_url]
end

Instance Attribute Details

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/tug/notify/slack.rb', line 4

def url
  @url
end

Instance Method Details

#notify(text) ⇒ Object



10
11
12
13
14
15
16
# 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