Created
March 5, 2010 22:34
-
-
Save shad/323240 to your computer and use it in GitHub Desktop.
An Improved puts for rspec in Textmate.
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
# Improved "puts" in Textmate's version of rspec | |
if ENV['TM_MODE'] == 'RSpec' | |
alias :orig_puts :puts | |
def puts(str) | |
str = '[nil]' if str.nil? | |
str = '' if str.blank? | |
url, line = caller[0].split(":") | |
md = caller[0].match(/[\\\/]([^\\\/]*:\d+):(.*)/) | |
link_text = md[1] | |
title = md[2] | |
orig_puts <<-HTML | |
<div class='puts' style='clear:both; font-family:"Inconsolata", "Monaco", monospace; border:1px dotted #444; border-top:0; background:#333; color: #D0FFAF; padding:0 5px; margin:0px 10px'> | |
<div class='caller' style="font-size:10pt; float:left; width:200px; padding-right:5px; line-height:1.3em; text-align:right;"><a href="txmt://open?url=file://#{url}&line=#{line}" title="#{title}">#{link_text}</a></div> | |
<div class='message' style='min-height:1.3em; font-size:10pt; line-height:1.3em; margin:0 0 0 210px;'>#{CGI.escapeHTML(str.to_s).gsub(/[\r\n]{1,2}/, "</br>")}</div> | |
</div> | |
HTML | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, I figured it out. Worked perfectly! Thanks a ton.