X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FPackage%2FDeprecationManager.pm;h=f8c9e8126a33b7faa575769381d22c7ccef3df72;hb=e1d24eefa22633edc19f051bf97bbc3a202f077f;hp=b18cb658cc090b0f5d33605c6aef24a3258e735f;hpb=dc4fc8c7d1c1c6f1d6689a0b16a5d13e8ecf38e5;p=gitmo%2FPackage-DeprecationManager.git diff --git a/lib/Package/DeprecationManager.pm b/lib/Package/DeprecationManager.pm index b18cb65..f8c9e81 100644 --- a/lib/Package/DeprecationManager.pm +++ b/lib/Package/DeprecationManager.pm @@ -48,6 +48,8 @@ sub _build_import { my $class = shift; my %args = @_; + $args{-api_version} ||= delete $args{-compatible}; + $registry->{ caller() } = $args{-api_version} if $args{-api_version}; @@ -99,8 +101,85 @@ __END__ =head1 SYNOPSIS - ... + package My::Class; + + use Package::DeprecationManager + -deprecations => { + 'My::Class::foo' => '0.02', + 'My::Class::bar' => '0.05', + }; + + sub foo { + deprecated( 'Do not call foo!' ); + + ... + } + + sub bar { + deprecated(); + + ... + } + + package Other::Class; + + use My::Class -api_version => '0.04'; + + My::Class->new()->foo(); # warns + My::Class->new()->bar(); # does not warn + My::Class->new()->far(); # does not warn again =head1 DESCRIPTION +This module allows you to manage a set of deprecations for one or more modules. + +When you import C, you must provide a set of +C<-deprecations> as a hash ref. The keys are fully qualified sub/method names, +and the values are the version when that subroutine was deprecated. + +As part of the import process, C will export two +subroutines into its caller. It proves an C sub for the caller and a +C sub. + +The C sub allows callers of I class to specify an C<-api_version> +parameter. If this is supplied, then deprecation warnings are only issued for +deprecations for api versions earlier than the one specified. + +You must call C sub in each deprecated subroutine. When called, +it will issue a warning using C. If you do not pass an explicit +warning message, one will be generated for you. + +Deprecation warnings are only issued once for a given package, regardless of +how many times the deprecated sub/method is called. + +=head1 BUGS + +Please report any bugs or feature requests to +C, or through the web interface at +L. I will be notified, and then you'll automatically be +notified of progress on your bug as I make changes. + +=head1 DONATIONS + +If you'd like to thank me for the work I've done on this module, please +consider making a "donation" to me via PayPal. I spend a lot of free time +creating free software, and would appreciate any support you'd care to offer. + +Please note that B in order +for me to continue working on this particular software. I will +continue to do so, inasmuch as I have in the past, for as long as it +interests me. + +Similarly, a donation made in this way will probably not make me work on this +software much more, unless I get so many donations that I can consider working +on free software full time, which seems unlikely at best. + +To donate, log into PayPal and send money to autarch@urth.org or use the +button on this page: L + +=head1 CREDITS + +The idea for this functionality and some of its implementation was originally +created as L by Goro Fuji. + =cut