tinder-1.10.1/0000755000004100000410000000000012471432221013105 5ustar www-datawww-datatinder-1.10.1/Rakefile0000644000004100000410000000025612471432220014554 0ustar www-datawww-datarequire 'bundler' Bundler::GemHelper.install_tasks require 'rspec/core/rake_task' desc 'Run the specs' RSpec::Core::RakeTask.new task :default => :spec task :test => :spec tinder-1.10.1/.gemtest0000644000004100000410000000000012471432220014543 0ustar www-datawww-datatinder-1.10.1/Gemfile0000644000004100000410000000013712471432220014400 0ustar www-datawww-datasource 'http://rubygems.org' platforms :jruby do gem 'jruby-openssl', '~> 0.7' end gemspec tinder-1.10.1/.rspec0000644000004100000410000000002412471432220014215 0ustar www-datawww-data--color --backtrace tinder-1.10.1/MIT-LICENSE0000644000004100000410000000207112471432220014540 0ustar www-datawww-dataCopyright (c) 2006-2014 Brandon Keepers, Collective Idea Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. tinder-1.10.1/spec/0000755000004100000410000000000012471432221014037 5ustar www-datawww-datatinder-1.10.1/spec/tinder/0000755000004100000410000000000012471432221015324 5ustar www-datawww-datatinder-1.10.1/spec/tinder/connection_spec.rb0000644000004100000410000000705212471432221021026 0ustar www-datawww-data# encoding: UTF-8 require 'spec_helper' describe Tinder::Connection do describe "authentication" do it "should raise an exception with bad credentials" do stub_connection(Tinder::Connection) do |stub| stub.get("/rooms.json") {[401, {}, "Unauthorized"]} end connection = Tinder::Connection.new('test', :token => 'foo') expect { connection.get('/rooms.json') }.to raise_error(Tinder::AuthenticationFailed) end it "should raise an exception when an invalid subdomain is specified" do stub_connection(Tinder::Connection) do |stub| stub.get("/rooms.json") {[404, {}, "Not found"]} end connection = Tinder::Connection.new('test', :token => 'foo') expect { connection.get('/rooms.json') }.to raise_error(Tinder::AuthenticationFailed) end it "should lookup token when username/password provided" do stub_connection(Tinder::Connection) do |stub| stub.get("/users/me.json") {[200, {}, fixture('users/me.json')]} end connection = Tinder::Connection.new('test', :username => 'user', :password => 'pass') expect(connection.token).to eq("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") end it "should use basic auth for credentials" do stub_connection(Tinder::Connection) do |stub| stub.get("/rooms.json") {[200, {}, fixture('rooms.json')]} end connection = Tinder::Connection.new('test', :token => 'mytoken') expect { connection.get('/rooms.json') }.not_to raise_error end end describe "oauth" do let (:oauth_token) { "myoauthtoken" } let (:connection) { Tinder::Connection.new('test', :oauth_token => oauth_token) } before do stub_connection(Tinder::Connection) do |stub| stub.get("/rooms.json") {[200, {}, fixture('rooms.json')]} end end it "should authenticate" do expect { connection.get('/rooms.json') }.to_not raise_error end it "should set the oauth_token" do connection.get('/rooms.json') expect(connection.options[:oauth_token]).to eq(oauth_token) end it "should set an Authorization header" do connection.get('/rooms.json') expect(connection.connection.headers["Authorization"]).to eq("Bearer #{oauth_token}") end end describe "ssl" do it "should turn on ssl by default" do stub_connection(Tinder::Connection) do |stub| stub.get("/users/me.json") {[200, {}, fixture('users/me.json')]} end connection = Tinder::Connection.new('test', :username => 'user', :password => 'pass') expect(connection.ssl?).to eq(true) end it "should should allow peer verification to be turned off" do stub_connection(Tinder::Connection) do |stub| stub.get("/users/me.json") {[200, {}, fixture('users/me.json')]} end connection = Tinder::Connection.new('test', :username => 'user', :password => 'pass', :ssl_verify => false) expect(connection.connection.ssl.verify?).to eq(false) end it "should allow passing any ssl_options to Faraday" do stub_connection(Tinder::Connection) do |stub| stub.get("/users/me.json") {[200, {}, fixture('users/me.json')]} end connection = Tinder::Connection.new('test', :username => 'user', :password => 'pass', :ssl_options => { :verify => false, :ca_path => "/usr/lib/ssl/certs", :ca_file => "/etc/ssl/custom" } ) expect(connection.connection.ssl.to_hash).to eq(:verify => false, :ca_path => "/usr/lib/ssl/certs", :ca_file => "/etc/ssl/custom") end end end tinder-1.10.1/spec/tinder/room_spec.rb0000644000004100000410000002501012471432221017635 0ustar www-datawww-data# encoding: UTF-8 require 'spec_helper' require 'date' describe Tinder::Room do def mock_listen_callbacks(stream) expect(stream).to receive(:each_item).with(any_args).and_return(true) expect(stream).to receive(:on_error) expect(stream).to receive(:on_max_reconnects) end before do @connection = Tinder::Connection.new('test', :token => 'mytoken') stub_connection(@connection) do |stub| stub.get('/room/80749.json') {[200, {}, fixture('rooms/show.json')]} end @room = Tinder::Room.new(@connection, 'id' => 80749, 'name' => 'Room 1') # Get EventMachine out of the way. We could be using em-spec, but seems like overkill require 'twitter/json_stream' module EventMachine; def self.run; yield end end expect(EventMachine).to receive(:reactor_running?).at_most(:once).and_return(true) @stream = double(Twitter::JSONStream) end describe "join" do before do stub_connection(@connection) do |stub| stub.post('/room/80749/join.json') {[200, {}, ""]} end end it "should post to join url" do @room.join end end describe "leave" do before do stub_connection(@connection) do |stub| stub.post('/room/80749/leave.json') {[200, {}, ""]} end end it "should post to leave url" do @room.leave end it "stops listening" do expect(@room).to receive(:stop_listening) @room.leave end end describe "lock" do before do stub_connection(@connection) do |stub| stub.post('/room/80749/lock.json') {[200, {}, ""]} end end it "should post to lock url" do @room.lock end end describe "search" do before do stub_connection(@connection) do |stub| stub.get('/search/foo.json') {[200, {}, fixture("rooms/recent.json")]} end end it "should GET the search endpoint with the search term and filter by room" do expect(@room).to receive(:id).twice.and_return(490096) expect(@room).to receive(:parse_message).exactly(2).times @room.search("foo") end it "should return empty array if no messages in room" do expect(@room).not_to receive(:parse_message) expect(@room.search("foo")).to be_empty end end describe "transcript" do it "should GET the transcript endpoint with the provided date" do stub_connection(@connection) do |stub| stub.get('/room/80749/transcript/2012/10/15.json') {[200, {}, fixture("rooms/recent.json")]} end expect(@room).to receive(:parse_message).exactly(2).times @room.transcript(Date.parse('2012-10-15')) end it "should default to today's date" do stub_connection(@connection) do |stub| stub.get('/room/80749/transcript/1981/03/21.json') {[200, {}, fixture("rooms/recent.json")]} end expect(Date).to receive(:today).and_return(Date.parse('1981-03-21')) expect(@room).to receive(:parse_message).exactly(2).times @room.transcript end it "should return an array of messages" do stub_connection(@connection) do |stub| stub.get('/room/80749/transcript/2012/10/15.json') {[200, {}, fixture('rooms/recent.json')]} stub.get('/users/1158839.json') {[200, {}, fixture('users/me.json')]} stub.get('/users/1158837.json') {[200, {}, fixture('users/me.json')]} end expect(@room.transcript(Date.parse('2012-10-15'))).to be_a(Array) end it "should have messages with attributes" do stub_connection(@connection) do |stub| stub.get('/room/80749/transcript/2012/10/15.json') {[200, {}, fixture("rooms/recent.json")]} stub.get('/users/1158839.json') {[200, {}, fixture('users/me.json')]} stub.get('/users/1158837.json') {[200, {}, fixture('users/me.json')]} end message = @room.transcript(Date.parse('2012-10-15')).first expect(message[:id]).to be_a(Integer) expect(message[:user][:id]).to be_a(Integer) expect(message[:body]).to be_a(String) expect(message[:created_at]).to be_a(Time) end end describe "unlock" do before do stub_connection(@connection) do |stub| stub.post('/room/80749/unlock.json') {[200, {}, ""]} end end it "should post to unlock url" do @room.unlock end end describe "guest_url" do it "should use guest_invite_code if active" do expect(@room).to receive(:guest_access_enabled?).and_return(true) expect(@room).to receive(:guest_invite_code).and_return('123') expect(@room.guest_url).to eq("https://test.campfirenow.com/123") end it "should return nil when guest access is not enabled" do expect(@room).to receive(:guest_access_enabled?).and_return(false) expect(@room.guest_url).to be_nil end end it "should set guest_invite_code" do expect(@room.guest_invite_code).to eq("90cf7") end it "should set guest_access_enabled?" do expect(@room.guest_access_enabled?).to eq(true) end describe "topic" do it "should get the current topic" do expect(@room.topic).to eq("Testing") end it "should get the current topic even if it's changed" do expect(@room.topic).to eq("Testing") # reinitialize a new connection since we can't modify the # faraday stack after a request has already been submitted @connection = Tinder::Connection.new('test', :token => 'mytoken') # returning a different room's json to get a diff topic stub_connection(@connection) do |stub| stub.get('/room/80749.json') {[200, {}, fixture('rooms/room80751.json')]} end expect(@room.topic).to eq("Testing 2") end end describe "name=" do it "should put to update the room" do stub_connection(@connection) do |stub| stub.put('/room/80749.json') {[200, {}, ""]} end @room.name = "Foo" end end describe "listen" do before do stub_connection(@connection) do |stub| stub.post('/room/80749/join.json') {[200, {}, ""]} end end it "should get from the streaming url" do expect(Twitter::JSONStream).to receive(:connect).with( { :host=>"streaming.campfirenow.com", :path=>"/room/80749/live.json", :auth=>"mytoken:X", :timeout=>6, :ssl=>true } ).and_return(@stream) mock_listen_callbacks(@stream) @room.listen { } end it "should raise an exception if no block is given" do expect { @room.listen }.to raise_error(ArgumentError, "no block provided") end it "marks the room as listening" do expect(Twitter::JSONStream).to receive(:connect).and_return(@stream) mock_listen_callbacks(@stream) expect { @room.listen { } }.to change(@room, :listening?).from(false).to(true) end end describe "stop_listening" do before do stub_connection(@connection) do |stub| stub.post('/room/80749/join.json') {[200, {}, ""]} end expect(Twitter::JSONStream).to receive(:connect).and_return(@stream) expect(@stream).to receive(:stop) end it "changes a listening room to a non-listening room" do mock_listen_callbacks(@stream) @room.listen { } expect { @room.stop_listening }.to change(@room, :listening?).from(true).to(false) end it "tells the json stream to stop" do mock_listen_callbacks(@stream) @room.listen { } @room.stop_listening end it "does nothing if the room is not listening" do mock_listen_callbacks(@stream) @room.listen { } @room.stop_listening @room.stop_listening end end describe "recent" do before do stub_connection(@connection) do |stub| stub.get('/room/80749/recent.json') {[ 200, {}, fixture('rooms/recent.json') ]} end end it "should get a list of parsed recent messages" do expect(@room).to receive(:parse_message).exactly(2).times messages = @room.recent end end describe "parse_message" do it "expands user and parses created_at" do unparsed_message = { :user_id => 123, :body => 'An aunt is worth two nieces', :created_at => '2012/02/14 16:21:00 +0000' } expected = { :user => { :name => 'Dr. Noodles' }, :body => 'An aunt is worth two nieces', :created_at => Time.parse('2012/02/14 16:21:00 +0000') } expect(@room).to receive(:user).with(123).and_return({ :name => 'Dr. Noodles' }) actual = @room.parse_message(unparsed_message) expect(actual).to eq(expected) end end describe "user" do before do expect(@room).to receive(:current_users).and_return([ { :id => 1, :name => 'The Amazing Crayon Executive'}, { :id => 2, :name => 'Lord Pants'}, ]) @not_current_user = { :id => 3, :name => 'Patriot Sally'} end it "looks up user if not already in room's cache" do expect(@room).to receive(:fetch_user).with(3). and_return(@not_current_user) expect(@room.user(3)).to eq(@not_current_user) end it "pulls user from room's cache if user in participant list" do expect(@room).not_to receive(:fetch_user) user = @room.user(1) end it "adds user to cache after first lookup" do expect(@room).to receive(:fetch_user).with(3).at_most(:once). and_return(@not_current_user) expect(@room.user(3)).to eq(@not_current_user) expect(@room.user(3)).to eq(@not_current_user) end end describe "fetch_user" do before do stub_connection(@connection) do |stub| stub.get("/users/5.json") {[200, {}, fixture('users/me.json')]} end end it "requests via GET and returns the requested user's information" do expect(@room.fetch_user(5)['name']).to eq('John Doe') end end describe "current_users" do it "returns list of currently participating users" do current_users = @room.current_users expect(current_users.size).to eq(1) expect(current_users.first[:name]).to eq('Brandon Keepers') end end describe "users" do it "returns current users if cache has not been initialized yet" do expect(@room).to receive(:current_users).and_return(:the_whole_spittoon) expect(@room.users).to eq(:the_whole_spittoon) end it "returns current users plus any added cached users" do expect(@room).to receive(:current_users).and_return([:mia_cuttlefish]) @room.users << :guy_wearing_new_mexico_as_a_hat expect(@room.users).to eq([:mia_cuttlefish, :guy_wearing_new_mexico_as_a_hat]) end end end tinder-1.10.1/spec/tinder/campfire_spec.rb0000644000004100000410000000572412471432221020461 0ustar www-datawww-data# encoding: UTF-8 require 'spec_helper' describe Tinder::Campfire do before do @campfire = Tinder::Campfire.new('test', :token => 'mytoken') end describe "rooms" do before do stub_connection(@campfire.connection) do |stub| stub.get('/rooms.json') {[200, {}, fixture('rooms.json')]} end end it "should return rooms" do expect(@campfire.rooms.size).to eq(2) expect(@campfire.rooms.first).to be_kind_of(Tinder::Room) end it "should set the room name and id" do room = @campfire.rooms.first expect(room.name).to eq('Room 1') expect(room.id).to eq(80749) end end describe "presence" do before do stub_connection(@campfire.connection) do |stub| stub.get('/presence.json') {[200, {}, fixture('presence.json')]} end end it "should return rooms" do expect(@campfire.presence.size).to eq(3) expect(@campfire.presence.first).to be_kind_of(Tinder::Room) end it "should set the room name and id" do room = @campfire.presence.last expect(room.name).to eq('Room 3') expect(room.id).to eq(80754) end end describe "find_room_by_id" do before do stub_connection(@campfire.connection) do |stub| stub.get('/rooms.json') {[200, {}, fixture('rooms.json')]} end end it "should return a Tinder::Room object when a match is found" do room = @campfire.find_room_by_id 80749 expect(room).to be_kind_of(Tinder::Room) end it "should return nil when no match is found" do room = @campfire.find_room_by_id 123 expect(room).to eq(nil) end end describe "find_room_by_name" do before do stub_connection(@campfire.connection) do |stub| stub.get('/rooms.json') {[200, {}, fixture('rooms.json')]} end end it "should return a Tinder::Room object when a match is found" do room = @campfire.find_room_by_name 'Room 1' expect(room).to be_kind_of(Tinder::Room) end it "should return nil when no match is found" do room = @campfire.find_room_by_name 'asdf' expect(room).to eq(nil) end end describe "users" do before do stub_connection(@campfire.connection) do |stub| stub.get('/rooms.json') {[200, {}, fixture('rooms.json')]} [80749, 80751].each do |id| stub.get("/room/#{id}.json") {[200, {}, fixture("rooms/room#{id}.json")]} end end end it "should return a sorted list of users in all rooms" do expect(@campfire.users.length).to eq(2) expect(@campfire.users.first[:name]).to eq("Jane Doe") expect(@campfire.users.last[:name]).to eq("John Doe") end end describe "me" do before do stub_connection(@campfire.connection) do |stub| stub.get("/users/me.json") {[200, {}, fixture('users/me.json')]} end end it "should return the current user's information" do expect(@campfire.me["name"]).to eq("John Doe") end end end tinder-1.10.1/spec/spec_helper.rb0000644000004100000410000000130612471432221016655 0ustar www-datawww-data# encoding: UTF-8 $:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') require 'rspec' require 'tinder' require 'fakeweb' FakeWeb.allow_net_connect = false def fixture(name) File.read(File.dirname(__FILE__) + "/fixtures/#{name}") end def stub_connection(object, &block) @stubs ||= Faraday::Adapter::Test::Stubs.new object.connection.build do |builder| builder.use FaradayMiddleware::EncodeJson builder.use FaradayMiddleware::Mashify builder.use FaradayMiddleware::ParseJson builder.use Faraday::Response::RemoveWhitespace builder.use Faraday::Response::RaiseOnAuthenticationFailure builder.adapter :test, @stubs end block.call(@stubs) end tinder-1.10.1/spec/fixtures/0000755000004100000410000000000012471432221015710 5ustar www-datawww-datatinder-1.10.1/spec/fixtures/rooms/0000755000004100000410000000000012471432221017047 5ustar www-datawww-datatinder-1.10.1/spec/fixtures/rooms/show.json0000644000004100000410000000111212471432221020715 0ustar www-datawww-data{ "room": { "full": false, "name": "Room 1", "created_at": "2007/03/16 18:03:21 +0000", "updated_at": "2007/03/16 18:03:21 +0000", "users": [{ "type": "Member", "created_at": "2006/12/07 21:20:39 +0000", "email_address": "brandon@opensoul.org", "admin": true, "id": 129553, "name": "Brandon Keepers" }], "topic": "Testing", "active_token_value": "90cf7", "id": 80749, "open_to_guests": true, "membership_limit": 4 } } tinder-1.10.1/spec/fixtures/rooms/room80749.json0000644000004100000410000000107212471432221021332 0ustar www-datawww-data{ "room": { "full": false, "name": "Room 1", "created_at": "2007/03/16 18:03:21 +0000", "updated_at": "2007/03/16 18:03:21 +0000", "users": [{ "type": "Member", "created_at": "2006/12/07 21:20:39 +0000", "email_address": "jane@example.com", "admin": true, "id": 1, "name": "Jane Doe" }], "topic": "Testing", "active_token_value": "90cf7", "id": 80749, "open_to_guests": true, "membership_limit": 4 } } tinder-1.10.1/spec/fixtures/rooms/room80751.json0000644000004100000410000000107412471432221021325 0ustar www-datawww-data{ "room": { "full": false, "name": "Room 2", "created_at": "2007/03/16 18:03:21 +0000", "updated_at": "2007/03/16 18:03:21 +0000", "users": [{ "type": "Member", "created_at": "2006/12/07 21:20:39 +0000", "email_address": "john@example.com", "admin": true, "id": 2, "name": "John Doe" }], "topic": "Testing 2", "active_token_value": "90cf7", "id": 80751, "open_to_guests": true, "membership_limit": 4 } } tinder-1.10.1/spec/fixtures/rooms/recent.json0000644000004100000410000000104012471432221021215 0ustar www-datawww-data{ "messages": [{ "starred": false, "type": "TextMessage", "room_id": 490096, "created_at": "2012/04/05 10:53:14 +0000", "id": 537713173, "user_id": 1158839, "body": "https://github.com/technomancy/dotfiles/commit/e19989d33777bb392c0ad1205444762dfecbaa5f " }, { "starred": false, "type": "TextMessage", "room_id": 490096, "created_at": "2012/04/05 10:54:20 +0000", "id": 537713420, "user_id": 1158837, "body": "Lol" }] } tinder-1.10.1/spec/fixtures/presence.json0000644000004100000410000000111312471432221020403 0ustar www-datawww-data{"rooms": [ { "name": "Room 1", "created_at": "2007/03/16 18:03:21 +0000", "updated_at": "2007/03/16 18:03:21 +0000", "topic": "Testing", "id": 80749, "membership_limit": 4 }, { "name": "Room 2", "created_at": "2007/03/16 18:04:54 +0000", "updated_at": "2007/03/16 18:04:54 +0000", "topic": "test", "id": 80751, "membership_limit": 4 }, { "name": "Room 3", "created_at": "2012/03/16 18:04:54 +0000", "updated_at": "2013/03/16 18:04:54 +0000", "topic": "presence", "id": 80754, "membership_limit": 4 }] }tinder-1.10.1/spec/fixtures/users/0000755000004100000410000000000012471432221017051 5ustar www-datawww-datatinder-1.10.1/spec/fixtures/users/me.json0000644000004100000410000000043712471432221020351 0ustar www-datawww-data{ "user": { "email_address": "user@example.com", "type": "Member", "created_at": "2006/04/06 00:38:28 +0000", "admin": true, "id": 12345, "name": "John Doe", "api_auth_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } } tinder-1.10.1/spec/fixtures/rooms.json0000644000004100000410000000061312471432221017742 0ustar www-datawww-data{"rooms": [ { "name": "Room 1", "created_at": "2007/03/16 18:03:21 +0000", "updated_at": "2007/03/16 18:03:21 +0000", "topic": "Testing", "id": 80749, "membership_limit": 4 }, { "name": "Room 2", "created_at": "2007/03/16 18:04:54 +0000", "updated_at": "2007/03/16 18:04:54 +0000", "topic": "test", "id": 80751, "membership_limit": 4 }] } tinder-1.10.1/.travis.yml0000644000004100000410000000017412471432220015217 0ustar www-datawww-datalanguage: ruby rvm: - rbx-2 - jruby-19mode - 1.9.3 - 2.0.0 - 2.1 only: - master notifications: disabled: true tinder-1.10.1/lib/0000755000004100000410000000000012471432221013653 5ustar www-datawww-datatinder-1.10.1/lib/tinder/0000755000004100000410000000000012471432221015140 5ustar www-datawww-datatinder-1.10.1/lib/tinder/connection.rb0000644000004100000410000000643512471432221017634 0ustar www-datawww-data# encoding: UTF-8 require 'faraday' require 'faraday/request/multipart' require 'faraday/response/raise_on_authentication_failure' require 'faraday/response/remove_whitespace' require 'faraday_middleware' require 'json' require 'uri' class Faraday::RequestOptions attr_accessor :preserve_raw end module Tinder class Connection HOST = 'campfirenow.com' attr_reader :subdomain, :uri, :options def self.connection @connection ||= Faraday.new do |builder| builder.use FaradayMiddleware::EncodeJson builder.use FaradayMiddleware::Mashify builder.use FaradayMiddleware::ParseJson builder.use Faraday::Response::RemoveWhitespace builder.use Faraday::Response::RaiseOnAuthenticationFailure builder.adapter Faraday.default_adapter end end def self.raw_connection @raw_connection ||= Faraday.new do |builder| builder.use Faraday::Request::Multipart builder.use FaradayMiddleware::Mashify builder.use FaradayMiddleware::ParseJson builder.use Faraday::Response::RemoveWhitespace builder.use Faraday::Response::RaiseOnAuthenticationFailure builder.adapter Faraday.default_adapter end end def initialize(subdomain, options = {}) @subdomain = subdomain @options = {:ssl => true, :ssl_options => {:verify => true}, :proxy => ENV['HTTP_PROXY']} @options[:ssl_options][:verify] = options.delete(:ssl_verify) unless options[:ssl_verify].nil? @options.merge!(options) @uri = URI.parse("#{@options[:ssl] ? 'https' : 'http' }://#{subdomain}.#{HOST}") @token = options[:token] @oauth_token = options[:oauth_token] if @oauth_token connection.headers["Authorization"] = "Bearer #{@oauth_token}" raw_connection.headers["Authorization"] = "Bearer #{@oauth_token}" else connection.basic_auth token, 'X' raw_connection.basic_auth token, 'X' end end def basic_auth_settings {:username => token, :password => 'X'} end def connection @connection ||= begin conn = self.class.connection.dup set_connection_options(conn) conn end end def raw_connection @raw_connection ||= begin conn = self.class.raw_connection.dup set_connection_options(conn) conn end end def token @token ||= begin connection.basic_auth(options[:username], options[:password]) get('/users/me.json')['user']['api_auth_token'] end end def get(url, *args) response = connection.get(url, *args) response.body end def post(url, body = nil, *args) response = connection.post(url, body, *args) response.body end def raw_post(url, body = nil, *args) response = raw_connection.post(url, body, *args) end def put(url, body = nil, *args) response = connection.put(url, body, *args) response.body end # Is the connection to campfire using ssl? def ssl? uri.scheme == 'https' end private def set_connection_options(conn) conn.url_prefix = @uri.to_s conn.proxy options[:proxy] if options[:ssl_options] conn.ssl.merge!(options[:ssl_options]) end end end end tinder-1.10.1/lib/tinder/room.rb0000644000004100000410000002044012471432221016441 0ustar www-datawww-data# encoding: UTF-8 require 'time' module Tinder # A campfire room class Room attr_reader :id, :name def initialize(connection, attributes = {}) @connection = connection @id = attributes['id'] @name = attributes['name'] @loaded = false end # Join the room # POST /room/#{id}/join.xml # For whatever reason, #join() and #leave() are still xml endpoints # whereas elsewhere in this API we're assuming json :\ def join post 'join', 'xml' end # Leave a room # POST /room/#{id}/leave.xml def leave post 'leave', 'xml' stop_listening end # Get the url for guest access def guest_url "#{@connection.uri}/#{guest_invite_code}" if guest_access_enabled? end def guest_access_enabled? load @open_to_guests ? true : false end # The invite code use for guest def guest_invite_code load @active_token_value end # Change the name of the room def name=(name) update :name => name end alias_method :rename, :name= # Change the topic def topic=(topic) update :topic => topic end def update(attrs) connection.put("/room/#{@id}.json", {:room => attrs}) end # Get the current topic def topic reload! @topic end # Lock the room to prevent new users from entering and to disable logging def lock post 'lock' end # Unlock the room def unlock post 'unlock' end # Post a new message to the chat room def speak(message, options = {}) send_message(message) end def paste(message) send_message(message, 'PasteMessage') end def play(sound) send_message(sound, 'SoundMessage') end def tweet(url) send_message(url, 'TweetMessage') end # Get the list of users currently chatting for this room def users @users ||= current_users end def current_users reload! @current_users end # return the user with the given id; if it isn't in our room cache, # do a request to get it def user(id) if id cached_user = users.detect {|u| u[:id] == id } user = cached_user || fetch_user(id) self.users << user user end end # Perform a request for the user with the given ID def fetch_user(id) user_data = connection.get("/users/#{id}.json") user = user_data && user_data[:user] user[:created_at] = Time.parse(user[:created_at]) user end # Modifies a hash representation of a Campfire message. Expands +:user_id+ # to a full hash at +:user+, generates Timestamp from +:created_at+. # # Full returned hash: # * +:body+: the body of the message # * +:user+: Campfire user, which is itself a hash, of: # * +:id+: User id # * +:name+: User name # * +:email_address+: Email address # * +:admin+: Boolean admin flag # * +:created_at+: User creation timestamp # * +:type+: User type (e.g. Member) # * +:id+: Campfire message id # * +:type+: Campfire message type # * +:room_id+: Campfire room id # * +:created_at+: Message creation timestamp def parse_message(message) message[:user] = user(message.delete(:user_id)) message[:created_at] = Time.parse(message[:created_at]) message end # Listen for new messages in the room, parsing them with #parse_message # and then yielding them to the provided block as they arrive. # # room.listen do |m| # room.speak "Go away!" if m[:body] =~ /Java/i # end def listen(options = {}) raise ArgumentError, "no block provided" unless block_given? Tinder.logger.info "Joining #{@name}…" join # you have to be in the room to listen require 'json' require 'hashie' require 'multi_json' require 'twitter/json_stream' auth = connection.basic_auth_settings options = { :host => "streaming.#{Connection::HOST}", :path => room_url_for('live'), :auth => "#{auth[:username]}:#{auth[:password]}", :timeout => 6, :ssl => connection.options[:ssl] }.merge(options) Tinder.logger.info "Starting EventMachine server…" EventMachine::run do @stream = Twitter::JSONStream.connect(options) Tinder.logger.info "Listening to #{@name}…" @stream.each_item do |message| message = Hashie::Mash.new(MultiJson.decode(message)) message = parse_message(message) yield(message) end @stream.on_error do |message| raise ListenFailed.new("got an error! #{message.inspect}!") end @stream.on_max_reconnects do |timeout, retries| raise ListenFailed.new("Tried #{retries} times to connect. Got disconnected from #{@name}!") end # if we really get disconnected raise ListenFailed.new("got disconnected from #{@name}!") if !EventMachine.reactor_running? end end def listening? @stream != nil end def stop_listening return unless listening? Tinder.logger.info "Stopped listening to #{@name}…" @stream.stop @stream = nil end # Get the transcript for the given date (Returns a hash in the same format as #listen) # # room.transcript(Time.now) # #=> [{:message=>"foobar!", # :user_id=>"99999", # :person=>"Brandon", # :id=>"18659245", # :timestamp=>=>Tue May 05 07:15:00 -0700 2009}] # # The timestamp slot will typically have a granularity of five minutes. # def transcript(transcript_date = Date.today) url = "/room/#{@id}/transcript/#{transcript_date.strftime('%Y/%m/%d')}.json" connection.get(url)['messages'].map do |message| parse_message(message) end end # Search transcripts for the given term (returns an array of messages parsed # via #parse_message, see #parse_message for format of returned message) # def search(term) encoded_term = URI.encode(term) room_messages = connection.get("/search/#{encoded_term}.json")["messages"].select do |message| message[:room_id] == id end room_messages.map do |message| parse_message(message) end end def upload(file, content_type = nil, filename = nil) require 'mime/types' content_type ||= MIME::Types.type_for(filename || file) raw_post(:uploads, { :upload => Faraday::UploadIO.new(file, content_type, filename) }) end # Get the list of latest files for this room def files(count = 5) get(:uploads)['uploads'].map { |u| u['full_url'] } end # Get a list of recent messages # Accepts a hash for options: # * +:limit+: Restrict the number of messages returned # * +:since_message_id+: Get messages created after the specified message id def recent(options = {}) options = { :limit => 10, :since_message_id => nil }.merge(options) # Build url manually, faraday has to be 8.0 to do this url = "#{room_url_for(:recent)}?limit=#{options[:limit]}&since_message_id=#{options[:since_message_id]}" connection.get(url)['messages'].map do |msg| parse_message(msg) end end protected def load reload! unless @loaded end def reload! attributes = connection.get("/room/#{@id}.json")['room'] @id = attributes['id'] @name = attributes['name'] @topic = attributes['topic'] @full = attributes['full'] @open_to_guests = attributes['open_to_guests'] @active_token_value = attributes['active_token_value'] @current_users = attributes['users'].map do |user| user[:created_at] = Time.parse(user[:created_at]) user end @loaded = true end def send_message(message, type = 'TextMessage') post 'speak', {:message => {:body => message, :type => type}} end def get(action) connection.get(room_url_for(action)) end def post(action, body = nil) connection.post(room_url_for(action), body) end def raw_post(action, body = nil) connection.raw_post(room_url_for(action), body) end def room_url_for(action, format="json") "/room/#{@id}/#{action}.#{format}" end def connection @connection end end end tinder-1.10.1/lib/tinder/version.rb0000644000004100000410000000013412471432221017150 0ustar www-datawww-data# encoding: UTF-8 module Tinder VERSION = '1.10.1' unless defined?(::Tinder::VERSION) end tinder-1.10.1/lib/tinder/campfire.rb0000644000004100000410000000517012471432221017256 0ustar www-datawww-data# encoding: UTF-8 module Tinder # == Usage # # campfire = Tinder::Campfire.new 'mysubdomain', :token => 'xyz' # # room = campfire.create_room 'New Room', 'My new campfire room to test tinder' # room.speak 'Hello world!' # room.destroy # # room = campfire.find_room_by_guest_hash 'abc123', 'John Doe' # room.speak 'Hello world!' class Campfire attr_reader :connection # Create a new connection to the campfire account with the given +subdomain+. # # == Options: # * +:ssl+: use SSL for the connection, which is required if you have a Campfire SSL account. # Defaults to true # * +:ssl_options+: SSL options passed to the underlaying Faraday connection. Allows to specify if the SSL certificate should be verified (:verify => true|false) and to specify the path to the ssl certs directory (:ca_path => "path/certs") # Defaults to {:verify => true} # * +:proxy+: a proxy URI. (e.g. :proxy => 'http://user:pass@example.com:8000') # # c = Tinder::Campfire.new("mysubdomain", :ssl => true) def initialize(subdomain, options = {}) @connection = Connection.new(subdomain, options) end # Get an array of all the available rooms # TODO: detect rooms that are full (no link) def rooms connection.get('/rooms.json')['rooms'].map do |room| Room.new(connection, room) end end # Get an array of all rooms user is present in def presence connection.get('/presence.json')['rooms'].map do |room| Room.new(connection, room) end end # Find a campfire room by id # NOTE: id should be of type Integer def find_room_by_id(id) id = id.to_i rooms.detect { |room| room.id == id } end # Find a campfire room by name def find_room_by_name(name) rooms.detect { |room| room.name == name } end # Find a campfire room by its guest hash def find_room_by_guest_hash(hash, name) rooms.detect { |room| room.guest_invite_code == hash } end # Creates and returns a new Room with the given +name+ and optionally a +topic+ def create_room(name, topic = nil) connection.post('/rooms.json', { :room => { :name => name, :topic => topic } }) find_room_by_name(name) end def find_or_create_room_by_name(name) find_room_by_name(name) || create_room(name) end # List the users that are currently chatting in any room def users rooms.map(&:users).flatten.compact.uniq.sort_by {|u| u[:name]} end # get the user info of the current user def me connection.get("/users/me.json")["user"] end end end tinder-1.10.1/lib/faraday/0000755000004100000410000000000012471432221015262 5ustar www-datawww-datatinder-1.10.1/lib/faraday/response/0000755000004100000410000000000012471432221017120 5ustar www-datawww-datatinder-1.10.1/lib/faraday/response/raise_on_authentication_failure.rb0000644000004100000410000000037512471432221026057 0ustar www-datawww-data# encoding: UTF-8 require 'faraday' module Faraday class Response::RaiseOnAuthenticationFailure < Response::Middleware def on_complete(response) raise Tinder::AuthenticationFailed if [401, 404].include?(response[:status]) end end end tinder-1.10.1/lib/faraday/response/remove_whitespace.rb0000644000004100000410000000026612471432221023162 0ustar www-datawww-data# encoding: UTF-8 require 'faraday' module Faraday class Response::RemoveWhitespace < Response::Middleware def parse(body) body =~ /^\s+$/ ? "" : body end end end tinder-1.10.1/lib/tinder.rb0000644000004100000410000000065012471432221015466 0ustar www-datawww-data# encoding: UTF-8 require 'tinder/connection' require 'tinder/campfire' require 'tinder/room' require 'logger' module Tinder class Error < StandardError; end class SSLRequiredError < Error; end class AuthenticationFailed < Error; end class ListenFailed < Error; end def self.logger @logger ||= Logger.new(ENV['TINDER_LOGGING'] ? STDOUT : nil) end def self.logger=(logger) @logger = logger end end tinder-1.10.1/README.markdown0000644000004100000410000000414612471432220015612 0ustar www-datawww-data# Tinder - get the Campfire started [![Gem Version](https://badge.fury.io/rb/tinder.png)](http://badge.fury.io/rb/tinder) [![Build Status](https://travis-ci.org/collectiveidea/tinder.png?branch=master)](https://travis-ci.org/collectiveidea/tinder) [![Code Climate](https://codeclimate.com/github/collectiveidea/tinder.png)](https://codeclimate.com/github/collectiveidea/tinder) [![Dependency Status](https://gemnasium.com/collectiveidea/tinder.png)](https://gemnasium.com/collectiveidea/tinder) Tinder is a library for interfacing with Campfire, the chat application from 37Signals, allowing you to programmatically manage and speak/listen in chat rooms. As of December 2009, thanks to initial work from Joshua Peek at 37signals, it now makes use of the official Campfire API (described at: http://developer.37signals.com/campfire/). ## Usage campfire = Tinder::Campfire.new 'mysubdomain', :token => '546884b3d8fee4d80665g561caf7h9f3ea7b999e' # or you can still use username/password and Tinder will look up your token # campfire = Tinder::Campfire.new 'mysubdomain', :username => 'user', :password => 'pass' # or if you have an OAuth token then you can use that to connect # campfire = Tinder::Campfire.new 'mysubdomain', :oauth_token => '546884b3d8fee4d80665g561caf7h9f3ea7b999e' room = campfire.rooms.first room.rename 'New Room Names' room.speak 'Hello world!' room.paste "my pasted\ncode" room = campfire.find_room_by_guest_hash 'abc123', 'John Doe' room.speak 'Hello world!' See the RDoc for more details. ## Installation gem install tinder ## Contributions Tinder is open source and contributions from the community are encouraged! No contribution is too small. Please consider: * adding an awesome feature * fixing a terrible bug * updating documentation * fixing a not-so-bad bug * fixing typos For the best chance of having your changes merged, please: 1. Ask us! We'd love to hear what you're up to. 2. Fork the project. 3. Commit your changes and tests (if applicable (they're applicable)). 4. Submit a pull request with a thorough explanation and at least one animated GIF. tinder-1.10.1/metadata.yml0000644000004100000410000001375312471432221015421 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: tinder version: !ruby/object:Gem::Version version: 1.10.1 platform: ruby authors: - Brandon Keepers - Brian Ryckbost - Tony Coconate autorequire: bindir: bin cert_chain: [] date: 2014-12-01 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: eventmachine requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.0' - !ruby/object:Gem::Dependency name: faraday requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: 0.9.0 type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: 0.9.0 - !ruby/object:Gem::Dependency name: faraday_middleware requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '0.9' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '0.9' - !ruby/object:Gem::Dependency name: hashie requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '1.0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '1.0' - !ruby/object:Gem::Dependency name: json requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: 1.8.0 type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: 1.8.0 - !ruby/object:Gem::Dependency name: mime-types requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: multi_json requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.7' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.7' - !ruby/object:Gem::Dependency name: twitter-stream requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '0.1' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '0.1' - !ruby/object:Gem::Dependency name: fakeweb requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rspec requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' description: A Ruby API for interfacing with Campfire, the 37Signals chat application. email: - brandon@opensoul.org - bryckbost@gmail.com - me@tonycoconate.com executables: [] extensions: [] extra_rdoc_files: - README.markdown files: - ".gemtest" - ".gitignore" - ".rspec" - ".travis.yml" - CHANGELOG.txt - Gemfile - MIT-LICENSE - README.markdown - Rakefile - init.rb - lib/faraday/response/raise_on_authentication_failure.rb - lib/faraday/response/remove_whitespace.rb - lib/tinder.rb - lib/tinder/campfire.rb - lib/tinder/connection.rb - lib/tinder/room.rb - lib/tinder/version.rb - site/index.html - site/stylesheets/style.css - spec/fixtures/presence.json - spec/fixtures/rooms.json - spec/fixtures/rooms/recent.json - spec/fixtures/rooms/room80749.json - spec/fixtures/rooms/room80751.json - spec/fixtures/rooms/show.json - spec/fixtures/users/me.json - spec/spec_helper.rb - spec/tinder/campfire_spec.rb - spec/tinder/connection_spec.rb - spec/tinder/room_spec.rb - tinder.gemspec homepage: http://github.com/collectiveidea/tinder licenses: [] metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: 1.3.6 requirements: [] rubyforge_project: rubygems_version: 2.2.2 signing_key: specification_version: 4 summary: Ruby wrapper for the Campfire API test_files: - spec/fixtures/presence.json - spec/fixtures/rooms.json - spec/fixtures/rooms/recent.json - spec/fixtures/rooms/room80749.json - spec/fixtures/rooms/room80751.json - spec/fixtures/rooms/show.json - spec/fixtures/users/me.json - spec/spec_helper.rb - spec/tinder/campfire_spec.rb - spec/tinder/connection_spec.rb - spec/tinder/room_spec.rb tinder-1.10.1/init.rb0000644000004100000410000000002112471432220014365 0ustar www-datawww-datarequire 'tinder' tinder-1.10.1/.gitignore0000644000004100000410000000006612471432220015076 0ustar www-datawww-data*.gem .bundle Gemfile.lock pkg/* .rvmrc .ruby-version tinder-1.10.1/tinder.gemspec0000644000004100000410000000236412471432221015744 0ustar www-datawww-data# -*- encoding: utf-8 -*- $:.push File.expand_path('../lib', __FILE__) require 'tinder/version' Gem::Specification.new do |gem| gem.add_dependency 'eventmachine', '~> 1.0' gem.add_dependency 'faraday', '~> 0.9.0' gem.add_dependency 'faraday_middleware', '~> 0.9' gem.add_dependency 'hashie', ['>= 1.0'] gem.add_dependency 'json', '~> 1.8.0' gem.add_dependency 'mime-types' gem.add_dependency 'multi_json', '~> 1.7' gem.add_dependency 'twitter-stream', '~> 0.1' gem.add_development_dependency 'fakeweb' gem.add_development_dependency 'rake' gem.add_development_dependency 'rspec' gem.authors = ["Brandon Keepers", "Brian Ryckbost", "Tony Coconate"] gem.description = %q{A Ruby API for interfacing with Campfire, the 37Signals chat application.} gem.email = ['brandon@opensoul.org', 'bryckbost@gmail.com', 'me@tonycoconate.com'] gem.extra_rdoc_files = ['README.markdown'] gem.files = `git ls-files`.split("\n") gem.homepage = 'http://github.com/collectiveidea/tinder' gem.name = 'tinder' gem.require_paths = ['lib'] gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') gem.summary = %q{Ruby wrapper for the Campfire API} gem.test_files = `git ls-files -- spec/*`.split("\n") gem.version = Tinder::VERSION end tinder-1.10.1/CHANGELOG.txt0000644000004100000410000000502112471432220015132 0ustar www-datawww-data1.10.1 - 2014-12-01 * Loosen hashie dependency 1.10.0 - 2014-08-06 * Update Faraday dependency * Loosen mime-type dependency 1.9.4 - 2014-02-24 * Fix typos in MIT licence * Add Campfire#presence to get a list of rooms in which you are present 1.9.3 - 2013-09-06 * OAuth support 1.9.2 - 2013-01-04 * Update dependencies to latest versions 1.9.0 - 2012-07-16 * Add Room#recent to get a list of recent messages * Add Room#search to search a room's transcripts 1.4.3 - 2010-12-07 * explicitly require 'uri' * added Room#tweet(url) 1.4.2 - 2010-11-13 * Use Faraday instead of HTTParty [eric] * Fix file uploads [eric] 1.4.1 - 2010-10-09 * Make SSL the default since it is available for all Campfire accounts. * Added MIT License 1.4 - 2010-05-11 * Remove methods no longer supported by API Campfire#available_transcripts, Room#ping, Room#destroy, Room#toggle_guest_access * Added Room#play * ActiveSupport 3.0 support * Fix streaming API support * Allow SSL for listening * Add support for HTTP proxies [c13bcc0b] 1.3.1 - 2009-12-17 * Declare HTTParty dependency * Fix Room#paste 1.3.0 - 2009-12-15 * Rewrite to use Official Campfire API 1.2.2 - 2009-09-12 * Work around CSRF protection bug * Fixes for changes to Campfire markup * Include timestamps in the transcript 1.2.1 - 2009-08-27 * Fixes for listening after campfire updates [Jordan Byron] 1.2.0 - 2009-01-28 * Get the list of available files [Christopher MacGown] * Upload files [Joshua Wand] * Find rooms even when full [Josh Owens] * Join rooms as a guest [Ian Lesperance] 1.1.7 - 2008-07-24 * Don't join the room when only speaking [Brian Donovan] * Added support for HTTP proxies * Fix listening for messages that contain URLs [Jared Kuolt] 0.1.6 - 2008-03-07 * Added Room#topic for getting the current topic [Even Weaver] * Trap INT in #listen(&block) [borrowed from Chris Shea's Pyre] 0.1.5 - 2008-01-25 * Fixed Room#listen, which was broken by latest Campfire deploy * Fixed timeout when listening but not speaking that will eventually log you out [Clinton R. Nixon] 0.1.4 - 2007-07-23 * Support for transcripts * Fixed Room#leave, which was broken by a Campfire deployment [Andy Smith] 0.1.3 - 2007-02-12 * added ssl support [Tero Parviainen] 0.1.2 - 2007-01-27 * fixed bug preventing #listen from working without a block 0.1.1 - 2007-01-27 * fix bug preventing speak from working * incorporated "watching" from http://soylentfoo.jnewland.com/articles/2006/12/07/updates-to-marshmallow-the-campfire-bot 0.1.0 - 2007-01-23 * Initial release as gem * Get the users in a room [Tero Parviainen] tinder-1.10.1/site/0000755000004100000410000000000012471432221014051 5ustar www-datawww-datatinder-1.10.1/site/stylesheets/0000755000004100000410000000000012471432221016425 5ustar www-datawww-datatinder-1.10.1/site/stylesheets/style.css0000644000004100000410000000176612471432221020311 0ustar www-datawww-databody { font-family: "Lucida Grande", Helvetica, Arial, sans-serif; font-size: 76%; background: #2A2A2A; margin: 0; padding: 0; } #collectiveidea { border-bottom: 1px solid #444; } a { color: #2D5385; } #main { background-color: #FFF; width: 700px; margin: 0 auto; border: 5px #CCC; border-left-style: solid; border-right-style: solid; padding: 0 1em; } #header { position: relative; border-bottom: 1px solid #999; padding: 1em; } #header h1 { margin: 0; padding: 0; color: #2D5385; } #header h1 a { text-decoration: none; } #header p { margin: 0; padding: 0; font-size: 0.8em; color: #999; } #nav { list-style: none; position: absolute; right: 0; top: 0.6em; } #nav li { display: inline; padding: 0 0.5em; } #content { padding: 1em 0; } dl { background-color: #DDD; padding: 1em; border: 1px solid #CCC; } dl .pronunciation { color: #C00; } dl .description { text-transform: uppercase; font-size: 0.8em; font-family: fixed; } tinder-1.10.1/site/index.html0000644000004100000410000001010712471432221016045 0ustar www-datawww-data Tinder

