Class: Worklog::Github::PullRequestReviewEvent
- Inherits:
-
Object
- Object
- Worklog::Github::PullRequestReviewEvent
- Defined in:
- lib/github/pull_request_review_event.rb
Overview
Event representing a pull request review
Instance Attribute Summary collapse
-
#created_at ⇒ Time
The creation time of the pull request review, not the pull request itself.
- #creator ⇒ String
- #description ⇒ String
-
#number ⇒ Integer
The pull request number.
-
#repository ⇒ String
The repository name.
-
#state ⇒ String
The state of the review (e.g., ‘approved’, ‘changes_requested’, etc.).
-
#title ⇒ String
The title of the pull request.
-
#url ⇒ String
The URL of the pull request review.
Instance Method Summary collapse
-
#approved? ⇒ Boolean
Whether the pull request review was approved.
-
#initialize(params = {}) ⇒ PullRequestReviewEvent
constructor
A new instance of PullRequestReviewEvent.
-
#to_log_entry(people_storage = nil) ⇒ LogEntry
Convert the PullRequestReviewEvent to a LogEntry.
-
#to_s ⇒ String
String representation of the PullRequestReviewEvent.
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_at ⇒ Time
Returns 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# 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(people_storage = nil) handle = resolve_username(people_storage) || creator = String.new 'Reviewed ' << 'and approved ' if approved? << "PR ##{number} #{handle}: #{title}" LogEntry.new( key: Hasher.sha256("#{repository}-#{number}-#{state}"), source: 'github', time: created_at, 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 private # Resolve the GitHub username to a person handle using the provided PeopleStorage # @param [PeopleStorage, nil] people_storage The PeopleStorage instance to use for resolution # @return [String, nil] The person handle if found, otherwise nil # @example # resolve_username(people_storage) #=> "~johndoe" def resolve_username(people_storage) return if people_storage.nil? person = people_storage.find_by_github_username(creator) person ? "~#{person.handle}" : nil end end |
#creator ⇒ String
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# 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(people_storage = nil) handle = resolve_username(people_storage) || creator = String.new 'Reviewed ' << 'and approved ' if approved? << "PR ##{number} #{handle}: #{title}" LogEntry.new( key: Hasher.sha256("#{repository}-#{number}-#{state}"), source: 'github', time: created_at, 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 private # Resolve the GitHub username to a person handle using the provided PeopleStorage # @param [PeopleStorage, nil] people_storage The PeopleStorage instance to use for resolution # @return [String, nil] The person handle if found, otherwise nil # @example # resolve_username(people_storage) #=> "~johndoe" def resolve_username(people_storage) return if people_storage.nil? person = people_storage.find_by_github_username(creator) person ? "~#{person.handle}" : nil end end |
#description ⇒ String
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# 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(people_storage = nil) handle = resolve_username(people_storage) || creator = String.new 'Reviewed ' << 'and approved ' if approved? << "PR ##{number} #{handle}: #{title}" LogEntry.new( key: Hasher.sha256("#{repository}-#{number}-#{state}"), source: 'github', time: created_at, 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 private # Resolve the GitHub username to a person handle using the provided PeopleStorage # @param [PeopleStorage, nil] people_storage The PeopleStorage instance to use for resolution # @return [String, nil] The person handle if found, otherwise nil # @example # resolve_username(people_storage) #=> "~johndoe" def resolve_username(people_storage) return if people_storage.nil? person = people_storage.find_by_github_username(creator) person ? "~#{person.handle}" : nil end end |
#number ⇒ Integer
Returns 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# 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(people_storage = nil) handle = resolve_username(people_storage) || creator = String.new 'Reviewed ' << 'and approved ' if approved? << "PR ##{number} #{handle}: #{title}" LogEntry.new( key: Hasher.sha256("#{repository}-#{number}-#{state}"), source: 'github', time: created_at, 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 private # Resolve the GitHub username to a person handle using the provided PeopleStorage # @param [PeopleStorage, nil] people_storage The PeopleStorage instance to use for resolution # @return [String, nil] The person handle if found, otherwise nil # @example # resolve_username(people_storage) #=> "~johndoe" def resolve_username(people_storage) return if people_storage.nil? person = people_storage.find_by_github_username(creator) person ? "~#{person.handle}" : nil end end |
#repository ⇒ String
Returns 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# 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(people_storage = nil) handle = resolve_username(people_storage) || creator = String.new 'Reviewed ' << 'and approved ' if approved? << "PR ##{number} #{handle}: #{title}" LogEntry.new( key: Hasher.sha256("#{repository}-#{number}-#{state}"), source: 'github', time: created_at, 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 private # Resolve the GitHub username to a person handle using the provided PeopleStorage # @param [PeopleStorage, nil] people_storage The PeopleStorage instance to use for resolution # @return [String, nil] The person handle if found, otherwise nil # @example # resolve_username(people_storage) #=> "~johndoe" def resolve_username(people_storage) return if people_storage.nil? person = people_storage.find_by_github_username(creator) person ? "~#{person.handle}" : nil end end |
#state ⇒ String
Returns 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# 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(people_storage = nil) handle = resolve_username(people_storage) || creator = String.new 'Reviewed ' << 'and approved ' if approved? << "PR ##{number} #{handle}: #{title}" LogEntry.new( key: Hasher.sha256("#{repository}-#{number}-#{state}"), source: 'github', time: created_at, 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 private # Resolve the GitHub username to a person handle using the provided PeopleStorage # @param [PeopleStorage, nil] people_storage The PeopleStorage instance to use for resolution # @return [String, nil] The person handle if found, otherwise nil # @example # resolve_username(people_storage) #=> "~johndoe" def resolve_username(people_storage) return if people_storage.nil? person = people_storage.find_by_github_username(creator) person ? "~#{person.handle}" : nil end end |
#title ⇒ String
Returns 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# 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(people_storage = nil) handle = resolve_username(people_storage) || creator = String.new 'Reviewed ' << 'and approved ' if approved? << "PR ##{number} #{handle}: #{title}" LogEntry.new( key: Hasher.sha256("#{repository}-#{number}-#{state}"), source: 'github', time: created_at, 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 private # Resolve the GitHub username to a person handle using the provided PeopleStorage # @param [PeopleStorage, nil] people_storage The PeopleStorage instance to use for resolution # @return [String, nil] The person handle if found, otherwise nil # @example # resolve_username(people_storage) #=> "~johndoe" def resolve_username(people_storage) return if people_storage.nil? person = people_storage.find_by_github_username(creator) person ? "~#{person.handle}" : nil end end |
#url ⇒ String
Returns 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# 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(people_storage = nil) handle = resolve_username(people_storage) || creator = String.new 'Reviewed ' << 'and approved ' if approved? << "PR ##{number} #{handle}: #{title}" LogEntry.new( key: Hasher.sha256("#{repository}-#{number}-#{state}"), source: 'github', time: created_at, 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 private # Resolve the GitHub username to a person handle using the provided PeopleStorage # @param [PeopleStorage, nil] people_storage The PeopleStorage instance to use for resolution # @return [String, nil] The person handle if found, otherwise nil # @example # resolve_username(people_storage) #=> "~johndoe" def resolve_username(people_storage) return if people_storage.nil? person = people_storage.find_by_github_username(creator) person ? "~#{person.handle}" : nil end end |
Instance Method Details
#approved? ⇒ Boolean
Whether the pull request review was approved
37 38 39 |
# File 'lib/github/pull_request_review_event.rb', line 37 def approved? state.downcase == 'approved' end |
#to_log_entry(people_storage = nil) ⇒ LogEntry
Convert the PullRequestReviewEvent to a LogEntry
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/github/pull_request_review_event.rb', line 43 def to_log_entry(people_storage = nil) handle = resolve_username(people_storage) || creator = String.new 'Reviewed ' << 'and approved ' if approved? << "PR ##{number} #{handle}: #{title}" LogEntry.new( key: Hasher.sha256("#{repository}-#{number}-#{state}"), source: 'github', time: created_at, message: , url: url ) end |
#to_s ⇒ String
String representation of the PullRequestReviewEvent
60 61 62 |
# File 'lib/github/pull_request_review_event.rb', line 60 def to_s "#<PullRequestReviewEvent repository=#{repository} number=#{number} state=#{state} creator=#{creator} created_at=#{created_at}>" # rubocop:disable Layout/LineLength end |