module Github::Refs

Constants

ENDPOINT

Public Class Methods

create(ref, sha) click to toggle source
# File lib/github/refs.rb, line 17
def self.create(ref, sha)
  ref = "refs/#{ref}"
  params = {
    'ref' => ref,
    'sha' => sha
  }

  resp = Github.post(ENDPOINT, params)
  raise "Github refs POST failed with http code: #{resp.code}" if resp.code != '201'
  ActiveSupport::JSON.decode(resp.body)
end
get(ref) click to toggle source
# File lib/github/refs.rb, line 5
def self.get(ref)
  resp = Github.get("#{ENDPOINT}/#{ref}")
  raise "Github refs POST failed with http code: #{resp.code}" if resp.code != '200'
  ActiveSupport::JSON.decode(resp.body)
end
get_all() click to toggle source
# File lib/github/refs.rb, line 11
def self.get_all
  resp = Github.get(ENDPOINT)
  raise "Github refs POST failed with http code: #{resp.code}" if resp.code != '200'
  ActiveSupport::JSON.decode(resp.body)
end
update(ref, sha) click to toggle source
# File lib/github/refs.rb, line 29
def self.update(ref, sha)
  params = {
    'sha' => sha,
    'force' => true
  }
  resp = Github.patch("#{ENDPOINT}/#{ref}", params)
  raise "Github refs update failed with http code: #{resp.code}" if resp.code != '200'
  ActiveSupport::JSON.decode(resp.body)
end