Class: ClaudeTaskMaster::PRComment
- Inherits:
-
Object
- Object
- ClaudeTaskMaster::PRComment
- Defined in:
- lib/claude_task_master/pr_comment.rb
Overview
Represents a GitHub PR review comment Detects CodeRabbit, Copilot, and other review bot comments
Constant Summary collapse
- ACTIONABLE_SEVERITIES =
%w[major critical warning].freeze
- CODERABBIT_BOT =
Known bot authors
'coderabbitai[bot]'- COPILOT_BOT =
'github-copilot[bot]'- KNOWN_BOTS =
[CODERABBIT_BOT, COPILOT_BOT].freeze
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#html_url ⇒ Object
readonly
Returns the value of attribute html_url.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#resolved ⇒ Object
readonly
Returns the value of attribute resolved.
-
#start_line ⇒ Object
readonly
Returns the value of attribute start_line.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Class Method Summary collapse
-
.from_api_response(data) ⇒ Object
Create collection from API response.
Instance Method Summary collapse
-
#actionable? ⇒ Boolean
Check if comment requires attention.
- #from_bot? ⇒ Boolean
-
#from_coderabbit? ⇒ Boolean
Bot detection.
- #from_copilot? ⇒ Boolean
- #from_human? ⇒ Boolean
-
#has_suggestion? ⇒ Boolean
Check if comment has committable suggestion.
-
#initialize(attrs = {}) ⇒ PRComment
constructor
A new instance of PRComment.
-
#line_range ⇒ Object
Line range as string (e.g., “40-42” or “42”).
-
#resolved? ⇒ Boolean
Resolved status.
-
#severity ⇒ Object
Parse severity from CodeRabbit/Copilot comment body.
-
#suggestion_code ⇒ Object
Extract suggestion code from body.
-
#summary ⇒ Object
Extract summary from comment body.
-
#to_h ⇒ Object
Serialize to hash.
- #unresolved? ⇒ Boolean
Constructor Details
#initialize(attrs = {}) ⇒ PRComment
Returns a new instance of PRComment.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/claude_task_master/pr_comment.rb', line 17 def initialize(attrs = {}) @id = attrs[:id] || attrs['id'] @file_path = attrs[:path] || attrs['path'] @line = attrs[:line] || attrs['line'] @start_line = attrs[:start_line] || attrs['start_line'] @body = attrs[:body] || attrs['body'] @author = (attrs[:user] || attrs['user']) @created_at = attrs[:created_at] || attrs['created_at'] @updated_at = attrs[:updated_at] || attrs['updated_at'] @html_url = attrs[:html_url] || attrs['html_url'] @resolved = attrs[:resolved] || attrs['resolved'] end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
14 15 16 |
# File 'lib/claude_task_master/pr_comment.rb', line 14 def @author end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
14 15 16 |
# File 'lib/claude_task_master/pr_comment.rb', line 14 def body @body end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/claude_task_master/pr_comment.rb', line 14 def created_at @created_at end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
14 15 16 |
# File 'lib/claude_task_master/pr_comment.rb', line 14 def file_path @file_path end |
#html_url ⇒ Object (readonly)
Returns the value of attribute html_url.
14 15 16 |
# File 'lib/claude_task_master/pr_comment.rb', line 14 def html_url @html_url end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/claude_task_master/pr_comment.rb', line 14 def id @id end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
14 15 16 |
# File 'lib/claude_task_master/pr_comment.rb', line 14 def line @line end |
#resolved ⇒ Object (readonly)
Returns the value of attribute resolved.
14 15 16 |
# File 'lib/claude_task_master/pr_comment.rb', line 14 def resolved @resolved end |
#start_line ⇒ Object (readonly)
Returns the value of attribute start_line.
14 15 16 |
# File 'lib/claude_task_master/pr_comment.rb', line 14 def start_line @start_line end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
14 15 16 |
# File 'lib/claude_task_master/pr_comment.rb', line 14 def updated_at @updated_at end |
Class Method Details
.from_api_response(data) ⇒ Object
Create collection from API response
31 32 33 34 |
# File 'lib/claude_task_master/pr_comment.rb', line 31 def self.from_api_response(data) data = [data] unless data.is_a?(Array) data.map { |item| new(item) } end |
Instance Method Details
#actionable? ⇒ Boolean
Check if comment requires attention
55 56 57 |
# File 'lib/claude_task_master/pr_comment.rb', line 55 def actionable? ACTIONABLE_SEVERITIES.include?(severity) end |
#from_bot? ⇒ Boolean
68 69 70 |
# File 'lib/claude_task_master/pr_comment.rb', line 68 def from_bot? KNOWN_BOTS.include?() || &.end_with?('[bot]') end |
#from_coderabbit? ⇒ Boolean
Bot detection
60 61 62 |
# File 'lib/claude_task_master/pr_comment.rb', line 60 def from_coderabbit? == CODERABBIT_BOT end |
#from_copilot? ⇒ Boolean
64 65 66 |
# File 'lib/claude_task_master/pr_comment.rb', line 64 def from_copilot? == COPILOT_BOT end |
#from_human? ⇒ Boolean
72 73 74 |
# File 'lib/claude_task_master/pr_comment.rb', line 72 def from_human? !from_bot? end |
#has_suggestion? ⇒ Boolean
Check if comment has committable suggestion
86 87 88 |
# File 'lib/claude_task_master/pr_comment.rb', line 86 def has_suggestion? body&.include?('```suggestion') || false end |
#line_range ⇒ Object
Line range as string (e.g., “40-42” or “42”)
37 38 39 40 41 42 |
# File 'lib/claude_task_master/pr_comment.rb', line 37 def line_range @line_range ||= begin start = start_line || line start == line ? line.to_s : "#{start}-#{line}" end end |
#resolved? ⇒ Boolean
Resolved status
77 78 79 |
# File 'lib/claude_task_master/pr_comment.rb', line 77 def resolved? @resolved == true end |
#severity ⇒ Object
Parse severity from CodeRabbit/Copilot comment body
45 46 47 |
# File 'lib/claude_task_master/pr_comment.rb', line 45 def severity @severity ||= parse_severity end |
#suggestion_code ⇒ Object
Extract suggestion code from body
91 92 93 94 95 96 97 98 |
# File 'lib/claude_task_master/pr_comment.rb', line 91 def suggestion_code @suggestion_code ||= begin return nil unless body&.include?('```suggestion') match = body.match(/```suggestion[^\n]*\n(.*?)\n```/m) match ? match[1] : nil end end |
#summary ⇒ Object
Extract summary from comment body
50 51 52 |
# File 'lib/claude_task_master/pr_comment.rb', line 50 def summary @summary ||= extract_summary end |
#to_h ⇒ Object
Serialize to hash
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/claude_task_master/pr_comment.rb', line 101 def to_h { id: id, file_path: file_path, line_range: line_range, author: , severity: severity, summary: summary, actionable: actionable?, from_bot: from_bot?, resolved: resolved?, has_suggestion: has_suggestion?, html_url: html_url } end |
#unresolved? ⇒ Boolean
81 82 83 |
# File 'lib/claude_task_master/pr_comment.rb', line 81 def unresolved? @resolved == false end |