Tinder is an API for interfacing with Campfire, the 37Signals chat application.

Example

campfire = Tinder::Campfire.new 'mysubdomain'
campfire.login 'myemail@example.com', 'mypassword'

Create, find and destroy rooms

room = campfire.create_room 'New Room', 'My new campfire room to test tinder'
room = campfire.find_room_by_name 'Other Room'
room.destroy

Speak and Paste

room.speak 'Hello world!'
room.paste File.read("path/to/your/file.txt")

Listening

room.listen
#=> [{:person=>"Brandon", :message=>"I'm getting very sleepy", :user_id=>"148583", :id=>"16434003"}]

# or in block form
room.listen do |m|
  room.speak 'Welcome!' if m[:message] == /hello/
end

Guest Access

room.toggle_guest_access
room.guest_url         #=> http://mysubdomain.campfirenow.com/11111
room.guest_invite_code #=> 11111

Change the name and topic

room.name = 'Tinder Demo'
room.topic = 'Showing how to change the room name and topic with tinder…'

Users

room.users
campfire.users # users in all rooms

Transcripts

transcript = room.transcript(room.available_transcripts.first)
#=> [{:message=>"foobar!", :user_id=>"99999", :person=>"Brandon", :id=>"18659245", :timestamp=>Tue May 05 07:15:00 -0700 2009}]

See the API documentation for more details.

Installation

Tinder can be installed as a gem or a Rails plugin. Install the gem by executing:

gem install tinder

Or, download it from RubyForge.

Source

Contributions are welcome and appreciated! The source is available from:

http://github.com/collectiveidea/tinder