Module::Patch

Base class for patch module
Download

Module::Patch Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Steven Haryanto
  • Publisher web site:
  • http://search.cpan.org/~sharyanto/

Module::Patch Tags


Module::Patch Description

Module::Patch is a Perl module that helps you create a patch module, a module that (monkey-)patches other module by replacing some of its subroutines.Patch module should be named Some::Module::patch::your_category. For example, HTTP::Daemon::patch::ipv6.You specify patch information (which versions of target modules and which subroutines to be replaced), while Module::Patch: checks target module version Can either die, display warning, or ignore if target module version is not supported. checks other patch modules for the same target version For example, if your patch module is Some::Module::patch::your_category, it will check other loaded Some::Module::patch::* for conflicts, i.e. whether the other patch modules want to patch the same subroutines. Can either die, display warning, or ignore if there are conflicts. provides an import()/unimport() routine unimport() will restore target module's original subroutines.SYNOPSIS # in your patch module package Some::Module::patch::your_category; use parent qw(Module::Patch); sub patch_data { my $my_foo = sub { my $orig = shift; ... }; return { versions => { # version specification can be a single version string '1.00' => { subs => { foo => $my_foo, bar => sub { ... }, ... }, }, # or multiple versions, separated by whitespace '1.02 1.03 /^2\..+$/' => { ... }, # also can contain a regex (/.../), no spaces in regex though. and # watch out for escapes. '1.99 /^2.+$/' => { ... }, }, }; } 1; # using your patch module use Some::Module; use Some::Module::patch::your_category # optional, default is 'die' -on_unknown_version => 'warn', # optional, default is 'die' -on_conflict => 'warn' ; my $o = Some::Module->new; $o->foo(); # the patched version { no Some::Module::patch::your_category; $o->foo(); # the original version }Product's homepage


Module::Patch Related Software