Class: Apperol::GithubClient

Inherits:
Object
  • Object
show all
Defined in:
lib/apperol/github_client.rb

Instance Method Summary collapse

Instance Method Details

#clientObject



19
20
21
22
23
# File 'lib/apperol/github_client.rb', line 19

def client
  @client ||= Net::HTTP.new(url.hostname, url.port).tap do |http|
    http.use_ssl = true
  end
end

#get(path) ⇒ Object



12
13
14
15
16
17
# File 'lib/apperol/github_client.rb', line 12

def get(path)
  req = Net::HTTP::Get.new(url + path)
  req.basic_auth *Apperol::Creds.github
  res = client.request(req)
  Apperol::Response.new(res.code, res.body, headers: res.to_hash)
end

#tarball(repository, branch = "master") ⇒ Object



6
7
8
9
10
# File 'lib/apperol/github_client.rb', line 6

def tarball(repository, branch = "master")
  tarball_path = "/repos/#{repository}/tarball/#{branch}"
  res = get(tarball_path)
  res.header("Location")
end

#urlObject



25
26
27
# File 'lib/apperol/github_client.rb', line 25

def url
  URI("https://api.github.com")
end