~ubuntu-branches/ubuntu/precise/bioperl/precise

« back to all changes in this revision

Viewing changes to Bio/Root/RootI.pm

  • Committer: Bazaar Package Importer
  • Author(s): Ilya Barygin
  • Date: 2010-01-27 22:48:22 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100127224822-ebot4qbrjxcv38au
Tags: 1.6.1-1ubuntu1
* Merge from Debian testing, remaining changes:
  - disable tests, they produce a FTBFS trying to access the network 
    during run.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# $Id: RootI.pm 15407 2009-01-20 05:18:29Z cjfields $
 
1
# $Id: RootI.pm 16090 2009-09-15 21:57:56Z cjfields $
2
2
#
3
3
# BioPerl module for Bio::Root::RootI
4
4
#
 
5
# Please direct questions and support issues to <bioperl-l@bioperl.org> 
 
6
#
5
7
# Cared for by Ewan Birney <birney@ebi.ac.uk>
6
8
#
7
9
# Copyright Ewan Birney
211
213
           
212
214
           $obj->deprecated(
213
215
                -message => 'use of the method foo() is deprecated, use bar() instead',
214
 
                -version => 1.006);
215
 
                            
216
 
           The version is optional but highly suggested. For proper comparisons
217
 
           one must use a version in lines with the current versioning scheme
218
 
           for Perl and BioPerl, (i.e. where 1.006000 indicates v1.6.0, 5.010000
219
 
           for v5.10.0, etc.).
 
216
                -version => 1.006  # throw if $VERSION is >= this version
 
217
                );
 
218
 
 
219
           or timed to go off at a certain point:
 
220
           
 
221
           $obj->deprecated(
 
222
                -message => 'use of the method foo() is deprecated, use bar() instead',
 
223
                -warn_version    => 1.006 # warn if $VERSION is >= this version
 
224
                -throw_version   => 1.007 # throw if $VERSION is >= this version
 
225
                );
 
226
           
 
227
           Using the last two named argument versions is suggested and will
 
228
           likely be the only supported way of calling this method in the future
 
229
           Yes, we see the irony of deprecating that particular usage of
 
230
           deprecated().
 
231
           
 
232
           The main difference between usage of the two named argument versions
 
233
           is that by designating a 'warn_version' one indicates the
 
234
           functionality is officially deprecated beginning in a future version
 
235
           of BioPerl (so warnings are issued only after that point), whereas
 
236
           setting either 'version' or 'throw_version' (synonyms) converts the
 
237
           deprecation warning to an exception.
 
238
           
 
239
           For proper comparisons one must use a version in lines with the
 
240
           current versioning scheme for Perl and BioPerl, (i.e. where 1.006000
 
241
           indicates v1.6.0, 5.010000 for v5.10.0, etc.).
220
242
 
221
243
=cut
222
244
 
223
245
sub deprecated{
224
246
    my ($self) = shift;
225
 
    my ($msg, $version) = $self->_rearrange([qw(MESSAGE VERSION)], @_);
 
247
    my ($msg, $version, $warn_version, $throw_version) =
 
248
        $self->_rearrange([qw(MESSAGE VERSION WARN_VERSION THROW_VERSION)], @_);    
 
249
    $version ||= $throw_version;
 
250
    for my $v ($warn_version, $version) {
 
251
        next unless defined $v;
 
252
        $self->throw('Version must be numerical, such as 1.006000 for v1.6.0, not '.
 
253
                     $v) unless $v =~ /^\d+\.\d+$/;
 
254
    }
 
255
    return if ($warn_version && $Bio::Root::Version::VERSION < $warn_version);
 
256
    # below default insinuates we're deprecating a method and not a full module
 
257
    # but it's the most common use case
 
258
    $msg ||= "Use of ".(caller(1))[3]."() is deprecated";
226
259
    # delegate to either warn or throw based on whether a version is given
227
260
    if ($version) {
228
 
        $self->throw('Version must be numerical, such as 1.006000 for v1.6.0, not '.
229
 
                     $version) unless $version =~ /^\d+\.\d+$/;
 
261
        $msg .= "\nTo be removed in $version";
230
262
        if ($Bio::Root::Version::VERSION >= $version) {
231
263
            $self->throw($msg)
232
264
        }