Class: HustleAndFlow::IssueTrackers::Github::PullRequests
- Inherits:
-
Object
- Object
- HustleAndFlow::IssueTrackers::Github::PullRequests
- Includes:
- Enumerable
- Defined in:
- lib/hustle_and_flow/issue_trackers/github/pull_requests.rb
Instance Attribute Summary collapse
-
#io ⇒ Object
Returns the value of attribute io.
-
#pull_requests ⇒ Object
Returns the value of attribute pull_requests.
-
#tracker ⇒ Object
Returns the value of attribute tracker.
Instance Method Summary collapse
- #client ⇒ Object
-
#each ⇒ Object
def find_or_create(**args) find(**args) || Issue.create(tracker: tracker, io: io, **args) end.
-
#find(labels: nil, title: nil, number: nil, branch: nil, me: tracker.me, organization_name: tracker.organization_name) ⇒ Object
def filter_by(**args) self.class.new(io: io, tracker: tracker, issues: issues.select do |issue| issue if issue.match?(**args) end) end.
-
#initialize(tracker:, io:, pull_requests: nil) ⇒ PullRequests
constructor
A new instance of PullRequests.
- #statuses ⇒ Object
- #statuses=(other) ⇒ Object
Constructor Details
#initialize(tracker:, io:, pull_requests: nil) ⇒ PullRequests
Returns a new instance of PullRequests.
13 14 15 16 17 |
# File 'lib/hustle_and_flow/issue_trackers/github/pull_requests.rb', line 13 def initialize(tracker:, io:, pull_requests: nil) self.io = io self.tracker = tracker self.pull_requests = pull_requests end |
Instance Attribute Details
#io ⇒ Object
Returns the value of attribute io.
9 10 11 |
# File 'lib/hustle_and_flow/issue_trackers/github/pull_requests.rb', line 9 def io @io end |
#pull_requests ⇒ Object
Returns the value of attribute pull_requests.
9 10 11 |
# File 'lib/hustle_and_flow/issue_trackers/github/pull_requests.rb', line 9 def pull_requests @pull_requests end |
#tracker ⇒ Object
Returns the value of attribute tracker.
9 10 11 |
# File 'lib/hustle_and_flow/issue_trackers/github/pull_requests.rb', line 9 def tracker @tracker end |
Instance Method Details
#client ⇒ Object
63 64 65 |
# File 'lib/hustle_and_flow/issue_trackers/github/pull_requests.rb', line 63 def client tracker.client end |
#each ⇒ Object
def find_or_create(**args)
find(**args) || Issue.create(tracker: tracker, io: io, **args)
end
23 24 25 26 27 |
# File 'lib/hustle_and_flow/issue_trackers/github/pull_requests.rb', line 23 def each pull_requests.each do |pull_request| yield pull_request end end |
#find(labels: nil, title: nil, number: nil, branch: nil, me: tracker.me, organization_name: tracker.organization_name) ⇒ Object
def filter_by(**args)
self.class.new(io: io,
tracker: tracker,
issues: issues.select do |issue|
issue if issue.match?(**args)
end)
end
private
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/hustle_and_flow/issue_trackers/github/pull_requests.rb', line 39 def find(labels: nil, title: nil, number: nil, branch: nil, me: tracker.me, organization_name: tracker.organization_name) pull_requests.find do |pull_request| pull_request.match?(labels: labels, title: title) || pull_request.match?(number: number.to_i) || pull_request.match?(branch: "#{me}:#{branch}") || pull_request.match?(branch: "#{organization_name}:#{branch}") end end |
#statuses ⇒ Object
67 68 69 |
# File 'lib/hustle_and_flow/issue_trackers/github/pull_requests.rb', line 67 def statuses @statuses ||= [:all] end |
#statuses=(other) ⇒ Object
71 72 73 |
# File 'lib/hustle_and_flow/issue_trackers/github/pull_requests.rb', line 71 def statuses=(other) @statuses ||= other.nil? ? [:all] : other end |