def check
      @nwo, @sha = parse_commit_url @commit_url
      begin
        @commit = @client.commit @nwo, @sha
      rescue ArgumentError
        raise ContributionChecker::InvalidCommitUrlError
      rescue Octokit::NotFound
        raise ContributionChecker::InvalidCommitUrlError
      rescue Octokit::Unauthorized
        raise ContributionChecker::InvalidAccessTokenError
      end
      @repo = @client.repository @nwo
      @user = @client.user

      @commit_email_is_not_generic = commit_email_is_not_generic?
      @commit_in_valid_branch = commit_in_valid_branch?
      @repo_not_a_fork = !repository_is_fork?
      @commit_email_linked_to_user = commit_email_linked_to_user?
      @user_has_starred_repo = user_has_starred_repo?
      @user_can_push_to_repo = user_can_push_to_repo?
      @user_is_repo_org_member = user_is_repo_org_member?
      @user_has_fork_of_repo = user_has_fork_of_repo?
      @user_has_opened_issue_or_pr_in_repo = user_has_opened_issue_or_pr_in_repo?

      {
        :contribution => and_criteria_met? && or_criteria_met?,
        :and_criteria => {
          :commit_email_is_not_generic => @commit_email_is_not_generic,
          :commit_in_valid_branch      => @commit_in_valid_branch,
          :repo_not_a_fork             => @repo_not_a_fork,
          :commit_email_linked_to_user => @commit_email_linked_to_user,
          :commit_email                => @commit[:commit][:author][:email],
          :default_branch              => @repo[:default_branch],
        },
        :or_criteria => {
          :user_has_starred_repo               => @user_has_starred_repo,
          :user_can_push_to_repo               => @user_can_push_to_repo,
          :user_is_repo_org_member             => @user_is_repo_org_member,
          :user_has_fork_of_repo               => @user_has_fork_of_repo,
          :user_has_opened_issue_or_pr_in_repo => @user_has_opened_issue_or_pr_in_repo,
        }
      }
    end
def check
      @nwo, @sha = parse_commit_url @commit_url
      begin
        @commit = @client.commit @nwo, @sha
      rescue ArgumentError
        raise ContributionChecker::InvalidCommitUrlError
      rescue Octokit::NotFound
        raise ContributionChecker::InvalidCommitUrlError
      rescue Octokit::Unauthorized
        raise ContributionChecker::InvalidAccessTokenError
      end
      @repo = @client.repository @nwo
      @user = @client.user

      @commit_email_is_not_generic = commit_email_is_not_generic?
      @commit_in_valid_branch = commit_in_valid_branch?
      @repo_not_a_fork = !repository_is_fork?
      @commit_email_linked_to_user = commit_email_linked_to_user?
      @user_has_starred_repo = user_has_starred_repo?
      @user_can_push_to_repo = user_can_push_to_repo?
      @user_is_repo_org_member = user_is_repo_org_member?
      @user_has_fork_of_repo = user_has_fork_of_repo?
      @user_has_opened_issue_or_pr_in_repo = user_has_opened_issue_or_pr_in_repo?

      {
        :contribution => and_criteria_met? && or_criteria_met?,
        :and_criteria => {
          :commit_email_is_not_generic => @commit_email_is_not_generic,
          :commit_in_valid_branch      => @commit_in_valid_branch,
          :repo_not_a_fork             => @repo_not_a_fork,
          :commit_email_linked_to_user => @commit_email_linked_to_user,
          :commit_email                => @commit[:commit][:author][:email],
          :default_branch              => @repo[:default_branch],
        },
        :or_criteria => {
          :user_has_starred_repo               => @user_has_starred_repo,
          :user_can_push_to_repo               => @user_can_push_to_repo,
          :user_is_repo_org_member             => @user_is_repo_org_member,
          :user_has_fork_of_repo               => @user_has_fork_of_repo,
          :user_has_opened_issue_or_pr_in_repo => @user_has_opened_issue_or_pr_in_repo,
        }
      }
    end
def check @nwo , @sha = parse_commit_url @commit_url begin @commit = @client . commit @nwo , @sha rescue ArgumentError raise ContributionChecker :: InvalidCommitUrlError rescue Octokit :: NotFound raise ContributionChecker :: InvalidCommitUrlError rescue Octokit :: Unauthorized raise ContributionChecker :: InvalidAccessTokenError end @repo = @client . repository @nwo @user = @client . user @commit_email_is_not_generic = commit_email_is_not_generic? @commit_in_valid_branch = commit_in_valid_branch? @repo_not_a_fork = ! repository_is_fork? @commit_email_linked_to_user = commit_email_linked_to_user? @user_has_starred_repo = user_has_starred_repo? @user_can_push_to_repo = user_can_push_to_repo? @user_is_repo_org_member = user_is_repo_org_member? @user_has_fork_of_repo = user_has_fork_of_repo? @user_has_opened_issue_or_pr_in_repo = user_has_opened_issue_or_pr_in_repo? { :contribution => and_criteria_met? && or_criteria_met? , :and_criteria => { :commit_email_is_not_generic => @commit_email_is_not_generic , :commit_in_valid_branch => @commit_in_valid_branch , :repo_not_a_fork => @repo_not_a_fork , :commit_email_linked_to_user => @commit_email_linked_to_user , :commit_email => @commit [ :commit ] [ :author ] [ :email ] , :default_branch => @repo [ :default_branch ] , } , :or_criteria => { :user_has_starred_repo => @user_has_starred_repo , :user_can_push_to_repo => @user_can_push_to_repo , :user_is_repo_org_member => @user_is_repo_org_member , :user_has_fork_of_repo => @user_has_fork_of_repo , :user_has_opened_issue_or_pr_in_repo => @user_has_opened_issue_or_pr_in_repo , } } end
Initialise a new Checker instance with an API access token and commit URL.

 @param options [Hash] Options which should take the form:
 {
   :access_token => "<Your 40 char GitHub API token>",
   :commit_url   => "https://github.com/user/repo/commit/sha"
 }

 @return [ContributionChecker::Checker] Contribution checker initialised
 for an authenticated user and a specific commit
 Checks whether the commit is counted as a contribution for the
 authenticated user.

 @return [Hash] The return value takes the following form:
 {
   :contribution => true,
   :and_criteria => {
     :commit_email_is_not_generic => true,
     :commit_in_valid_branch      => true,
     :repo_not_a_fork             => true,
     :commit_email_linked_to_user => true,
     :commit_email                => "me@foo.com",
     :default_branch              => "master"
   },
   :or_criteria => {
     :user_has_starred_repo               => false,
     :user_can_push_to_repo               => false,
     :user_is_repo_org_member             => true,
     :user_has_fork_of_repo               => false,
     :user_has_opened_issue_or_pr_in_repo => false
   }
 }
Initialise a new Checker instance with an API access token and commit URL .