Skip to content

Commit

Permalink
added textmate error scraping, use [e]rrors , give the file you want …
Browse files Browse the repository at this point in the history
…to edit, and it will open in textmate and jump to the line
  • Loading branch information
smeevil committed Jan 3, 2010
1 parent a78852d commit 0b4cfbc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
27 changes: 26 additions & 1 deletion lib/fresnel.rb
Expand Up @@ -332,7 +332,7 @@ def show_ticket(number)
puts "Current state : #{ticket.versions.last.state}"
choices = {
:states => %w[open resolved invalid hold new],
:actions => %w[quit tickets bins comments assign self web links]
:actions => %w[quit tickets bins comments assign self web links errors]
}
states = choices[:states]
action=InputDetector.pretty_prompt(choices).answer
Expand All @@ -344,6 +344,7 @@ def show_ticket(number)
when "s" then claim(:ticket=>number)
when "w" then open_browser_for_ticket(number)
when "l" then links(number)
when "e" then errors(number)
when *(states.map{|state| state[0,1]})
change_state(:ticket=>number,:state=>states.find{|state| state[0,1] == action})
else
Expand Down Expand Up @@ -375,6 +376,30 @@ def links(number)
show_ticket(number)
end
def errors(number)
ticket = get_ticket(number)
errors = ticket.versions.map{ |version| version.body.to_s.scrape_textmate_links }.flatten
if errors.size == 0
puts "No errors found"
sleep 1
elsif errors.size == 1
error=errors.first
error=~/(.*?):(\d+)/
`mate -l #{$2} #{File.expand_path(".")}#{$1.gsub(/^\./,"")}`
else
error_table=table do |t|
t.headings=['#','error']
errors.each_with_index{|error,i|t << [i,error]}
end
puts error_table
pick=InputDetector.new("open error # : ", (0...errors.size).to_a).answer
error=errors[pick.to_i]
error=~/(.*?):(\d+)/
`mate -l #{$2} #{File.expand_path(".")}#{$1.gsub(/^\./,"")}`
end
show_ticket(number)
end
def comment(number,state=nil)
puts "create comment for #{number}"
ticket=get_ticket(number)
Expand Down
4 changes: 4 additions & 0 deletions lib/fresnel/string.rb
Expand Up @@ -11,4 +11,8 @@ def truncate(size)
def scrape_urls
scan(/(http|https)(:\/\/)([a-zA-Z0-9.\/_-]+\?[&=a-zA-Z0-9.\/_-]+)| (www\.[a-zA-Z0-9.\/_-]+)/).map{ |url| url.join}
end

def scrape_textmate_links
scan(/(\.?\/.*?\.rb:\d+):in/)
end
end

0 comments on commit 0b4cfbc

Please sign in to comment.