Sha256: a41f4d9c29291316415f0906a1e28b2b6344d2c6c52dad78ac05d8eb91d0ed45

Contents?: true

Size: 1.28 KB

Versions: 6

Compression:

Stored size: 1.28 KB

Contents

require 'knife-spork/plugins/plugin'

module KnifeSpork
  module Plugins
    class HipChat < Plugin
      name :hipchat

      def perform; end

      def after_upload
        hipchat "#{organization}#{current_user} uploaded the following cookbooks:\n#{cookbooks.collect{ |c| "  #{c.name}@#{c.version}" }.join("\n")}"
      end

      def after_promote_remote
        hipchat "#{organization}#{current_user} promoted the following cookbooks:\n#{cookbooks.collect{ |c| "  #{c.name}@#{c.version}" }.join("\n")} to #{environments.collect{ |e| "#{e.name}" }.join(", ")}"
      end

      private
      def hipchat(message)
        safe_require 'hipchat'

        rooms.each do |room_name|
          begin
            client = ::HipChat::Client.new(config.api_token)
            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

      def rooms
        [ config.room || config.rooms ].flatten
      end

      def nickname
        config.nickname || 'KnifeSpork'
      end

      def notify
        config.notify.nil? ? true : config.notify
      end

      def color
        config.color || 'yellow'
      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/hipchat.rb
knife-spork-1.2.1 lib/knife-spork/plugins/hipchat.rb
knife-spork-1.2.0 lib/knife-spork/plugins/hipchat.rb
knife-spork-1.0.17 lib/knife-spork/plugins/hipchat.rb
knife-spork-1.0.16 lib/knife-spork/plugins/hipchat.rb
knife-spork-1.0.14 lib/knife-spork/plugins/hipchat.rb