Sha256: 4d634832d007534d00faf195c636f6de6fc100d1c6fa446d6a089af6fd43052e

Contents?: true

Size: 954 Bytes

Versions: 4

Compression:

Stored size: 954 Bytes

Contents

# @summary A simple wrapper class around Github pull request and Gitlab merge
#   request objects used to abstract the differences and provide a common
#   interface to PR URL and number/id.
class PdkSync::PullRequest
  class << self
    def github(pr_object)
      new(pr_object)
    end

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

    private :new
  end

  attr_reader :html_url, :number

  # Create a new PR wrapper object setting html_url and number
  # @param pr_object
  #   The pull request object to wrap as created by Octokit::Client or
  #   Gitlab::Client
  # @param [Symbol] git_platform
  #   The Git hosting platform against which the pull request is made
  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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pdksync-0.8.0 lib/pdksync/pullrequest.rb
pdksync-0.6.0 lib/pdksync/pullrequest.rb
pdksync-0.5.0 lib/pdksync/pullrequest.rb
pdksync-0.4.0 lib/pdksync/pullrequest.rb