Top Level Namespace

Instance Method Summary collapse

Instance Method Details

#find_attachment(ticket_id) ⇒ Object



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. = "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

#retrieve_patch_file(ticket_id, attachment) ⇒ Object



34
35
36
37
38
# File 'bin/patchr', line 34

def retrieve_patch_file(ticket_id, attachment)
  patch_file = "/tmp/#{ticket_id}-#{attachment.filename}"
  `curl -kL #{attachment.url} > #{patch_file}`
  patch_file
end