Skip to content

Instantly share code, notes, and snippets.

@dpaluy
Last active April 18, 2021 04:04
Show Gist options
  • Select an option

  • Save dpaluy/394fcaf419ef2865eec4d881b4078a63 to your computer and use it in GitHub Desktop.

Select an option

Save dpaluy/394fcaf419ef2865eec4d881b4078a63 to your computer and use it in GitHub Desktop.
pryrc settings with AwesomePrint
if defined?(PryByebug)
Pry.commands.alias_command 'con', 'continue'
Pry.commands.alias_command 's', 'step'
Pry.commands.alias_command 'n', 'next'
Pry.commands.alias_command 'f', 'finish'
end
begin
require 'awesome_print'
module AwesomePrint
Formatter.prepend(Module.new do
def awesome_self(object, type)
if type == :string && @options[:string_limit] && object.inspect.to_s.length > @options[:string_limit]
colorize(object.inspect.to_s[0..@options[:string_limit]] + "...", type)
else
super(object, type)
end
end
end)
end
AwesomePrint.defaults = {
string_limit: 80,
indent: 2,
multiline: true
}
AwesomePrint.pry!
rescue
puts 'There is no Awesome Print gem installed'
end
Pry.hooks.add_hook :after_read, :hack_utf8 do |str, _|
str.force_encoding('utf-8')
end
@dpaluy
Copy link
Author

dpaluy commented Apr 18, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment