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
32
|
# File 'bin/patchr', line 6
def find_attachment(ticket_id)
unless ticket_id
puts "Supply ticket id"
exit
end
Lighthouse.account = "rails"
ticket = Lighthouse::Ticket.find(ticket_id, :params => { :project_id => 8994 } )
attachments = ticket.attachments
if attachments.none?
puts "No attachments available"
exit
end
attachment = if attachments.many?
puts "Several attachments available. Choose one of the following"
attachments.each_with_index do |attachment, i|
puts "#{i + 1}. #{attachment.filename}"
end
choice = STDIN.gets.to_i - 1
attachments[choice]
else
attachments.first
end
end
|