Module: Broach
- Defined in:
- lib/broach.rb,
lib/broach/room.rb,
lib/broach/user.rb,
lib/broach/session.rb,
lib/broach/attributes.rb,
lib/broach/exceptions.rb
Overview
Settings
Before you can do anything else you will need to provide credentials first, this includes the account name and authentication token. The use_ssl
parameter is optional and defaults to false.
Broach.settings = { 'account' => 'example', 'token' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'use_ssl' => true }
You can find the token for any Campfire account by logging into the web interface and clicking ‘My Info’ in the top-right corner.
Say someting in a room real quick
If you just need to say something real quick in a room, you can use the speak class method.
Broach.speak("Office", "Manfred just deployed a new version of the weblog (http://www.fngtps.com)")
Note that this fetches a list of all rooms so it can figure out the ID for the room you specified.
Post a lot of stuff to a room
If you want to post multiple lines to one room, it’s a good idea to create a Room instance.
room = Broach::Room.find_by_name('Office')
room.speak('Manfred just commited to the `weblog' repository')
room.speak("commit 4578530113cb87e1e7dbd696c376181e97d429d7\n" +
"Author: Manfred Stienstra <[email protected]>\n" +
"Date: Wed Dec 16 14:03:33 2009 +0100\n\n" +
" Add a speak method to Broach to quickly say something in a room.", :type => :paste)
Defined Under Namespace
Modules: Attributes Classes: APIError, AuthenticationError, AuthorizationError, ConfigurationError, Room, Session, User
Class Method Summary collapse
-
.me ⇒ Object
Returns a User instance for the currently authenticated user.
-
.rooms ⇒ Object
Returns a Room instance for all rooms accesible to the currently authenticated user.
-
.session ⇒ Object
Returns a session object with the current settings.
-
.settings ⇒ Object
Returns the current Broach settings.
-
.settings=(settings) ⇒ Object
Sets the broach settings.
-
.speak(room_name, content, options = {}) ⇒ Object
Send a message to a room with a certain name.
Class Method Details
.me ⇒ Object
Returns a User instance for the currently authenticated user
57 58 59 |
# File 'lib/broach.rb', line 57 def self.me Broach::User.me end |
.rooms ⇒ Object
Returns a Room instance for all rooms accesible to the currently authenticated user
62 63 64 |
# File 'lib/broach.rb', line 62 def self.rooms Broach::Room.all end |
.session ⇒ Object
Returns a session object with the current settings
52 53 54 |
# File 'lib/broach.rb', line 52 def self.session @session ||= Broach::Session.new(settings) end |
.settings ⇒ Object
Returns the current Broach settings
41 42 43 |
# File 'lib/broach.rb', line 41 def self.settings @settings end |
.settings=(settings) ⇒ Object
Sets the broach settings
46 47 48 49 |
# File 'lib/broach.rb', line 46 def self.settings=(settings) @settings = settings @session = nil end |
.speak(room_name, content, options = {}) ⇒ Object
Send a message to a room with a certain name.
Note that you should only use this method if you’re sending just one message. It fetches all rooms before sending the message to find the room with the name you’re specifying.
If you need to send multiple messages to the same room you should instantiate a room first.
Options
room
The name of the room, ie. 'Office'
content
The content of the message, see Broach::Room#speak for more information.
options
Options for the message, see Broach::Room#speak for more information.
Examples
Broach.speak('Office', 'Manfred just deployed a new version of the weblog (http://www.fngtps.com)')
Broach.speak('Office', 'crickets', :type => :sound)
86 87 88 89 90 |
# File 'lib/broach.rb', line 86 def self.speak(room_name, content, ={}) if room = rooms.find { |room| room.name == room_name } room.speak(content, ) end end |