Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattetti/monkey_patcher
keep track of your monkey patches
https://github.com/mattetti/monkey_patcher
Last synced: about 12 hours ago
JSON representation
keep track of your monkey patches
- Host: GitHub
- URL: https://github.com/mattetti/monkey_patcher
- Owner: mattetti
- License: mit
- Created: 2010-06-06T07:04:06.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2010-06-06T07:41:34.000Z (over 14 years ago)
- Last Synced: 2024-04-24T20:13:53.755Z (9 months ago)
- Homepage:
- Size: 97.7 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
- License: LICENSE
Awesome Lists containing this project
README
= monkey_patcher
Dead simple - not so useful gem helping you keep track of your monkey patches.
In other words, this gem lets you keep track of modifications made on some "base" code, classes/methods tempered with can be easily found and the modifying code can be spotted.== Example:
require 'monkey_patcher'
# base code
class Foo
def bar; 'original Foo#bar'; end
end# monkey patch #1
class Foo
include MonkeyPatcher
monkey_trace("Reopening Foo to add a couple methods necessary for the README",
File.expand_path(__FILE__))
def self.bar; 'class method bar'; end
def bar; 'modified Foo#bar'; end
def baz; 'added Foo#baz'; end
end# monkey patch #2
class Foo
include MonkeyPatcher
monkey_trace("Just to show it works",
File.expand_path(__FILE__))
def bar; 'patched another time'; end
endputs "Foo was tempered" if Foo.monkey_patched?
puts Foo.patched_methods
puts Foo.patched_methods.first.desc=== Output:
Foo was tempered
Foo.bar - patched in /Users/mattetti/Desktop/test.rb - Reopening Foo to add a couple methods necessary for the README
bar - patched in /Users/mattetti/Desktop/test.rb - Reopening Foo to add a couple methods necessary for the README
baz - patched in /Users/mattetti/Desktop/test.rb - Reopening Foo to add a couple methods necessary for the README
bar - patched in /Users/mattetti/Desktop/test.rb - Just to show it works== Misc
The description and origin of the patch are cached in the modified class, if the same class is reopened without defining a new description and origin, the previously settings will be used. So if you see a method monkey patched 5 times in the same file when you really only monkey patched once, that means that the file was modified in other 'untraced' places.
== Note on Patches/Pull Requests
* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.== Copyright
Copyright (c) 2010 Matt Aimonetti. See LICENSE for details.