class KnifeSpork::Plugins::HipChat
Public Instance Methods
after_databagcreate()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 71 def after_databagcreate databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} created data bag #{object_name} #{databag_gist}" end
after_databagdelete()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 76 def after_databagdelete databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} deleted data bag item #{object_name} #{databag_gist}" end
after_databagedit()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 66 def after_databagedit databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} edited data bag item #{object_name}:#{object_secondary_name} #{databag_gist}" end
after_databagfromfile()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 86 def after_databagfromfile databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} uploaded data bag item #{object_name}:#{object_secondary_name} #{databag_gist}" end
after_databagitemdelete()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 81 def after_databagitemdelete databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} deleted data bag item #{object_name}:#{object_secondary_name} #{databag_gist}" end
after_delete()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 14 def after_delete hipchat "#{organization}#{current_user} deleted the following cookbooks: #{misc_output}" end
after_environmentcreate()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 36 def after_environmentcreate environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} created environment #{object_name} #{environment_gist}" end
after_environmentdelete()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 41 def after_environmentdelete environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} deleted environment #{object_name} #{environment_gist}" end
after_environmentedit()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 31 def after_environmentedit environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} edited environment #{object_name} #{environment_gist}" end
after_environmentfromfile()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 26 def after_environmentfromfile environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} uploaded environment #{object_name} #{environment_gist}" end
after_nodecreate()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 101 def after_nodecreate node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} created node #{object_name} #{node_gist}" end
after_nodedelete()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 96 def after_nodedelete node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} deleted node #{object_name} #{node_gist}" end
after_nodeedit()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 91 def after_nodeedit node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} edited node #{object_name} #{node_gist}" end
after_nodefromfile()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 106 def after_nodefromfile node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} uploaded node #{object_name} #{node_gist}" end
after_noderunlistadd()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 111 def after_noderunlistadd node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} added run_list items to #{object_name}: #{object_secondary_name} #{node_gist}" end
after_noderunlistremove()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 116 def after_noderunlistremove node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} removed run_list items from #{object_name}: #{object_secondary_name} #{node_gist}" end
after_noderunlistset()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 121 def after_noderunlistset node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} set the run_list for #{object_name} to #{object_secondary_name} #{node_gist}" end
after_promote_remote()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 18 def after_promote_remote environments.each do |environment| diff = environment_diffs[environment.name] env_gist = env_gist(environment, diff) if config.gist hipchat "#{organization}#{current_user} promoted the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")} to #{environment} #{env_gist}" end end
after_rolecreate()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 56 def after_rolecreate role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} created role #{object_name} #{role_gist}" end
after_roledelete()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 61 def after_roledelete role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} deleted role #{object_name} #{role_gist}" end
after_roleedit()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 51 def after_roleedit role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} edited role #{object_name} #{role_gist}" end
after_rolefromfile()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 46 def after_rolefromfile role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty? hipchat "#{organization}#{current_user} uploaded role #{object_name} #{role_gist}" end
after_upload()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 10 def after_upload hipchat "#{organization}#{current_user} uploaded the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")}" end
perform()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 8 def perform; end
Private Instance Methods
color()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 166 def color config.color || 'yellow' end
env_gist(environment, diff)
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 142 def env_gist(environment, diff) msg = "Environment #{environment} uploaded at #{Time.now.getutc} by #{current_user}\n\nConstraints updated on server in this version:\n\n#{diff.collect { |k, v| "#{k}: #{v}\n" }.join}" link = %x[ echo "#{msg}" | #{config.gist}] return "<a href=\"#{link}\">Diff</a>" if !link.nil? || !link.empty? end
hipchat(message)
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 128 def hipchat(message) safe_require 'hipchat' rooms.each do |room_name| begin client = ::HipChat::Client.new(config.api_token, :api_version => config.api_version ||= 'v1', :server_url => config.server_url ||= 'https://api.hipchat.com') client[room_name].send(nickname, message, :notify => notify, :color =>color) rescue Exception => e ui.error 'Something went wrong sending to HipChat.' ui.error e.to_s end end end
nickname()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 158 def nickname config.nickname || 'KnifeSpork' end
notify()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 162 def notify config.notify.nil? ? true : config.notify end
object_gist(object_type, object_name, object_diff)
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 148 def object_gist(object_type, object_name, object_diff) msg = "#{object_type.capitalize} #{object_name} changed at #{Time.now.getutc} by #{current_user}\n\nDiff is as follows:\n\n#{object_diff}" link = %x[ echo "#{msg}" | #{config.gist}] return "<a href=\"#{link}\">Diff</a>" if !link.nil? || !link.empty? end
rooms()
click to toggle source
# File lib/knife-spork/plugins/hipchat.rb, line 154 def rooms [ config.room || config.rooms ].flatten end