Class: PdkSync::PullRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/pdksync/pullrequest.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pr_object, git_platform = :github) ⇒ PullRequest

Create a new PR wrapper object setting html_url and number

Parameters:

  • pr_object

    The pull request object to wrap as created by Octokit::Client or Gitlab::Client

  • git_platform (Symbol) (defaults to: :github)

    The Git hosting platform against which the pull request is made



25
26
27
28
29
30
31
32
33
34
# File 'lib/pdksync/pullrequest.rb', line 25

def initialize(pr_object, git_platform = :github)
  case git_platform
  when :github
    @html_url = pr_object.html_url
    @number = pr_object.number
  when :gitlab
    @html_url = pr_object.web_url
    @number = pr_object.iid
  end
end

Instance Attribute Details

#html_urlObject (readonly)

Returns the value of attribute html_url.



17
18
19
# File 'lib/pdksync/pullrequest.rb', line 17

def html_url
  @html_url
end

#numberObject (readonly)

Returns the value of attribute number.



17
18
19
# File 'lib/pdksync/pullrequest.rb', line 17

def number
  @number
end

Class Method Details

.github(pr_object) ⇒ Object



6
7
8
# File 'lib/pdksync/pullrequest.rb', line 6

def github(pr_object)
  new(pr_object)
end

.gitlab(pr_object) ⇒ Object



10
11
12
# File 'lib/pdksync/pullrequest.rb', line 10

def gitlab(pr_object)
  new(pr_object, :gitlab)
end