Skip to content

Instantly share code, notes, and snippets.

@bguest
Created April 4, 2013 03:00
Show Gist options
  • Save bguest/5307358 to your computer and use it in GitHub Desktop.
Save bguest/5307358 to your computer and use it in GitHub Desktop.
~/.pryrc
# Launch Pry with access to the entire Rails stack.
# If you have Pry in your Gemfile, you can pass: ./script/console --irb=pry instead.
# If you don't, you can load it through the lines below :)
rails = File.join Dir.getwd, 'config', 'environment.rb'
if File.exist?(rails) && ENV['SKIP_RAILS'].nil?
require rails
if Rails.version[0..0] == "2"
require 'console_app'
require 'console_with_helpers'
elsif Rails.version[0..0] == "3"
require 'rails/console/app'
require 'rails/console/helpers'
# Show sql output
ActiveRecord::Base.logger = Logger.new(STDOUT) if defined? ActiveRecord::Base
# Add reload! command if rails version > 3.2
if Rails.version[2..2].to_i >= 2
include Rails::ConsoleMethods
end
else
warn "[WARN] cannot load Rails console commands (Not on Rails2 or Rails3?)"
end
end
# HIRB's the word.
begin
require 'hirb'
rescue LoadError
# Missing goodies, bummer
end
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 |output, value|
Hirb::View.view_or_page_output(value) || @old_print.call(output, value)
end
end
def disable_output_method
Pry.config.print = @old_print
@output_method = nil
end
end
Hirb.enable
end
require 'methodfinder'
if defined? Pry
old_print = Pry.config.print
Pry.config.print = proc do |output, value|
Hirb::View.view_or_page_output(value) || old_print.call(output, value)
end
Pry.commands.alias_command 'c', 'continue'
Pry.commands.alias_command 's', 'step'
Pry.commands.alias_command 'n', 'next'
Pry.commands.alias_command 'f', 'finish'
end
# gem 'pry'
# gem 'pry-doc'
# gem 'pry-debugger'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment