Skip to content

Instantly share code, notes, and snippets.

@willbailey
Forked from jashkenas/tix
Created June 1, 2009 15:03
Show Gist options
  • Save willbailey/121465 to your computer and use it in GitHub Desktop.
Save willbailey/121465 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'time'
username = "<username>"
password = "<password>"
tix = Hpricot(IO.popen("curl https://trac.zenbe.com/report/7 --basic -u #{username}:#{password} -k -s"))
tix = (tix/"table.listing.tickets"/"tbody"/"tr").collect { |row|
t = {}
t[:ticket] = (row/"td.ticket"/"a").first.inner_html
t[:summary] = (row/"td.summary"/"a").first.inner_html
t[:date] = Time.parse((row/"td.date").first.inner_html.strip)
t[:priority] = (row/"td.priority").first.inner_html.strip
t
}.sort_by{|t| t[:date]}.reverse
tix.each{|t|
puts "\033[0;32m#{t[:ticket]} #{t[:summary]}\e[0m"
puts "Priority: #{t[:priority]}"
puts "Date: #{t[:date].strftime("%b %d, %Y")}\n\n"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment