Class: Worklog::Github::PullRequestReviewEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/github/pull_request_review_event.rb

Overview

Event representing a pull request review

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ PullRequestReviewEvent

Returns a new instance of PullRequestReviewEvent.



29
30
31
32
33
# File 'lib/github/pull_request_review_event.rb', line 29

def initialize(params = {})
  params.each do |key, value|
    send("#{key}=", value) if respond_to?("#{key}=")
  end
end

Instance Attribute Details

#created_atTime

Returns the creation time of the pull request review, not the pull request itself.

Returns:

  • (Time)

    the creation time of the pull request review, not the pull request itself



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/github/pull_request_review_event.rb', line 26

class PullRequestReviewEvent
  attr_accessor :repository, :number, :url, :title, :description, :creator, :created_at, :state

  def initialize(params = {})
    params.each do |key, value|
      send("#{key}=", value) if respond_to?("#{key}=")
    end
  end

  # Whether the pull request review was approved
  # @return [Boolean]
  def approved?
    state.downcase == 'approved'
  end

  # Convert the PullRequestReviewEvent to a LogEntry
  # @return [LogEntry]
  def to_log_entry
    message = String.new 'Reviewed '
    message << 'and approved ' if approved?
    message << "PR ##{number} #{creator}: #{title}"
    LogEntry.new(
      key: Hasher.sha256("#{repository}-#{number}-#{state}"),
      source: 'github',
      time: created_at,
      message: message,
      url: url
    )
  end

  # String representation of the PullRequestReviewEvent
  # @return [String]
  def to_s
    "#<PullRequestReviewEvent repository=#{repository} number=#{number} state=#{state} creator=#{creator} created_at=#{created_at}>" # rubocop:disable Layout/LineLength
  end
end

#creatorString

Returns:

  • (String)

    the description of the pull request

  • (String)

    the username of the pull request creator



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/github/pull_request_review_event.rb', line 26

class PullRequestReviewEvent
  attr_accessor :repository, :number, :url, :title, :description, :creator, :created_at, :state

  def initialize(params = {})
    params.each do |key, value|
      send("#{key}=", value) if respond_to?("#{key}=")
    end
  end

  # Whether the pull request review was approved
  # @return [Boolean]
  def approved?
    state.downcase == 'approved'
  end

  # Convert the PullRequestReviewEvent to a LogEntry
  # @return [LogEntry]
  def to_log_entry
    message = String.new 'Reviewed '
    message << 'and approved ' if approved?
    message << "PR ##{number} #{creator}: #{title}"
    LogEntry.new(
      key: Hasher.sha256("#{repository}-#{number}-#{state}"),
      source: 'github',
      time: created_at,
      message: message,
      url: url
    )
  end

  # String representation of the PullRequestReviewEvent
  # @return [String]
  def to_s
    "#<PullRequestReviewEvent repository=#{repository} number=#{number} state=#{state} creator=#{creator} created_at=#{created_at}>" # rubocop:disable Layout/LineLength
  end
end

#descriptionString

Returns:

  • (String)

    the description of the pull request

  • (String)

    the username of the pull request creator



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/github/pull_request_review_event.rb', line 26

class PullRequestReviewEvent
  attr_accessor :repository, :number, :url, :title, :description, :creator, :created_at, :state

  def initialize(params = {})
    params.each do |key, value|
      send("#{key}=", value) if respond_to?("#{key}=")
    end
  end

  # Whether the pull request review was approved
  # @return [Boolean]
  def approved?
    state.downcase == 'approved'
  end

  # Convert the PullRequestReviewEvent to a LogEntry
  # @return [LogEntry]
  def to_log_entry
    message = String.new 'Reviewed '
    message << 'and approved ' if approved?
    message << "PR ##{number} #{creator}: #{title}"
    LogEntry.new(
      key: Hasher.sha256("#{repository}-#{number}-#{state}"),
      source: 'github',
      time: created_at,
      message: message,
      url: url
    )
  end

  # String representation of the PullRequestReviewEvent
  # @return [String]
  def to_s
    "#<PullRequestReviewEvent repository=#{repository} number=#{number} state=#{state} creator=#{creator} created_at=#{created_at}>" # rubocop:disable Layout/LineLength
  end
end

#numberInteger

Returns the pull request number.

Returns:

  • (Integer)

    the pull request number



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/github/pull_request_review_event.rb', line 26

class PullRequestReviewEvent
  attr_accessor :repository, :number, :url, :title, :description, :creator, :created_at, :state

  def initialize(params = {})
    params.each do |key, value|
      send("#{key}=", value) if respond_to?("#{key}=")
    end
  end

  # Whether the pull request review was approved
  # @return [Boolean]
  def approved?
    state.downcase == 'approved'
  end

  # Convert the PullRequestReviewEvent to a LogEntry
  # @return [LogEntry]
  def to_log_entry
    message = String.new 'Reviewed '
    message << 'and approved ' if approved?
    message << "PR ##{number} #{creator}: #{title}"
    LogEntry.new(
      key: Hasher.sha256("#{repository}-#{number}-#{state}"),
      source: 'github',
      time: created_at,
      message: message,
      url: url
    )
  end

  # String representation of the PullRequestReviewEvent
  # @return [String]
  def to_s
    "#<PullRequestReviewEvent repository=#{repository} number=#{number} state=#{state} creator=#{creator} created_at=#{created_at}>" # rubocop:disable Layout/LineLength
  end
end

#repositoryString

Returns the repository name.

Returns:

  • (String)

    the repository name



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/github/pull_request_review_event.rb', line 26

class PullRequestReviewEvent
  attr_accessor :repository, :number, :url, :title, :description, :creator, :created_at, :state

  def initialize(params = {})
    params.each do |key, value|
      send("#{key}=", value) if respond_to?("#{key}=")
    end
  end

  # Whether the pull request review was approved
  # @return [Boolean]
  def approved?
    state.downcase == 'approved'
  end

  # Convert the PullRequestReviewEvent to a LogEntry
  # @return [LogEntry]
  def to_log_entry
    message = String.new 'Reviewed '
    message << 'and approved ' if approved?
    message << "PR ##{number} #{creator}: #{title}"
    LogEntry.new(
      key: Hasher.sha256("#{repository}-#{number}-#{state}"),
      source: 'github',
      time: created_at,
      message: message,
      url: url
    )
  end

  # String representation of the PullRequestReviewEvent
  # @return [String]
  def to_s
    "#<PullRequestReviewEvent repository=#{repository} number=#{number} state=#{state} creator=#{creator} created_at=#{created_at}>" # rubocop:disable Layout/LineLength
  end
end

#stateString

Returns the state of the review (e.g., ‘approved’, ‘changes_requested’, etc.).

Returns:

  • (String)

    the state of the review (e.g., ‘approved’, ‘changes_requested’, etc.)



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/github/pull_request_review_event.rb', line 26

class PullRequestReviewEvent
  attr_accessor :repository, :number, :url, :title, :description, :creator, :created_at, :state

  def initialize(params = {})
    params.each do |key, value|
      send("#{key}=", value) if respond_to?("#{key}=")
    end
  end

  # Whether the pull request review was approved
  # @return [Boolean]
  def approved?
    state.downcase == 'approved'
  end

  # Convert the PullRequestReviewEvent to a LogEntry
  # @return [LogEntry]
  def to_log_entry
    message = String.new 'Reviewed '
    message << 'and approved ' if approved?
    message << "PR ##{number} #{creator}: #{title}"
    LogEntry.new(
      key: Hasher.sha256("#{repository}-#{number}-#{state}"),
      source: 'github',
      time: created_at,
      message: message,
      url: url
    )
  end

  # String representation of the PullRequestReviewEvent
  # @return [String]
  def to_s
    "#<PullRequestReviewEvent repository=#{repository} number=#{number} state=#{state} creator=#{creator} created_at=#{created_at}>" # rubocop:disable Layout/LineLength
  end
end

#titleString

Returns the title of the pull request.

Returns:

  • (String)

    the title of the pull request



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/github/pull_request_review_event.rb', line 26

class PullRequestReviewEvent
  attr_accessor :repository, :number, :url, :title, :description, :creator, :created_at, :state

  def initialize(params = {})
    params.each do |key, value|
      send("#{key}=", value) if respond_to?("#{key}=")
    end
  end

  # Whether the pull request review was approved
  # @return [Boolean]
  def approved?
    state.downcase == 'approved'
  end

  # Convert the PullRequestReviewEvent to a LogEntry
  # @return [LogEntry]
  def to_log_entry
    message = String.new 'Reviewed '
    message << 'and approved ' if approved?
    message << "PR ##{number} #{creator}: #{title}"
    LogEntry.new(
      key: Hasher.sha256("#{repository}-#{number}-#{state}"),
      source: 'github',
      time: created_at,
      message: message,
      url: url
    )
  end

  # String representation of the PullRequestReviewEvent
  # @return [String]
  def to_s
    "#<PullRequestReviewEvent repository=#{repository} number=#{number} state=#{state} creator=#{creator} created_at=#{created_at}>" # rubocop:disable Layout/LineLength
  end
end

#urlString

Returns the URL of the pull request review.

Returns:

  • (String)

    the URL of the pull request review



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/github/pull_request_review_event.rb', line 26

class PullRequestReviewEvent
  attr_accessor :repository, :number, :url, :title, :description, :creator, :created_at, :state

  def initialize(params = {})
    params.each do |key, value|
      send("#{key}=", value) if respond_to?("#{key}=")
    end
  end

  # Whether the pull request review was approved
  # @return [Boolean]
  def approved?
    state.downcase == 'approved'
  end

  # Convert the PullRequestReviewEvent to a LogEntry
  # @return [LogEntry]
  def to_log_entry
    message = String.new 'Reviewed '
    message << 'and approved ' if approved?
    message << "PR ##{number} #{creator}: #{title}"
    LogEntry.new(
      key: Hasher.sha256("#{repository}-#{number}-#{state}"),
      source: 'github',
      time: created_at,
      message: message,
      url: url
    )
  end

  # String representation of the PullRequestReviewEvent
  # @return [String]
  def to_s
    "#<PullRequestReviewEvent repository=#{repository} number=#{number} state=#{state} creator=#{creator} created_at=#{created_at}>" # rubocop:disable Layout/LineLength
  end
end

Instance Method Details

#approved?Boolean

Whether the pull request review was approved

Returns:

  • (Boolean)


37
38
39
# File 'lib/github/pull_request_review_event.rb', line 37

def approved?
  state.downcase == 'approved'
end

#to_log_entryLogEntry

Convert the PullRequestReviewEvent to a LogEntry

Returns:



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/github/pull_request_review_event.rb', line 43

def to_log_entry
  message = String.new 'Reviewed '
  message << 'and approved ' if approved?
  message << "PR ##{number} #{creator}: #{title}"
  LogEntry.new(
    key: Hasher.sha256("#{repository}-#{number}-#{state}"),
    source: 'github',
    time: created_at,
    message: message,
    url: url
  )
end

#to_sString

String representation of the PullRequestReviewEvent

Returns:

  • (String)


58
59
60
# File 'lib/github/pull_request_review_event.rb', line 58

def to_s
  "#<PullRequestReviewEvent repository=#{repository} number=#{number} state=#{state} creator=#{creator} created_at=#{created_at}>" # rubocop:disable Layout/LineLength
end