Class: Gitomator::GitHub::Model::PullRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/gitomator/github/model/pull_request.rb

Instance Method Summary collapse

Constructor Details

#initialize(gh_pull_request, octokit) ⇒ PullRequest

Returns a new instance of PullRequest.

Parameters:

  • gh_pull_request (Sawyer::Resource)
  • octokit (Octokit::Client)


13
14
15
16
# File 'lib/gitomator/github/model/pull_request.rb', line 13

def initialize(gh_pull_request, octokit)
  @r = gh_pull_request
  @octokit = octokit
end

Instance Method Details

#base_branchObject



73
74
75
# File 'lib/gitomator/github/model/pull_request.rb', line 73

def base_branch
  @r.base.label.split(':').last
end

#base_repoObject

The “destination repo”



69
70
71
# File 'lib/gitomator/github/model/pull_request.rb', line 69

def base_repo
  Gitomator::GitHub::Model::HostedRepo.new(@r.base.repo)
end

#created_atObject



31
32
33
# File 'lib/gitomator/github/model/pull_request.rb', line 31

def created_at
  @r.created_at
end

#created_byObject



27
28
29
# File 'lib/gitomator/github/model/pull_request.rb', line 27

def created_by
  @r.user.
end

#head_branchObject



64
65
66
# File 'lib/gitomator/github/model/pull_request.rb', line 64

def head_branch
  @r.head.label.split(':').last
end

#head_repoObject

The “source repo”



60
61
62
# File 'lib/gitomator/github/model/pull_request.rb', line 60

def head_repo
  Gitomator::GitHub::Model::HostedRepo.new(@r.head.repo)
end

#idObject



19
20
21
# File 'lib/gitomator/github/model/pull_request.rb', line 19

def id
  @r.number
end

#mergeable?Boolean

Returns true/false/nil.

Returns:

  • (Boolean)

    true/false/nil



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# 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

#stateString

Returns One of ‘open’, ‘close’.

Returns:

  • (String)

    One of ‘open’, ‘close’



37
38
39
# File 'lib/gitomator/github/model/pull_request.rb', line 37

def state
  @r.state
end

#titleObject



23
24
25
# File 'lib/gitomator/github/model/pull_request.rb', line 23

def title
  @r.title
end