Skip to content

Instantly share code, notes, and snippets.

@kyleburton
Created September 8, 2011 16:29
Show Gist options
  • Save kyleburton/1203835 to your computer and use it in GitHub Desktop.
Save kyleburton/1203835 to your computer and use it in GitHub Desktop.
Rakefile for Chris B. B.
require 'rubygems'
require 'fileutils'
require 'net/http'
require 'net/https'
require 'json'
require 'pp'
def http_get url
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
http.request(request)
end
desc "my frist task"
task :runme do
puts "In runme!"
end
desc "update the rakefile from the gist"
task :update do
response = http_get "https://api.github.com/gists/1203835"
info = JSON.parse(response.body)
#pp info
raw_url = info['files']['sample-Rakefile.rb']['raw_url']
raw_url.sub! '/raw/', '/gist/'
raw_url.sub! '/gist.', '/raw.'
#puts raw_url
new_content = http_get raw_url
File.open('Rakefile','w') do |f|
f.write new_content
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment