Sha256: bb495decbc9861dca26a9905d86a556dde46297ae63c633c4e11106485bb5612

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require 'knife-spork/plugins/plugin'

module KnifeSpork
  module Plugins
    class StatusNet < Plugin
      name :statusnet

      def perform; end

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

      def after_promote_remote
        statusnet "#{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 statusnet(message)
        safe_require 'curb'

        begin
          c = Curl::Easy.new(config.url)
          c.http_auth_types = :basic
          c.username = config.username
          c.password = config.password
          c.post_body = message
          c.perform
        rescue Exception => e
          ui.error 'Something went wrong sending to StatusNet.'
          ui.error e.to_s
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
knife-spork-1.2.2 lib/knife-spork/plugins/statusnet.rb
knife-spork-1.2.1 lib/knife-spork/plugins/statusnet.rb
knife-spork-1.2.0 lib/knife-spork/plugins/statusnet.rb