Footing
Footing provides some sanity for monkey patching practices. It's also a utility lib that contains additional functionality for core objects that you might find useful.
NOTE: this lib is experimental at the moment
No implicit monkey patching
No surprises here. You must explicitly patch.
# some examples of explicit patching
Footing.patch! String, Footing::String
Footing.patch! Numeric, Footing::Numeric
# instrospect the changes
String.ancestors
[
String,
Footing::String,
Comparable,
Object,
Kernel,
BasicObject
]
Numeric.ancestors
[
Numeric,
Footing::Numeric,
Comparable,
Object,
Kernel,
BasicObject
]
Instance patching
If you don't want to corrupt the entire runtime, you can patch an instance.
s = "foo"
Footing.patch! s, Footing::String
s.respond_to? :escape # => true
"foo".respond_to? :escape # => false
Shotgun patching
For the lazy and brave, you can also patch everything at once.
Footing.patch_all!
Patch free
Dont like monkey patches? Run patch free by setting up utility methods instead.
Footing.util! Footing::String
Footing::String.escape "foo", "o" # => "f\\o\\o"
Kick the tires
git clone git://github.com/hopsoft/footing.git
cd /path/to/footing
bundle
./test
./console
Footing.patch! String, Footing::String
or
gem install footing
irb
require 'rubygems'
require 'footing'
Footing.patch! String, Footing::String