-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpryrc_rails
executable file
·41 lines (34 loc) · 921 Bytes
/
pryrc_rails
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/ruby
begin
require 'hirb' # sudo gem install cldwalker-hirb --source http://gems.github.com
require "hirb-unicode"
rescue LoadError
end
# https://github.com/pry/pry/wiki/FAQ#how-can-i-use-the-hirb-gem-with-pry
if defined? Hirb
# Slightly dirty hack to fully support in-session Hirb.disable/enable toggling
Hirb::View.instance_eval do
def enable_output_method
@output_method = true
@old_print = Pry.config.print
Pry.config.print = proc do |*args|
Hirb::View.view_or_page_output(args[1]) || @old_print.call(*args)
end
end
def disable_output_method
Pry.config.print = @old_print
@output_method = nil
end
end
Hirb.enable(pager: false)
end
def change_log(stream)
ActiveRecord::Base.logger = Logger.new(stream)
ActiveRecord::Base.clear_active_connections!
end
def show_log
change_log(STDOUT)
end
def hide_log
change_log(nil)
end