Class: Flowchef::NotifyInbox
- Inherits:
-
Chef::Handler
- Object
- Chef::Handler
- Flowchef::NotifyInbox
- Defined in:
- lib/flowchef.rb
Defined Under Namespace
Classes: InvalidParameterError
Instance Method Summary collapse
- #blank?(var) ⇒ Boolean
-
#initialize(options = {}) ⇒ NotifyInbox
constructor
A new instance of NotifyInbox.
- #report ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ NotifyInbox
Returns a new instance of NotifyInbox.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/flowchef.rb', line 21 def initialize( = {}) @api_token = if [:api_token].kind_of?(Array) [:api_token] else [:api_token].to_s end raise InvalidParameterError, "Must specify a Flow token" if blank?(@api_token) # Emacs indented this oddly @tags = if [:tags].kind_of?(Array) [:tags].each do |tag| raise InvalidParameterError, "Tags must be strings" if not tag.kind_of?(String) end end end |
Instance Method Details
#blank?(var) ⇒ Boolean
50 51 52 |
# File 'lib/flowchef.rb', line 50 def blank?(var) var.nil? || var.respond_to?(:length) && var.length == 0 end |
#report ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/flowchef.rb', line 36 def report msg = <<-eos <h2>Chef failures on #{node.name}</h2> #{run_status.formatted_exception} eos flow = Flowdock::Flow.new(:api_token => @api_token, :source => "chef-#{node.environment}", :from => {:name => "Node #{node.fqdn}", :address => "noreply@#{node.fqdn}"}) flow.push_to_team_inbox(:subject => "Chef failuers on #{node.name}", :content => msg, :tags => []) end |