# -----------------------------------------------
# support for nice html output in rspec tmbundle
# -----------------------------------------------
module RSpecTmBundleHelpers
class TextmateRspecLogger < DataMapper::Logger
def prep_msg(message, level)
"#{super}
"
end
end
def with_dm_logger(level = :debug)
DataMapper.logger.level = level
yield
ensure
DataMapper.logger.level = :off
end
def print_call_stack(from = 2, to = nil, html = true)
(from..(to ? to : caller.length)).each do |idx|
p "[#{idx}]: #{caller[idx]}#{html ? '
' : ''}"
end
end
def puth(html = nil)
print "#{h(html)}
"
end
ESCAPE_TABLE = { '&'=>'&', '<'=>'<', '>'=>'>', '"'=>'"', "'"=>''', }
def h(value)
value.to_s.gsub(/[&<>"]/) {|s| ESCAPE_TABLE[s] }
end
end