Sha256: f66dfe687d4bf9e88cf3eea4c84866c48e0b5bc194da149686625598a9d9b76d

Contents?: true

Size: 1.18 KB

Versions: 6

Compression:

Stored size: 1.18 KB

Contents

require 'knife-spork/plugins/plugin'

module KnifeSpork
  module Plugins
    class Campfire < Plugin
      name :campfire

      def perform; end

      def after_upload
        campfire do |rooms|
          rooms.paste <<-EOH
#{organization}#{current_user} froze the following cookbooks on Chef Server:
#{cookbooks.collect{|c| "  #{c.name}@#{c.version}"}.join("\n")}
EOH
        end
      end

      def after_promote_remote
        campfire do |rooms|
          rooms.paste <<-EOH
#{organization}#{current_user} promoted cookbooks on Chef Server:

cookbooks:
#{cookbooks.collect{|c| "  #{c.name}@#{c.version}"}.join("\n")}

environments:
#{environments.collect{|e| "  #{e.name}"}.join("\n")}
EOH
        end
      end

      private
      def campfire(&block)
        safe_require 'campy'

        rooms = [config.rooms || config.room].flatten.compact
        campfire = Campy::Room.new(:account => config.account, :token => config.token)

        rooms.each do |room_name|
          room = Campy::Room.new(
            :account => config.account,
            :token => config.token,
            :room => room_name
          )
          yield(room) unless room.nil?
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
knife-spork-1.2.2 lib/knife-spork/plugins/campfire.rb
knife-spork-1.2.1 lib/knife-spork/plugins/campfire.rb
knife-spork-1.2.0 lib/knife-spork/plugins/campfire.rb
knife-spork-1.0.17 lib/knife-spork/plugins/campfire.rb
knife-spork-1.0.16 lib/knife-spork/plugins/campfire.rb
knife-spork-1.0.14 lib/knife-spork/plugins/campfire.rb