class KnifeSpork::Plugins::Irccat
Constants
- TEMPLATES
Public Instance Methods
after_databagcreate()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 190 def after_databagcreate databag_gist = object_gist("databag", "#{object_name}", object_difference) if config.gist and !object_difference.empty? display_gist(databag_gist) if databag_gist irccat(template(:databagcreate) % { :organization => organization, :current_user => current_user, :object_name => object_name, :gist => databag_gist }) end
after_databagdelete()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 167 def after_databagdelete databag_gist = object_gist("databag item", "#{object_name}", object_difference) if config.gist and !object_difference.empty? display_gist(databag_gist) if databag_gist irccat(template(:databagdelete) % { :organization => organization, :current_user => current_user, :object_name => object_name, :gist => databag_gist }) end
after_databagedit()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 155 def after_databagedit databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty? display_gist(databag_gist) if databag_gist irccat(template(:databagedit) % { :organization => organization, :current_user => current_user, :object_name => object_name, :object_secondary_name => object_secondary_name, :gist => databag_gist }) end
after_databagfromfile()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 201 def after_databagfromfile databag_gist = object_gist("databag", "#{object_name}", object_difference) if config.gist and !object_difference.empty? display_gist(databag_gist) if databag_gist irccat(template(:databagfromfile) % { :organization => organization, :current_user => current_user, :object_name => object_name, :object_secondary_name => object_secondary_name, :gist => databag_gist }) end
after_databagitemdelete()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 178 def after_databagitemdelete databag_gist = object_gist("databag item", "#{object_name}:#{object_secondary_name}", object_difference) if config.gist and !object_difference.empty? display_gist(databag_gist) if databag_gist irccat(template(:databagitemdelete) % { :organization => organization, :current_user => current_user, :object_name => object_name, :object_secondary_name => object_secondary_name, :gist => databag_gist }) end
after_delete()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 44 def after_delete irccat(template(:delete) % { :organization => organization, :current_user => current_user, :misc_output => misc_output }) end
after_environmentcreate()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 89 def after_environmentcreate environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty? display_gist(environment_gist) if environment_gist irccat(template(:environmentcreate) % { :organization => organization, :current_user => current_user, :object_name => object_name, :gist => environment_gist }) end
after_environmentdelete()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 100 def after_environmentdelete environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty? display_gist(environment_gist) if environment_gist irccat(template(:environmentdelete) % { :organization => organization, :current_user => current_user, :object_name => object_name, :gist => environment_gist }) end
after_environmentedit()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 78 def after_environmentedit environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty? display_gist(environment_gist) if environment_gist irccat(template(:environmentedit) % { :organization => organization, :current_user => current_user, :object_name => object_name, :gist => environment_gist }) end
after_environmentfromfile()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 67 def after_environmentfromfile environment_gist = object_gist("environment", object_name, object_difference) if config.gist and !object_difference.empty? display_gist(environment_gist) if environment_gist irccat(template(:environmentfromfile) % { :organization => organization, :current_user => current_user, :object_name => object_name, :gist => environment_gist }) end
after_nodecreate()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 235 def after_nodecreate node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty? display_gist(node_gist) if node_gist irccat(template(:nodecreate) % { :organization => organization, :current_user => current_user, :object_name => object_name, :gist => node_gist }) end
after_nodedelete()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 224 def after_nodedelete node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty? display_gist(node_gist) if node_gist irccat(template(:nodedelete) % { :organization => organization, :current_user => current_user, :object_name => object_name, :gist => node_gist }) end
after_nodeedit()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 213 def after_nodeedit node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty? display_gist(node_gist) if node_gist irccat(template(:nodeedit) % { :organization => organization, :current_user => current_user, :object_name => object_name, :gist => node_gist }) end
after_nodefromfile()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 246 def after_nodefromfile node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty? display_gist(node_gist) if node_gist irccat(template(:nodefromfile) % { :organization => organization, :current_user => current_user, :object_name => object_name, :gist => node_gist }) end
after_noderunlistadd()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 257 def after_noderunlistadd node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty? display_gist(node_gist) if node_gist irccat(template(:noderunlistadd) % { :organization => organization, :current_user => current_user, :object_name => object_name, :object_secondary_name => object_secondary_name, :gist => node_gist }) end
after_noderunlistremove()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 269 def after_noderunlistremove node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty? display_gist(node_gist) if node_gist irccat(template(:noderunlistremove) % { :organization => organization, :current_user => current_user, :object_name => object_name, :object_secondary_name => object_secondary_name, :gist => node_gist }) end
after_noderunlistset()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 281 def after_noderunlistset node_gist = object_gist("node", "#{object_name}", object_difference) if config.gist and !object_difference.empty? display_gist(node_gist) if node_gist irccat(template(:noderunlistset) % { :organization => organization, :current_user => current_user, :object_name => object_name, :object_secondary_name => object_secondary_name, :gist => node_gist }) end
after_promote_remote()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 52 def after_promote_remote environments.each do |environment| diff = environment_diffs[environment.name] env_gist = env_gist(environment, diff) if config.gist display_gist(env_gist) if env_gist irccat(template(:promote) % { :organization => organization, :current_user => current_user, :cookbooks => cookbooks.collect{ |c| "#{c.name}@#{c.version}" }.join(", "), :environment => environment.name, :gist => env_gist }) end end
after_rolecreate()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 133 def after_rolecreate role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty? display_gist(role_gist) if role_gist irccat(template(:rolecreate) % { :organization => organization, :current_user => current_user, :object_name => object_name, :gist => role_gist }) end
after_roledelete()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 144 def after_roledelete role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty? display_gist(role_gist) if role_gist irccat(template(:roledelete) % { :organization => organization, :current_user => current_user, :object_name => object_name, :gist => role_gist }) end
after_roleedit()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 122 def after_roleedit role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty? display_gist(role_gist) if role_gist irccat(template(:roleedit) % { :organization => organization, :current_user => current_user, :object_name => object_name, :gist => role_gist }) end
after_rolefromfile()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 111 def after_rolefromfile role_gist = object_gist("role", object_name, object_difference) if config.gist and !object_difference.empty? display_gist(role_gist) if role_gist irccat(template(:rolefromfile) % { :organization => organization, :current_user => current_user, :object_name => object_name, :gist => role_gist }) end
after_upload()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 36 def after_upload irccat(template(:upload) % { :organization => organization, :current_user => current_user, :cookbooks => cookbooks.collect { |c| "#{c.name}@#{c.version}" }.join(", ") }) end
perform()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 34 def perform; end
Private Instance Methods
channels()
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 323 def channels [ config.channel || config.channels ].flatten end
display_gist(gist)
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 314 def display_gist(gist) ui.info "Gist generated at #{gist}" end
env_gist(environment, diff)
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 309 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}" %x[ echo "#{msg}" | #{config.gist}] end
irccat(message)
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 294 def irccat(message) channels.each do |channel| begin # Write the message using a TCP Socket socket = TCPSocket.open(config.server, config.port) socket.write("#{channel} #{message}") rescue Exception => e ui.error 'Failed to post message with irccat.' ui.error e.to_s ensure socket.close unless socket.nil? end end end
object_gist(object_type, object_name, object_diff)
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 318 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}" %x[ echo "#{msg}" | #{config.gist}] end
template(name)
click to toggle source
# File lib/knife-spork/plugins/irccat.rb, line 327 def template(name) (config.template && config.template[name]) || TEMPLATES[name] end