Supporting plugins was Jim Cromie's idea. He was even good enough to send a nice big patch. I ended up not using his patch and writing my own version, for various reasons, but he deserves a great deal of credit for the idea.
The way I've done plugins is, I think, really nifty. We use File::Find::Rule to find any Data::Compare::Plugins::* module on the system, and
require it. Because
require returns the value from evaluating the code, we make use of that, and instead of just evaluating to
1 like most modules do, plugins must evaluate to a data structure which describes what the plugin can compare and how. That is squirreled away in a hash for easy access later.
Then, whenever we come to compare two structures, we first check to see if there is a hash entry for that pair of data types and if there is, do whatever the plugin says. If there isn't, we try to compare the underlying data structures.
Plugins are useful in two circumstances that I can see:
And then this morning, the first thing I did was spot a documentation bug in the new version. Oops.
[Update] I spotted another oopsie too, where it might try to load the same plugin twice, and hence spit out errors about redefined subroutines and stuff. Both fixed in 0.07