Skip to content

Instantly share code, notes, and snippets.

@chrismcg
Created October 9, 2008 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrismcg/15730 to your computer and use it in GitHub Desktop.
Save chrismcg/15730 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby -w
#---
# Excerpted from "TextMate"
# We make no guarantees that this code is fit for any purpose.
# Visit http://www.pragmaticprogrammer.com/titles/textmate for more book information.
#---
$LOAD_PATH << "#{ENV["TM_SUPPORT_PATH"]}/lib"
require "exit_codes"
require "web_preview"
require "escape"
check = `ruby -c 2>&1`
if check.include? "Syntax OK"
puts "Ruby #{check}"
else
file = ENV["TM_FILEPATH"]
check = htmlize(check)
check.gsub!( /(^|<br \/>)-:(\d+):\s+([\w\s]+)/,
"\\1<a href='txmt://open?url=file://#{file}&line=\\2'>\\3</a>" )
html_header("Syntax Checker", "Ruby")
puts <<END_HTML
<h1>Errors Located in Your File</h1>
<pre style="word-wrap: break-word;">#{check}</pre>
END_HTML
html_footer
TextMate.exit_show_html
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment