def trace(expr, style=:p)
unless expr.respond_to? :to_str
warn "trace: Can't evaluate the given value: #{caller.first}"
else
require 'nano/binding/of_caller'
Binding.of_caller do |b|
value = b.eval(expr.to_str)
formatter = TRACE_STYLES[style] || :inspect
case formatter
when :pp then require 'pp'
when :y, :yaml, :to_yaml then require 'yaml'
end
value_s = value.send(formatter)
message = "#{expr} = #{value_s}"
lines = message.split(/\n/)
indent = " "
debug(lines.shift)
lines.each do |line|
debug(indent + line)
end
end
end
end