Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
81 lines (69 sloc) 1.36 KB
#$LOAD_PATH.unshift File.expand_path("~/Code/ex/rails-dev-boost/lib")
#require 'rails_development_boost'
require 'hirb'
Hirb.enable :pager => false
Paperclip.options.merge! log_command: true
class BigDecimal
def inspect
"BD: #{to_s}"
end
end
class Money
def inspect
"M: #{to_s}"
end
end
class Object
def hirbify
Hirb::View.formatter.format_output(self) || inspect
end
def tapp(prefix = nil, &block)
block ||= lambda {|x| x }
tap do |x|
value = block[x].hirbify
if prefix
print prefix
if value.lines.count > 1
print ":\n"
else
print ": "
end
end
puts value
end
end
def tapr(prefix = nil, &block)
block ||= lambda {|x| x }
tap do |x|
value = block[x].hirbify
buffer = ''
if prefix
buffer += prefix
if value.lines.count > 1
buffer += ":\n"
else
buffer += ": "
end
end
buffer += value
raise buffer
end
end
def tapl(prefix = nil, &block)
block ||= lambda {|x| x }
tap do |x|
value = block[x].hirbify
buffer = ''
if prefix
buffer += prefix
if value.lines.count > 1
buffer += ":\n"
else
buffer += ": "
end
end
buffer += value
Rails.logger.info buffer
end
end
end