Module: Bl::Printer

Included in:
Command
Defined in:
lib/bl/printer.rb

Class Method Summary collapse

Class Method Details



5
6
7
8
9
10
11
12
13
14
# File 'lib/bl/printer.rb', line 5

def print_response(res, resource)
  case resource
  when :issue
    puts formatter.render(printable_issues(res.body), fields: ISSUE_FIELDS)
  when :named
    puts formatter.render(res.body, fields: %i(id name))
  else
    raise 'invalid resource error'
  end
end

.printable_issues(ary) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/bl/printer.rb', line 16

def printable_issues(ary)
  ary = Array(ary)
  ary.each do |v|
    v.issueType = v.issueType.name
    v.assignee = v.assignee.name if v.assignee
    v.status = v.status.name
    v.priority = v.priority.name
    v.startDate = format_date(v.startDate)
    v.dueDate = format_date(v.dueDate)
    v.created = format_datetime(v.created)
    v.updated = format_datetime(v.updated)
  end
  ary
end