Module: Linear::Formatters

Extended by:
Formatters
Included in:
Formatters
Defined in:
lib/linear/formatters.rb

Instance Method Summary collapse

Instance Method Details

#display_issue(issue) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/linear/formatters.rb', line 5

def display_issue(issue)
  puts "\n#{issue['identifier']}: #{issue['title']}"
  puts "=" * 60
  puts "Status:   #{issue['state']['name']}"
  puts "Assignee: #{issue.dig('assignee', 'name') || 'Unassigned'}"
  puts "Priority: #{priority_label(issue['priority'])}"
  puts "URL:      #{issue['url']}"
  puts "\nDescription:"
  puts issue['description'] || "(no description)"
  puts ""
end

#display_issue_list(issues) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/linear/formatters.rb', line 17

def display_issue_list(issues)
  puts "\nFound #{issues.length} issue(s):\n\n"
  issues.each do |issue|
    state_badge = "[#{issue['state']['name']}]".ljust(15)
    priority_badge = priority_label(issue['priority']).ljust(8)
    assignee = (issue.dig('assignee', 'name') || 'Unassigned').ljust(15)

    puts "#{issue['identifier'].ljust(12)} #{state_badge} #{priority_badge} #{assignee} #{issue['title']}"
  end
  puts ""
end

#display_project_list(projects) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/linear/formatters.rb', line 40

def display_project_list(projects)
  puts "\nFound #{projects.length} project(s):\n\n"
  projects.each do |project|
    state_badge = "[#{project['state']}]".ljust(15)
    progress = project['progress'] ? "#{(project['progress'] * 100).round}%" : "0%"
    progress_badge = progress.ljust(6)
    lead = (project.dig('lead', 'name') || 'No lead').ljust(20)

    puts "#{project['name'].ljust(30)} #{state_badge} #{progress_badge} #{lead}"
    puts "  ID: #{project['id']}"

    if project['description'] && !project['description'].empty?
      # Show first line of description
      first_line = project['description'].lines.first&.strip
      puts "  #{first_line[0..80]}#{'...' if first_line && first_line.length > 80}" if first_line
    end

    if project['targetDate']
      puts "  Target: #{project['targetDate']}"
    end

    puts "  URL: #{project['url']}" if project['url']
    puts ""
  end
end

#priority_label(priority) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/linear/formatters.rb', line 29

def priority_label(priority)
  case priority
  when 0 then "None"
  when 1 then "Urgent"
  when 2 then "High"
  when 3 then "Medium"
  when 4 then "Low"
  else "Unknown"
  end
end