class Gitomator::GitHub::Model::PullRequest

Public Class Methods

new(gh_pull_request, octokit) click to toggle source

@param gh_pull_request [Sawyer::Resource] @param octokit [Octokit::Client]

# File lib/gitomator/github/model/pull_request.rb, line 13
def initialize(gh_pull_request, octokit)
  @r = gh_pull_request
  @octokit = octokit
end

Public Instance Methods

base_branch() click to toggle source
# File lib/gitomator/github/model/pull_request.rb, line 73
def base_branch
  @r.base.label.split(':').last
end
base_repo() click to toggle source

The “destination repo”

# File lib/gitomator/github/model/pull_request.rb, line 69
def base_repo
  Gitomator::GitHub::Model::HostedRepo.new(@r.base.repo)
end
created_at() click to toggle source
# File lib/gitomator/github/model/pull_request.rb, line 31
def created_at
  @r.created_at
end
created_by() click to toggle source
# File lib/gitomator/github/model/pull_request.rb, line 27
def created_by
  @r.user.login
end
head_branch() click to toggle source
# File lib/gitomator/github/model/pull_request.rb, line 64
def head_branch
  @r.head.label.split(':').last
end
head_repo() click to toggle source

The “source repo”

# File lib/gitomator/github/model/pull_request.rb, line 60
def head_repo
  Gitomator::GitHub::Model::HostedRepo.new(@r.head.repo)
end
id() click to toggle source
# File lib/gitomator/github/model/pull_request.rb, line 19
def id
  @r.number
end
mergeable?() click to toggle source

@return true/false/nil

# File lib/gitomator/github/model/pull_request.rb, line 44
def mergeable?
  # In Octokit, the two methods `pull_request` and `pull_requests` return
  # different type of objects (the one returned by `pull_requests` is missing
  # the mergeable? method)
  if (not @r.respond_to? :mergeable?)
    @r = @octokit.pull_request(@r.base.repo.full_name, @r.number)
  end

  if @r.mergeable_state == 'clean'
    return @r.mergeable?
  else
    return nil
  end
end
state() click to toggle source

@return [String] One of 'open', 'close'

# File lib/gitomator/github/model/pull_request.rb, line 37
def state
  @r.state
end
title() click to toggle source
# File lib/gitomator/github/model/pull_request.rb, line 23
def title
  @r.title
end