Last active
April 18, 2021 04:04
-
-
Save dpaluy/394fcaf419ef2865eec4d881b4078a63 to your computer and use it in GitHub Desktop.
pryrc settings with AwesomePrint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another alternative: https://gist.github.com/am-kantox/5ebb68916ccde06736e8d95026693742