Skip to content

Commit

Permalink
Adding .pryrc
Browse files Browse the repository at this point in the history
  • Loading branch information
bray committed Aug 9, 2012
1 parent 844b558 commit cc6f843
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .pryrc
@@ -0,0 +1,28 @@
require 'awesome_print'

#Pry.config.editor = 'mate -w'

def r; reload! end

# Default print but without pretty print
Pry.config.print = proc do |output, value|
stringified = begin
value.inspect
rescue Pry::RescuableException
nil
end

unless String === stringified
# Read the class name off of the singleton class to provide a default inspect.
klass = (class << value; self; end).ancestors.first
stringified = "#<#{klass}:0x#{value.__id__.to_s(16)}>"
end

nonce = rand(0x100000000).to_s(16) # whatever
colorized = Pry::Helpers::BaseHelpers.colorize_code(stringified.gsub(/#</, "%<#{nonce}"))
Pry::Helpers::BaseHelpers.stagger_output("=> #{colorized.gsub(/%<(.*?)#{nonce}/, '#<\1')}", output)
end

# Only for Rails < 3.1 ...
ActiveRecord::Base.logger = Logger.new(STDOUT)

0 comments on commit cc6f843

Please sign in to comment.