Class: Cerberus::Publisher::Twitter

Inherits:
Base
  • Object
show all
Defined in:
lib/cerberus/publisher/twitter.rb

Class Method Summary collapse

Methods inherited from Base

formatted_message

Class Method Details

.publish(state, manager, options) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cerberus/publisher/twitter.rb', line 14

def self.publish(state, manager, options)
  begin
    require 'twitter'

    twitter_options = options[:publisher, :twitter]
    raise "There is no login info for Twitter publisher" unless twitter_options[:login] and twitter_options[:password]

    subject,body = Cerberus::Publisher::Base.formatted_message(state, manager, options)

    client = Twitter::Client.new( :login => twitter_options[:login], :password => twitter_options[:password] )
    status = client.status( :post, subject )

  rescue Gem::LoadError
    puts "Twitter publisher requires that you install the 'twitter4r' gem first." 
  end
end