monkeypatch is a new ruby projects that tries to protect you from
== Project info
monkeypatch introduces a small API that you can use when you want to
external libraries. The mechanism is meant to be as straightforward as
possible. Also, by adding monkeypatch as a gem dependency, you declare
your package is fixing other package’s code.
== A small example
my_patch = MonkeyPatch.add_method(:to_blob) do
def to_blog; “” end
“hello”.to_blob #=> “”
== How does it work ?
When applying a patch, there are two mechanism that enters the game ;
conditions and conflicts.
- Conditions are not fatal. If they don’t match, the patch is simply not
applied, and a message is passed to the MonkeyPatch.logger.
Conditions are for library version matching for example. They are
extensible buy using: #add_condition(msg, &cond)
- Conflicts are fatal, in that they raise a ConflictError if they don’t
match. Conflicts are for patch collision. They are not extensible and
the API. The idea is that if your code has conflicting patches, you
get notified by a crashing application, so that you can fix it as
Another aspect are PatchSet (s). If you have a bundle of patches you
apply, you can aggregate them with the & operator. You then get a
instance which you can use like a Patch. This is not fully done now, but
theoritically, your bundle does not apply unless all patch conditions
== What’s next ?
This project API is intentionally unstable for now. What I’m really
now, is community feedback. I also intend to look at real-world patches
see how this library can be made more useful.
So if you have some real-world patches or any comments, please give me