Skip to content

Instantly share code, notes, and snippets.

@frankyston
Last active October 26, 2020 18:01
Show Gist options
  • Save frankyston/bdf41132b24da6ffe9ea to your computer and use it in GitHub Desktop.
Save frankyston/bdf41132b24da6ffe9ea to your computer and use it in GitHub Desktop.
Personalizando Pry
Arquivo para carregar automaticamente o Pry
necessário as gems:
pry, pry-doc, awesome_print
begin
require "pry"
Pry.start
exit
rescue LoadError => e
warn "=> Error to load pry"
end
Configuração do pryrc do screenshort do nando vieira sobre o pry
Pry.config.prompt = proc do |obj, level, _|
prompt = "\e[1;30m"
prompt << "#{Rails.version}@" if defined?(Rails)
prompt << "#{RUBY_VERSION}"
"#{prompt} (#{obj})>\e[0m "
end
Pry.config.exception_handler = proc do |output, exception, _|
output.puts "\e[31m#{exception.class}: #{exception.message}"
output.puts "from #{exception.backtrace.first}\e[0m"
end
begin
require 'awesome_print'
Pry.config.print = proc { |output, value| Pry::Helpers::BaseHelpers.stagger_output("=> #{value.ai}", output) }
if defined?(Rails) && Rails.env
if defined?(Rails::ConsoleMethods)
include Rails::ConsoleMethods
else
def reload!(print=true)
puts "Reloading..." if print
ActionDispatch::Reloader.cleanup!
ActionDispatch::Reloader.prepare!
true
end
end
end
rescue LoadError => err
puts "no awesome_print :("
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment