Class: PostCommit::Hooks::Twitter

Inherits:
Base
  • Object
show all
Defined in:
lib/post_commit/hooks/twitter.rb

Overview

To send a Twitter post commit, you have to setup your username and password.

post_commit :twitter do
  authorize :username => "johndoe", :password => "test"
  post "Some message"
end

You can specify the message type. See PostCommit::Hooks::Twitter#post for usage.

Instance Attribute Summary

Attributes inherited from Base

#credentials, #options, #request, #response, #uri

Instance Method Summary (collapse)

Methods inherited from Base

#authorize, #convert_to_params, #convert_to_xml, inherited, #initialize, #set

Constructor Details

This class inherits a constructor from PostCommit::Hooks::Base

Instance Method Details

- (Object) post(message, options = {})

Post message to Twitter. You can send public and direct messages.

post "Hi Twitter!"
#=> public message

post "Hi john!", :type => :direct_message, :screen_name => "johndoe"
#=> private message

post "Hi john!", :type => :direct_message, :user_id => 1
#=> private message


23
24
25
26
27
28
29
30
31
32
# File 'lib/post_commit/hooks/twitter.rb', line 23

def post(message, options = {})
  options = {:type => :status}.merge(options)

  case options.delete(:type)
  when :status then status(message, options)
  when :direct_message then direct_message(message, options)
  else
    raise PostCommit::InvalidOptionError, "Twitter's message type should be either :status or :direct_message"
  end
end