Class: Jirify::Issues

Inherits:
Base
  • Object
show all
Defined in:
lib/jirify/models/issues.rb

Class Method Summary collapse

Methods inherited from Base

client, project

Class Method Details

.mine(verbose, statuses = [], all = false) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/jirify/models/issues.rb', line 6

def mine(verbose, statuses = [], all = false)
  all_clause = "AND sprint in openSprints() " unless all
  my_issues = client.Issue.jql("project='#{project}' #{all_clause}AND assignee='#{Config.options["username"]}'")

  my_issues.sort_by! { |issue| issue.status.name }
  my_issues.each do |issue|
    status = issue.status.name

    next if statuses.any? && !statuses.include?(status)

    status_justified = "(#{status})".rjust(14)
    status_colorized = case status
      when "Done" then status_justified.green
      when "In Progress" then status_justified.blue
      when "In Review" then status_justified.yellow
      when "Closed" then status_justified.black
      else status_justified
    end

    if verbose
      print "#{status_colorized} #{issue.key.ljust(7)}: #{issue.summary} (#{Config.issue_browse_url}#{issue.key})\n"
    else
      print "#{issue.key.ljust(7)}: (#{Config.issue_browse_url}#{issue.key})\n"
    end
  end
end