public
Last active

Enable Hirb in Pry, and hack disable/enable to work in-session

  • Download Gist
.pryrc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
begin
require 'hirb'
rescue LoadError
# Missing goodies, bummer
end
 
if defined? Hirb
# Dirty hack to support in-session Hirb.disable/enable
Hirb::View.instance_eval do
def enable_output_method
@output_method = true
Pry.config.print = proc do |output, value|
Hirb::View.view_or_page_output(value) || Pry::DEFAULT_PRINT.call(output, value)
end
end
 
def disable_output_method
Pry.config.print = proc { |output, value| Pry::DEFAULT_PRINT.call(output, value) }
@output_method = nil
end
end
 
Hirb.enable
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.