pazdera / word_wrap

A simple word-wrapping tool and a tiny single-purpose library written in Ruby.
MIT License
20 stars 4 forks source link

Feature request: make core extensions (monkey patches) optional #6

Closed wconrad closed 9 years ago

wconrad commented 9 years ago

What would you say to making it possible to use word_wrap without it monkey patching String?

Background: I prefer to avoid, or at least minimize, gems that monkey patch core classes. It can get ugly in a hurry as the program grows and starts including other libraries that also monkey patch core classes.

I can think of a few ways to go, if you wanted to allow this. One would be to make the monkey-patch be omitted by:

require 'word_wrap'

and put into a piece you could require separately, if you wanted it:

require 'word_wrap/core_extensions'

This is a breaking API change. The other way, which is not a breaking API change, is to make the monkey patch be included, as it is now, by:

require 'word_wrap'

But omitted by, for example:

require 'word_wrap/core'

What do you think? Good idea? If so, how would you like it to work?

pazdera commented 9 years ago

Hi Wayne,

I see you point. It makes sense to keep the core_extensions separate, I haven't really thought that through all that well. I'd go with your first suggestion, even though it breaks the current interface. It seems like a right thing to do.

wconrad commented 9 years ago

Sounds good. If you like, I'll cook up a pull request.

Sorry, I didn't notice that you've done it already. Excellent, and thanks!

pazdera commented 9 years ago

This should be addressed in 1.0.0.

Core extensions are omitted by default and can be added using:

require 'word_wrap/core_ext'

Thanks @wconrad!