Sha256: fc7221e4692b917432934038ac47b823d9b8bc2e2c8cba657370efb6cf30a180

Contents?: true

Size: 1.15 KB

Versions: 16

Compression:

Stored size: 1.15 KB

Contents

module Github
  module Refs
    ENDPOINT = URI.join(Github::ROOT_ENDPOINT, 'repos/', "#{Github::OWNER}/", "#{Github::REPO}/", 'git/', 'refs').to_s

    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

    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

    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

    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
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
aleph_analytics-0.4.9.pre.dev lib/github/refs.rb
aleph_analytics-0.4.8 lib/github/refs.rb
aleph_analytics-0.4.7 lib/github/refs.rb
aleph_analytics-0.4.4 lib/github/refs.rb
aleph_analytics-0.4.2 lib/github/refs.rb
aleph_analytics-0.4.1 lib/github/refs.rb
aleph_analytics-0.3.0 lib/github/refs.rb
aleph_analytics-0.2.0 lib/github/refs.rb
aleph_analytics-0.1.0 lib/github/refs.rb
aleph_analytics-0.0.6 lib/github/refs.rb
aleph_analytics-0.0.5 lib/github/refs.rb
aleph_analytics-0.0.4 lib/github/refs.rb
aleph_analytics-0.0.3 lib/github/refs.rb
aleph_analytics-0.0.2 lib/github/refs.rb
aleph_analytics-0.0.1.alpha lib/github/refs.rb
aleph_analytics-0.0.0.alpha lib/github/refs.rb