There’s so much existing material here. Just look at all the dozens of existing plugins.
Here’s an example of overriding the onebox system:
Note that patching can be very targeted and clever (this plugin isn’t particularly! But that’s partly due to the structure of this core code that makes overrides necessarily verbose) and the art of it is doing as little as possible to get the desired effect: if you are proposing to override entire files you might want to think again about your overall approach.
And again as per Richard you are almost never (in Ruby on Rails at least) overriding entire files. You need to think about methods.