File Coverage

blib/lib/Alt/Base.pm
Criterion Covered Total %
statement 33 33 100.0
branch 10 10 100.0
condition 1 3 33.3
subroutine 6 6 100.0
pod n/a
total 50 52 96.1


line stmt bran cond sub pod time code
1             package Alt::Base;
2              
3 1     1   1204 use strict;
  1         2  
  1         35  
4 1     1   4 use warnings;
  1         2  
  1         70  
5              
6             our $VERSION = '0.02'; # VERSION
7              
8             sub import {
9 5     5   4150 my $self = shift;
10              
11 5   33     23 my $class = ref($self) || $self;
12 5         6 my %opts;
13             {
14 1     1   4 no strict 'refs';
  1         1  
  1         22  
  5         7  
15 1     1   3 no warnings;
  1         2  
  1         156  
16 5         9 %opts = %{"$class\::ALT"};
  5         27  
17             }
18              
19 5 100       23 if (defined($opts{check}) ? $opts{check} : 1) {
    100          
20 4 100       43 my ($orig, $phrase) = $class =~ /^Alt::(\w+(?:::\w+)*)::(\w+)$/
21             or die "Bad syntax in alternate module name '$class', should be ".
22             "Alt::::\n";
23 3         6 my $origf = $orig;
24 3         5 $origf =~ s!::!/!g; $origf .= ".pm";
  3         5  
25 3         1213 require $origf;
26 3         26 my $mphrase;
27             {
28 1     1   4 no strict 'refs';
  1         1  
  1         121  
  3         4  
29 3         4 $mphrase = ${"$orig\::ALT"};
  3         10  
30             }
31 3 100       20 defined($mphrase)
32             or die "$orig does not define \$ALT, might not be from the same ".
33             "distribution as $class\n";
34 2 100       22 $mphrase eq $phrase
35             or die "$orig has \$ALT set to '$mphrase' instead of '$phrase', ".
36             "might not be from the same distribution as $class\n";
37             }
38             }
39              
40             1;
41             #ABSTRACT: Base class for alternate module
42              
43              
44             __END__