Class: Geet::GitHub::AbstractIssue
- Inherits:
-
Object
- Object
- Geet::GitHub::AbstractIssue
- Defined in:
- lib/geet/git_hub/abstract_issue.rb
Overview
For clarity, in this class we keep only the identical logic between the subclasses, but other methods could be moved in here at some complexity cost.
Instance Attribute Summary collapse
-
#issue_number ⇒ Object
readonly
Returns the value of attribute issue_number.
Class Method Summary collapse
-
.list(repository, api_helper, filter: nil) ⇒ Object
Returns an array of Struct(:number, :title); once this workflow is extended, the struct will likely be converted to a standard class.
Instance Method Summary collapse
- #add_labels(labels) ⇒ Object
-
#assign_user(users) ⇒ Object
params: users: String, or Array of strings.
-
#initialize(repository, issue_number, api_helper) ⇒ AbstractIssue
constructor
A new instance of AbstractIssue.
Constructor Details
#initialize(repository, issue_number, api_helper) ⇒ AbstractIssue
Returns a new instance of AbstractIssue.
40 41 42 43 44 |
# File 'lib/geet/git_hub/abstract_issue.rb', line 40 def initialize(repository, issue_number, api_helper) @repository = repository @issue_number = issue_number @api_helper = api_helper end |
Instance Attribute Details
#issue_number ⇒ Object (readonly)
Returns the value of attribute issue_number.
8 9 10 |
# File 'lib/geet/git_hub/abstract_issue.rb', line 8 def issue_number @issue_number end |
Class Method Details
.list(repository, api_helper, filter: nil) ⇒ Object
Returns an array of Struct(:number, :title); once this workflow is extended, the struct will likely be converted to a standard class.
See developer.github.com/v3/issues/#list-issues-for-a-repository
options:
filter: :pr, :issue, or nil
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/geet/git_hub/abstract_issue.rb', line 18 def self.list(repository, api_helper, filter: nil) request_address = "#{api_helper.repo_link}/issues" response = api_helper.send_request(request_address, multipage: true) issue_class = Struct.new(:number, :title, :link) response.each_with_object([]) do |issue_data, result| include_issue = \ filter.nil? || filter == :pr && issue_data.key?('pull_request') || filter == :issue && ! issue_data.key?('pull_request') if include_issue number = issue_data.fetch('number') title = issue_data.fetch('title') link = issue_data.fetch('html_url') result << issue_class.new(number, title, link) end end end |
Instance Method Details
#add_labels(labels) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/geet/git_hub/abstract_issue.rb', line 56 def add_labels(labels) request_data = labels request_address = "#{@api_helper.repo_link}/issues/#{@issue_number}/labels" @api_helper.send_request(request_address, data: request_data) end |
#assign_user(users) ⇒ Object
params:
users: String, or Array of strings.
49 50 51 52 53 54 |
# File 'lib/geet/git_hub/abstract_issue.rb', line 49 def assign_user(users) request_data = { assignees: Array(users) } request_address = "#{@api_helper.repo_link}/issues/#{@issue_number}/assignees" @api_helper.send_request(request_address, data: request_data) end |