-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't monkey patch String class #91
Don't monkey patch String class #91
Conversation
nice to see some movement on this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is long overdue. Thank you. At first glance, this looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! This is very much needed.
Could you please check out the lints and make Robocop happy? 😁
Done :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those other checks appear to be failing on master so we can fix those separately. |
Thank you! |
As explained here awesome-print/awesome_print#419, monkey patch on
String
class was pretty unexpected.The key is in
def colorize(str, type)
method : instead of monkey patchingString
+ calling'foo'.red
, let's define colors methods onAmazingPrint::Colors
module and callAmazingPrint::Colors.red('foo')
instead.amazing_print/lib/amazing_print/colorize.rb
Lines 9 to 22 in 8c0ae33
This way we don't pollute
String
class with new methods and we avoid clashes withcolorize
gem which I don't use due to license issues (gpl2 is contaminating) and we do not have to add a new dependency like Rainbow gem.Thank you!