Sha256: 8ac4fe70fc0f330a4c5450265be9f0bb43d283bcdc5d6c10bf6c30308eae61ae

Contents?: true

Size: 861 Bytes

Versions: 1

Compression:

Stored size: 861 Bytes

Contents

require "octokit"

module Codestatus
  module Repositories
    class GitHubRepository < Base
      # combined status on github
      # https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref
      def status(ref = default_branch)
        response = client.combined_status(slug, ref)

        BuildStatus.new(sha: response.sha, status: response.state)
      end

      # https://github.com/meganemura/codestatus
      def html_url
        repository['html_url']
      end

      private

      def default_branch
        repository['default_branch']
      end

      def repository
        @repository ||= client.repository(slug)
      end

      def client
        @client ||= Octokit::Client.new(access_token: access_token)
      end

      def access_token
        ENV['CODESTATUS_GITHUB_TOKEN']
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
codestatus-0.1.3 lib/codestatus/repositories/github_repository.rb