Class: Policial::PullRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/policial/pull_request.rb

Overview

Public: A GibHub Pull Request.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo:, number:, head_sha:, user: nil) ⇒ PullRequest

Returns a new instance of PullRequest.



6
7
8
9
10
11
# File 'lib/policial/pull_request.rb', line 6

def initialize(repo:, number:, head_sha:, user: nil)
  @repo     = repo
  @number   = number
  @head_sha = head_sha
  @user     = user
end

Instance Attribute Details

#numberObject (readonly)

Returns the value of attribute number.



4
5
6
# File 'lib/policial/pull_request.rb', line 4

def number
  @number
end

#repoObject (readonly)

Returns the value of attribute repo.



4
5
6
# File 'lib/policial/pull_request.rb', line 4

def repo
  @repo
end

#userObject (readonly)

Returns the value of attribute user.



4
5
6
# File 'lib/policial/pull_request.rb', line 4

def user
  @user
end

Instance Method Details

#commentsObject



13
14
15
# File 'lib/policial/pull_request.rb', line 13

def comments
  @comments ||= fetch_comments
end

#filesObject



17
18
19
20
21
22
23
# File 'lib/policial/pull_request.rb', line 17

def files
  @files ||= Policial.octokit.pull_request_files(
    @repo, @number
  ).map do |file|
    build_commit_file(file)
  end
end

#head_commitObject



25
26
27
# File 'lib/policial/pull_request.rb', line 25

def head_commit
  @head_commit ||= Commit.new(@repo, @head_sha)
end