From b0f093af621f6eb3fc9d659146cf41186e30b029 Mon Sep 17 00:00:00 2001 From: Tim Kelty Date: Wed, 17 Nov 2010 13:59:46 -0500 Subject: [PATCH 1/3] Create gist working again, using v1 api --- Support/lib/gist.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Support/lib/gist.rb b/Support/lib/gist.rb index 6a80d9c..b99d3fc 100755 --- a/Support/lib/gist.rb +++ b/Support/lib/gist.rb @@ -24,13 +24,14 @@ def add_file(name, content) def send(private_gist) load_files - url = URI.parse('https://gist.github.com/gists') - req = Net::HTTP.post_form(url, data(private_gist)) + url = URI.parse('http://gist.github.com/api/v1/json/new') + req = Net::HTTP.post_form(url, data(private_gist)) case req when Net::HTTPBadRequest print "Ewww, not your fault, but something bad happened. No gist created." - when Net::HTTPFound - url = copy req['Location'] + when Net::HTTPOK + repo = req.body.match(/repo\"\:\"(\d+)\"/)[1] + url = copy 'http://gist.github.com/' + repo print "Created gist at #{url}. URL copied to clipboard." end clear From 6fb0e38e131ea0442e90abd9a9b3c0ba23066599 Mon Sep 17 00:00:00 2001 From: John Dyer Date: Thu, 2 Dec 2010 09:45:50 -0500 Subject: [PATCH 2/3] Fixed a regex issue with the send method in gist.rb --- Support/lib/gist.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Support/lib/gist.rb b/Support/lib/gist.rb index b99d3fc..0bdf67e 100755 --- a/Support/lib/gist.rb +++ b/Support/lib/gist.rb @@ -30,7 +30,7 @@ def send(private_gist) when Net::HTTPBadRequest print "Ewww, not your fault, but something bad happened. No gist created." when Net::HTTPOK - repo = req.body.match(/repo\"\:\"(\d+)\"/)[1] + repo = req.body.scan(/\"repo\":\"(\w+)\"/).to_s url = copy 'http://gist.github.com/' + repo print "Created gist at #{url}. URL copied to clipboard." end From e6331e9588715a3d778b899ce950c07b98fa0dca Mon Sep 17 00:00:00 2001 From: John Dyer Date: Thu, 2 Dec 2010 09:45:50 -0500 Subject: [PATCH 3/3] Fixed a regex issue with the send method in gist.rb --- Support/lib/gist.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Support/lib/gist.rb b/Support/lib/gist.rb index b99d3fc..0bdf67e 100755 --- a/Support/lib/gist.rb +++ b/Support/lib/gist.rb @@ -30,7 +30,7 @@ def send(private_gist) when Net::HTTPBadRequest print "Ewww, not your fault, but something bad happened. No gist created." when Net::HTTPOK - repo = req.body.match(/repo\"\:\"(\d+)\"/)[1] + repo = req.body.scan(/\"repo\":\"(\w+)\"/).to_s url = copy 'http://gist.github.com/' + repo print "Created gist at #{url}. URL copied to clipboard." end