Class: HustleAndFlow::IssueTrackers::Github::Issues

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/hustle_and_flow/issue_trackers/github/issues.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tracker:, io:, issues: nil, statuses: nil) ⇒ Issues

Returns a new instance of Issues.



14
15
16
17
18
19
# File 'lib/hustle_and_flow/issue_trackers/github/issues.rb', line 14

def initialize(tracker:, io:, issues: nil, statuses: nil)
  self.io       = io
  self.tracker  = tracker
  self.statuses = statuses
  self.issues   = issues
end

Instance Attribute Details

#ioObject

Returns the value of attribute io.



9
10
11
# File 'lib/hustle_and_flow/issue_trackers/github/issues.rb', line 9

def io
  @io
end

#issues=(value) ⇒ Object

Sets the attribute issues

Parameters:

  • value

    the value to set the attribute issues to.



9
10
11
# File 'lib/hustle_and_flow/issue_trackers/github/issues.rb', line 9

def issues=(value)
  @issues = value
end

#statusesObject

Returns the value of attribute statuses.



9
10
11
# File 'lib/hustle_and_flow/issue_trackers/github/issues.rb', line 9

def statuses
  @statuses
end

#trackerObject

Returns the value of attribute tracker.



9
10
11
# File 'lib/hustle_and_flow/issue_trackers/github/issues.rb', line 9

def tracker
  @tracker
end

Instance Method Details

#eachObject



25
26
27
28
29
# File 'lib/hustle_and_flow/issue_trackers/github/issues.rb', line 25

def each
  issues.each do |issue|
    yield issue
  end
end

#filter_by(**args) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/hustle_and_flow/issue_trackers/github/issues.rb', line 31

def filter_by(**args)
  self.class.new(io:      io,
                 tracker: tracker,
                 issues:  issues.select do |issue|
                            issue if issue.match?(**args)
                          end)
end

#filter_by_branch(branch:) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/hustle_and_flow/issue_trackers/github/issues.rb', line 39

def filter_by_branch(branch:)
  data_from_branch = Issue.
                     from_branch_name(branch).
                     each_with_object({}) do |item, memo|
                       memo[item[0]] = item[1] unless item[1].nil?
                     end

  self.class.new(io:      io,
                 tracker: tracker,
                 issues:  issues.select do |issue|
                            issue if issue.match?(**data_from_branch)
                          end)
end

#find_or_create(**args) ⇒ Object



21
22
23
# File 'lib/hustle_and_flow/issue_trackers/github/issues.rb', line 21

def find_or_create(**args)
  find(**args) || Issue.create(tracker: tracker, io: io, **args)
end