Created
October 11, 2012 15:01
-
-
Save coldfumonkeh/3873004 to your computer and use it in GitHub Desktop.
Ruby / Sinatra code for PhoneGap Build to automatically force a new request from a Github repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'rest_client' | |
def get_or_post(path, opts={}, &block) | |
get(path, opts, &block) | |
post(path, opts, &block) | |
end | |
get '/' do | |
'Hello world' | |
end | |
get_or_post '/:user/:pass/:appid' do | |
pgURL = 'https://build.phonegap.com/apps/' + params[:appid] + '/push' | |
private_resource = | |
RestClient::Resource.new pgURL, params[:user], params[:pass] | |
private_resource.get{ |response, request, result, &block| | |
if [301, 302, 307].include? response.code | |
response.follow_redirection(request, result, &block) | |
end | |
} | |
end | |
# Handle all other routing | |
["/", "/:user", "/:user/", "/:user/:pass", "/:user/:pass/"].each do |path| | |
get_or_post path do | |
'Ru-roh, you cant do that.' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment