| 1 | package FAST::Bio::Root::Version; | ||
| 2 | use strict; | ||
| 3 | |||
| 4 | # ABSTRACT: provide global, distribution-level versioning | ||
| 5 | # AUTHOR: Aaron Mackey <amackey@virginia.edu> | ||
| 6 | # OWNER: Aaron Mackey | ||
| 7 | # LICENSE: Perl_5 | ||
| 8 | |||
| 9 | =head1 SYNOPSIS | ||
| 10 | |||
| 11 | package FAST::Bio::Tools::NiftyFeature; | ||
| 12 | require FAST::Bio::Root::RootI; | ||
| 13 | |||
| 14 | |||
| 15 | # later, in client code: | ||
| 16 | package main; | ||
| 17 | use FAST::Bio::Tools::NiftyFeature 3.14; | ||
| 18 | |||
| 19 | |||
| 20 | ## alternative usage: NiftyFeature defines own $VERSION: | ||
| 21 | package FAST::Bio::Tools::NiftyFeature; | ||
| 22 | my $VERSION = 9.8; | ||
| 23 | |||
| 24 | # later in client code: | ||
| 25 | package main; | ||
| 26 | |||
| 27 | # ensure we're using an up-to-date BioPerl distribution | ||
| 28 | use FAST::Bio::Perl 3.14; | ||
| 29 | |||
| 30 | # NiftyFeature has its own versioning scheme: | ||
| 31 | use FAST::Bio::Tools::NiftyFeature 9.8; | ||
| 32 | |||
| 33 | =head1 DESCRIPTION | ||
| 34 | |||
| 35 | This module provides a mechanism by which all other BioPerl modules | ||
| 36 | can share the same $VERSION, without manually synchronizing each file. | ||
| 37 | |||
| 38 | FAST::Bio::Root::RootI itself uses this module, so any module that directly | ||
| 39 | (or indirectly) uses FAST::Bio::Root::RootI will get a global $VERSION | ||
| 40 | variable set if it's not already. | ||
| 41 | |||
| 42 | =cut | ||
| 43 | |||
| 44 | our $VERSION = '1.006924'; # pre-1.7 | ||
| 45 | $VERSION = eval $VERSION; | ||
| 46 | |||
| 47 | sub import { | ||
| 48 | # try to handle multiple levels of inheritance: | ||
| 49 | my $i = 0; | ||
| 50 | my $pkg = caller($i); | ||
| 51 | no strict 'refs'; | ||
| 52 | while ($pkg) { | ||
| 53 | if ( $pkg =~ m/^FAST::Bio::/o | ||
| 54 | and not defined ${$pkg . "::VERSION"} | ||
| 55 | ) { | ||
| 56 | ${$pkg . "::VERSION"} = $VERSION; | ||
| 57 | } | ||
| 58 | $pkg = caller(++$i); | ||
| 59 | } | ||
| 60 | } | ||
| 61 | |||
| 62 | 1; | ||
| 63 | __END__ |