Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

70 lines (62 sloc) 1.502 kb
$LOAD_PATH.unshift *Dir["#{File.dirname(__FILE__)}/vendor/**/lib"]
# stdlib
require 'net/http'
require 'net/https'
require 'net/smtp'
require 'socket'
require 'timeout'
require 'xmlrpc/client'
require 'openssl'
require 'cgi'
#~ require 'date' # This is needed by the CIA service in ruby 1.8.7 or later
# vendor
require 'mime/types'
require 'xmlsimple'
require 'activesupport'
require 'rack'
require 'sinatra'
require 'tinder'
require 'json'
require 'tinder'
require 'basecamp'
require 'tmail'
require 'xmpp4r'
require 'xmpp4r-simple'
require 'rubyforge'
set :run, true
set :environment, :production
set :port, ARGV.first || 8080
begin
require 'mongrel'
set :server, 'mongrel'
rescue LoadError
begin
require 'thin'
set :server, 'thin'
rescue LoadError
set :server, 'webrick'
end
end
module GitHub
def service(name)
Timeout.timeout(20) do
post "/#{name}/" do
data = JSON.parse(params[:data])
payload = JSON.parse(params[:payload])
yield data, payload
end
end
rescue Timeout::Error
end
def shorten_url(url)
Timeout::timeout(6) do
short = Net::HTTP.get("api.bit.ly", "/shorten?version=2.0.1&longUrl=#{url}&login=github&apiKey=R_261d14760f4938f0cda9bea984b212e4")
short = JSON.parse(short)
short["errorCode"].zero? ? short["results"][url]["shortUrl"] : url
end
rescue Timeout::Error
url
end
end
include GitHub
Dir["#{File.dirname(__FILE__)}/services/**/*.rb"].each { |service| load service }
Jump to Line
Something went wrong with that request. Please try again.