class Apperol::HerokuClient
Public Instance Methods
builds_client()
click to toggle source
# File lib/apperol/heroku_client.rb, line 31 def builds_client @builds_client ||= Net::HTTP.new(builds_url.hostname, 443).tap do |http| http.use_ssl = true end end
builds_url()
click to toggle source
# File lib/apperol/heroku_client.rb, line 37 def builds_url URI("https://build-output.heroku.com") end
client()
click to toggle source
# File lib/apperol/heroku_client.rb, line 48 def client @client ||= Net::HTTP.new("api.heroku.com", 443).tap do |http| http.use_ssl = true end end
default_headers()
click to toggle source
# File lib/apperol/heroku_client.rb, line 41 def default_headers { "Content-Type" => "application/json", "Accept" => "application/vnd.heroku+json; version=edge" } end
get(url)
click to toggle source
# File lib/apperol/heroku_client.rb, line 6 def get(url) request = Net::HTTP::Get.new(url, initheader = default_headers) request.basic_auth *Apperol::Creds.heroku res = client.request(request) Apperol::Response.new(res.code, res.body) end
post(url, body)
click to toggle source
# File lib/apperol/heroku_client.rb, line 13 def post(url, body) request = Net::HTTP::Post.new(url, initheader = default_headers) request.basic_auth *Apperol::Creds.heroku request.body = body res = client.request(request) Apperol::Response.new(res.code, res.body) end
stream_build(url) { |chunk| ... }
click to toggle source
# File lib/apperol/heroku_client.rb, line 21 def stream_build(url) req = Net::HTTP::Get.new(url, initheader = default_headers) req.basic_auth *Apperol::Creds.heroku builds_client.request req do |response| response.read_body do |chunk| yield chunk end end end