Skip to content

Instantly share code, notes, and snippets.

@bradylove
Created June 2, 2011 03:46
Show Gist options
  • Save bradylove/1003895 to your computer and use it in GitHub Desktop.
Save bradylove/1003895 to your computer and use it in GitHub Desktop.
require "typhoeus"
require "json"
require "./Constants"
include Constants
include Typhoeus
class Gist
def build_gist
gist = { :description => "This is a test",
:public => true,
:files => { "file1.txt" => { :content => "Testing a sample string" } }
}
json = JSON.pretty_generate(gist)
puts json
return json
end
def send_gist(gist)
url = BASE_URL + "/gists"
request = Request.new(url, :username => USERNAME,
:password => PASSWORD,
:method => :post,
:body => gist)
puts request.params
hydra = Hydra.hydra
hydra.queue(request)
hydra.run
response = request.response
puts response.body
end
end
gist = Gist.new
gist.send_gist(gist.build_gist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment