Class: Hubkit::IssueCollection
- Inherits:
-
ChainableCollection
- Object
- ChainableCollection
- Hubkit::IssueCollection
- Defined in:
- lib/hubkit/issue_collection.rb
Overview
A collection of GitHub issues with chainable filters
Instance Method Summary collapse
-
#by_assignee ⇒ Hash
Group the issue collection by the current assignee.
-
#closed ⇒ IssueCollection
Return a collection of issues which are closed.
-
#ever_labeled(label) ⇒ IssueCollection
Filters to issues which where at some point labeled with the given label regardless of whether it currently has that label or not.
-
#labeled(labels) ⇒ IssueCollection
Return a collection of issues which are labeled with any of the given labels.
-
#labeled_like(label_pattern) ⇒ IssueCollection
Return a collection of issues which have labels matching a pattern.
-
#open ⇒ IssueCollection
Return a collection of issues which are open.
-
#opened_between(start_dt, end_dt) ⇒ IssueCollection
Returns issues opened within a date window between start_dt and end_dt.
-
#pulls ⇒ IssueCollection
Return issues which are pull requests.
-
#true_issues ⇒ IssueCollection
Return issues which are not pull requests.
-
#unassigned ⇒ IssueCollection
Return issues which are unassigned.
-
#unlabeled ⇒ IssueCollection
Return a collection of issues which are not labeled.
Methods inherited from ChainableCollection
#==, #initialize, #method_missing, #not, #respond_to?, scope, #select, #wrap
Constructor Details
This class inherits a constructor from Hubkit::ChainableCollection
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Hubkit::ChainableCollection
Instance Method Details
#by_assignee ⇒ Hash
Group the issue collection by the current assignee
94 95 96 97 98 99 |
# File 'lib/hubkit/issue_collection.rb', line 94 def by_assignee groups = group_by { |issue| issue.assignee.try(:login) } groups.each_with_object(groups) do |(key, list), memo| memo[key] = wrap(list) end end |
#closed ⇒ IssueCollection
Return a collection of issues which are closed
25 26 27 |
# File 'lib/hubkit/issue_collection.rb', line 25 def closed wrap(@inner.select { |issue| issue.state == "closed" }) end |
#ever_labeled(label) ⇒ IssueCollection
Filters to issues which where at some point labeled with the given label regardless of whether it currently has that label or not
9 10 11 12 13 14 15 |
# File 'lib/hubkit/issue_collection.rb', line 9 def ever_labeled(label) wrap( @inner.select do |issue| issue.when_labeled(label).present? end, ) end |
#labeled(labels) ⇒ IssueCollection
Return a collection of issues which are labeled with any of the given labels
35 36 37 38 39 40 41 |
# File 'lib/hubkit/issue_collection.rb', line 35 def labeled(labels) return wrap(labels.flat_map { |label| labeled(label) }) if labels.respond_to?(:map) wrap(@inner.select do |issue| issue.labels.include?(labels.downcase) end) end |
#labeled_like(label_pattern) ⇒ IssueCollection
Return a collection of issues which have labels matching a pattern
54 55 56 57 58 |
# File 'lib/hubkit/issue_collection.rb', line 54 def labeled_like(label_pattern) wrap(@inner.select do |issue| issue.labels.any? { |label| label_pattern.match(label) } end) end |
#open ⇒ IssueCollection
Return a collection of issues which are open
19 20 21 |
# File 'lib/hubkit/issue_collection.rb', line 19 def open wrap(@inner.select { |issue| issue.state == "open" }) end |
#opened_between(start_dt, end_dt) ⇒ IssueCollection
Returns issues opened within a date window between start_dt and end_dt
83 84 85 86 87 88 89 |
# File 'lib/hubkit/issue_collection.rb', line 83 def opened_between(start_dt, end_dt) wrap( @inner.select do |issue| start_dt <= issue.when_opened && issue.when_opened < end_dt end, ) end |
#pulls ⇒ IssueCollection
Return issues which are pull requests
69 70 71 |
# File 'lib/hubkit/issue_collection.rb', line 69 def pulls wrap(@inner.select(&:pull?)) end |
#true_issues ⇒ IssueCollection
Return issues which are not pull requests
63 64 65 |
# File 'lib/hubkit/issue_collection.rb', line 63 def true_issues wrap(@inner.select(&:true_issue?)) end |
#unassigned ⇒ IssueCollection
Return issues which are unassigned
75 76 77 |
# File 'lib/hubkit/issue_collection.rb', line 75 def unassigned wrap(@inner.select { |issue| issue.assignee.nil? }) end |
#unlabeled ⇒ IssueCollection
Return a collection of issues which are not labeled
45 46 47 |
# File 'lib/hubkit/issue_collection.rb', line 45 def unlabeled wrap(@inner.select { |issue| issue.labels.empty? }) end |