Class: Jiraa::Formatters::Issue

Inherits:
Object
  • Object
show all
Defined in:
lib/jiraa/formatters/issue.rb

Instance Method Summary collapse

Constructor Details

#initialize(issue, opts) ⇒ Issue

Returns a new instance of Issue.



4
5
6
7
# File 'lib/jiraa/formatters/issue.rb', line 4

def initialize(issue, opts)
  @issue = issue
  @options = opts
end

Instance Method Details

#formatObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/jiraa/formatters/issue.rb', line 9

def format
  color = issue_color(@issue.issuetype)
  puts "#{@issue.key}\t#{@issue.summary} [#{@issue.status.name.upcase}] (#{@issue.assignee})".colorize(color)
  if @options[:subtasks]
    puts
    puts "SUBTASKS"
    puts
    @issue.subtasks.each do |subtask|
      puts "    #{subtask.key}\t#{subtask.summary} [#{subtask.status.name.upcase}]"
    end
    puts
  end
  if @options[:description]
    puts
    puts "DESCRIPTION"
    puts
    puts "    #{@issue.description}".gsub("\n", "\n    ") if @options[:description]
  end
  if @options[:comments]
    puts
    puts "COMMENTS"
    puts
    @issue.comments.each do |comment|
      puts "    #{comment.author}: #{comment.created.strftime("%e-%b-%Y (%H:%M)")}"
      puts "    #{comment.body}".gsub("\n", "\n    ")
      puts
    end
  end
end

#issue_color(type) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/jiraa/formatters/issue.rb', line 39

def issue_color(type)
  color = case type.name
  when "Bug"
    :red
  when "Task"
    :blue
  when "Story"
    :green
  end
  color
end