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, and Codeberg/Gitea/Forgejo via a unified interface. Each provider implements the same methods with provider-specific API calls.
Direct Known Subclasses
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.
63 64 65 66 67 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 63 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.
22 23 24 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 22 def api_url @api_url end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
22 23 24 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 22 def repo @repo end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
22 23 24 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 22 def token @token end |
Class Method Details
.for(provider, token:, repo:, api_url: nil) ⇒ IssueTrackerClient
Factory method — returns the correct client for the provider
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 31 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) else raise ArgumentError, "Unknown issue tracker provider: #{provider}. Supported: :github, :gitlab, :codeberg" end end |
.from_config ⇒ IssueTrackerClient?
Build a client from the current gem configuration
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 47 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
89 90 91 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 89 def add_comment(number:, body:) raise NotImplementedError end |
#close_issue(number:) ⇒ Hash
Close an issue
77 78 79 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 77 def close_issue(number:) raise NotImplementedError end |
#create_issue(title:, body:, labels: []) ⇒ Hash
Create an issue on the platform
71 72 73 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 71 def create_issue(title:, body:, labels: []) raise NotImplementedError end |
#fetch_comments(number:, per_page: 10) ⇒ Hash
Fetch comments from an issue
95 96 97 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 95 def fetch_comments(number:, per_page: 10) raise NotImplementedError end |
#fetch_issue(number:) ⇒ Hash
Fetch issue details (status, assignees, labels)
101 102 103 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 101 def fetch_issue(number:) raise NotImplementedError end |
#reopen_issue(number:) ⇒ Hash
Reopen a closed issue
83 84 85 |
# File 'lib/rails_error_dashboard/services/issue_tracker_client.rb', line 83 def reopen_issue(number:) raise NotImplementedError end |