Class: Dude::Interface

Inherits:
Object
  • Object
show all
Includes:
Settings
Defined in:
lib/dude/interface.rb

Constant Summary

Constants included from Settings

Settings::CONFIG_FILE

Instance Method Summary collapse

Methods included from Settings

#file, #read, #settings

Instance Method Details

#draw_issue_info(info) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/dude/interface.rb', line 26

def draw_issue_info(info)
  issue_label = info['labels'].find do |label|
    ['To Do', 'Doing', 'To Verify'].include? label
  end

  issue_color = case issue_label
  when 'To Do'
    :yellow
  when 'Doing'
    :green
  when 'To Verify'
    :blue
  end

  puts "#{info['title']} ##{info['iid']}".colorize(issue_color).bold
  puts "Status: ".colorize(:yellow) + "#{issue_label}"
  puts "Estimated time: ".colorize(:yellow) +
    "#{info['time_stats']['human_time_estimate']}"
  puts "Spent time: ".colorize(:yellow) +
    "#{info['time_stats']['human_total_time_spent'] || '0h'}"
  puts "Link: ".colorize(:yellow) + "#{info['web_url']}"
end

#draw_report(report) ⇒ Object



8
9
10
11
12
13
# File 'lib/dude/interface.rb', line 8

def draw_report(report)
  @report = report
  report_weekly
  puts ''
  report_daily
end

#draw_time_estimate(time) ⇒ Object



22
23
24
# File 'lib/dude/interface.rb', line 22

def draw_time_estimate(time)
  puts "Changed time estimate to #{time.colorize(:green)}"
end

#issues_list(issues) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/dude/interface.rb', line 49

def issues_list(issues)
  [['To Do', :yellow], ['Doing', :green], ['To Verify', :blue]].each do |group, color|
    puts "#{group}:".colorize(color).bold
    grouped = issues.select {|i| i[2].include?(group)}
    if grouped.length.zero?
      puts 'Nothing'
    else
      grouped.each do |id, issue, labels|
        puts "#{id}:".colorize(color) + " #{issue} #{labels.compact.to_s.gsub('"', "")}"
      end
    end
    puts ''
  end
end

#throw_error(issue_id, project_title) ⇒ Object



15
16
17
18
19
20
# File 'lib/dude/interface.rb', line 15

def throw_error(issue_id, project_title)
  puts "Something went wrong. Please, check input data\n".colorize(:red) +
    "Project: #{project_title.to_s.bold}\n" +
    "Issue ID: #{issue_id.to_s.bold}"
  exit
end