Class: Policial::PullRequest

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

Overview

Public: A GitHub Pull Request.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of PullRequest.



9
10
11
12
13
14
15
# File 'lib/policial/pull_request.rb', line 9

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

Instance Attribute Details

#github_clientObject

Returns the value of attribute github_client.



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

def github_client
  @github_client
end

#numberObject (readonly)

Returns the value of attribute number.



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

def number
  @number
end

#repoObject (readonly)

Returns the value of attribute repo.



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

def repo
  @repo
end

#userObject (readonly)

Returns the value of attribute user.



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

def user
  @user
end

Instance Method Details

#filesObject



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

def files
  @files ||= @github_client.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, @github_client)
end