Created
October 9, 2008 09:09
-
-
Save chrismcg/15730 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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