Class: RailsErrorDashboard::Services::IssueTrackerClient
- Inherits:
-
Object
- Object
- RailsErrorDashboard::Services::IssueTrackerClient
- Defined in:
- lib/rails_error_dashboard/services/issue_tracker_client.rb
Overview
Base class and factory for issue tracker API clients.
Supports GitHub, GitLab, Codeberg/Gitea/Forgejo, and Linear via a unified interface. Each provider implements the same methods with provider-specific API calls.
Direct Known Subclasses
CodebergIssueClient, GitHubIssueClient, GitLabIssueClient, LinearIssueClient
Constant Summary collapse
- REQUEST_TIMEOUT =
seconds
15- MAX_BODY_LENGTH =
GitHub has ~65K limit for issue body
65_000
Instance Attribute Summary collapse
-
#api_url ⇒ Object
readonly
Returns the value of attribute api_url.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
-
.for(provider, token:, repo:, api_url: nil) ⇒ IssueTrackerClient
Factory method — returns the correct client for the provider.
-
.from_config ⇒ IssueTrackerClient?
Build a client from the current gem configuration.
Instance Method Summary collapse
-
#add_comment(number:, body:) ⇒ Hash
Add a comment to an issue.
-
#close_issue(number:) ⇒ Hash
Close an issue.
-
#create_issue(title:, body:, labels: []) ⇒ Hash
Create an issue on the platform.
-
#fetch_comments(number:, per_page: 10) ⇒ Hash
Fetch comments from an issue.
-
#fetch_issue(number:) ⇒ Hash
Fetch issue details (status, assignees, labels).
-
#initialize(token:, repo:, api_url: nil) ⇒ IssueTrackerClient
constructor
A new instance of IssueTrackerClient.
-
#reopen_issue(number:) ⇒ Hash
Reopen a closed issue.
Constructor Details
#initialize(token:, repo:, api_url: nil) ⇒ IssueTrackerClient
Returns a new instance of IssueTrackerClient.
66 67 68 69 70 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 66 def initialize(token:, repo:, api_url: nil) @token = token @repo = repo @api_url = api_url end |
Instance Attribute Details
#api_url ⇒ Object (readonly)
Returns the value of attribute api_url.
23 24 25 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 23 def api_url @api_url end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
23 24 25 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 23 def repo @repo end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
23 24 25 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 23 def token @token end |
Class Method Details
.for(provider, token:, repo:, api_url: nil) ⇒ IssueTrackerClient
Factory method — returns the correct client for the provider
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 32 def self.for(provider, token:, repo:, api_url: nil) case provider&.to_sym when :github GitHubIssueClient.new(token: token, repo: repo, api_url: api_url) when :gitlab GitLabIssueClient.new(token: token, repo: repo, api_url: api_url) when :codeberg CodebergIssueClient.new(token: token, repo: repo, api_url: api_url) when :linear LinearIssueClient.new(token: token, repo: repo, api_url: api_url) else raise ArgumentError, "Unknown issue tracker provider: #{provider}. Supported: :github, :gitlab, :codeberg, :linear" end end |
.from_config ⇒ IssueTrackerClient?
Build a client from the current gem configuration
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 50 def self.from_config config = RailsErrorDashboard.configuration return nil unless config.enable_issue_tracking provider = config.effective_issue_tracker_provider token = config.effective_issue_tracker_token repo = config.effective_issue_tracker_repo api_url = config.effective_issue_tracker_api_url return nil unless provider && token && repo self.for(provider, token: token, repo: repo, api_url: api_url) rescue => e nil end |
Instance Method Details
#add_comment(number:, body:) ⇒ Hash
Add a comment to an issue
92 93 94 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 92 def add_comment(number:, body:) raise NotImplementedError end |
#close_issue(number:) ⇒ Hash
Close an issue
80 81 82 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 80 def close_issue(number:) raise NotImplementedError end |
#create_issue(title:, body:, labels: []) ⇒ Hash
Create an issue on the platform
74 75 76 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 74 def create_issue(title:, body:, labels: []) raise NotImplementedError end |
#fetch_comments(number:, per_page: 10) ⇒ Hash
Fetch comments from an issue
98 99 100 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 98 def fetch_comments(number:, per_page: 10) raise NotImplementedError end |
#fetch_issue(number:) ⇒ Hash
Fetch issue details (status, assignees, labels)
104 105 106 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 104 def fetch_issue(number:) raise NotImplementedError end |
#reopen_issue(number:) ⇒ Hash
Reopen a closed issue
86 87 88 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 86 def reopen_issue(number:) raise NotImplementedError end |