blib/lib/PDL/Exporter.pm

filter: Statementstmt 100% 11 / 11 Branchbran 87.5% 7 / 8 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 96.1% 25 / 26 CC 6 SCAR 16.7
CC
6
Cov
95%
import
6.0
BEGIN
1.0
CRAP 5.3
« blib/lib/PDL/Bad.pm ↑ Summary blib/lib/PDL/Basic.pm »
1 =head1 NAME
2  
3 PDL::Exporter - PDL export control
4  
5 =head1 DESCRIPTION
6  
7 Implements the standard conventions for
8 import of PDL modules in to the namespace
9  
10 Hopefully will be extended to allow fine
11 control of which namespace is used.
12  
13 =head1 SYNOPSIS
14  
15 use PDL::Exporter;
16  
17 use PDL::MyModule; # Import default function list ':Func'
18 use PDL::MyModule ''; # Import nothing (OO)
19 use PDL::MyModule '...'; # Same behaviour as Exporter
20  
21 =head1 SUMMARY
22  
23 C<PDL::Exporter> is a drop-in replacement for the L<Exporter|Exporter>
24 module. It confers the standard PDL export conventions to your module.
25 Usage is fairly straightforward and best illustrated by an example. The
26 following shows typical usage near the top of a simple PDL module:
27  
28  
29 package PDL::MyMod;
30  
31 use strict;
32
33 # For Perl 5.6:
34 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
35 # For more modern Perls:
36 our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
37
38 require PDL::Exporter;
39
40 @ISA = qw(PDL::Exporter);
41 @EXPORT_OK = qw(inc myfunc); # these will be exported by default
42 %EXPORT_TAGS = (Func=>[@EXPORT_OK],
43 Internal => [qw/internfunc1 internfunc2/],
44 );
45
46 # ... body of your module
47
48 1; # end of simple module
49  
50  
51 =cut
52  
53 package PDL::Exporter;
54  
55 120 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
56  
57 sub import {
58 5671 ▶ my $pkg = shift;
Subroutine import: called CC=6 SCAR=17.9
59 5671 ▶ return if $pkg eq 'PDL::Exporter'; # Module don't export thyself :)
Branch: 1 branch
BranchTrueFalseTotal
if $pkg eq "PDL::Exporter" 1399 4272 5671
60 4272 my $callpkg = caller($Exporter::ExportLevel);
61 4272 ▶ print "DBG: pkg=$pkg callpkg = $callpkg :@_\n" if($PDL::Exporter::Verbose);
Branch: 1 branch
BranchTrueFalseTotal
if $Verbose 0 4272 4272
62 4272 ▶ push @_, ':Func' unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 3556 716 4272
63 4272 ▶ @_=() if scalar(@_)==1 and $_[0] eq '';
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ == 1 and $_[0] eq "" 157 4115 4272
Condition100%3/3
scalar @_ == 1 and $_[0] eq ""
!ll&&!rl&&r
554060157
MC/DC100%2/2
scalar @_ == 1 and $_[0] eq ""
scalar @_ == 1 $_[0] eq ""
Truth table100%3/3
A and B
A= scalar @_ == 1B= $_[0] eq ""
ABresult
0X0
100
111
64 4272 Exporter::export($pkg, $callpkg, @_);
65 }
66  
67 120 1;
68  
69 =head1 SEE ALSO
70  
71 L<Exporter|Exporter>
72  
73 =head1 AUTHOR
74  
75 Copyright (C) Karl Glazebrook (kgb@aaoepp.aao.gov.au).
76 Some docs by Christian Soeller.
77 All rights reserved. There is no warranty. You are allowed
78 to redistribute this software / documentation under certain
79 conditions. For details, see the file COPYING in the PDL
80 distribution. If this file is separated from the PDL distribution,
81 the copyright notice should be included in the file.
82  
83  
84 =cut
« blib/lib/PDL/Bad.pm ↑ Summary blib/lib/PDL/Basic.pm »