« /usr/local/lib/perl5/5.44.0/x86_64-linux/Unicode/Normalize.pm
↑ Summary
/usr/local/lib/perl5/site_perl/5.44.0/Pod/Coverage/CountParents.pm »
| 1 | package Sub::Exporter::Progressive; | ||||||||||||||||||||
| 2 | 7 | $Sub::Exporter::Progressive::VERSION = '0.001013'; | |||||||||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 7 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | # ABSTRACT: Only use Sub::Exporter if you need it | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 0 | ▶ | sub _croak { | ||||||||||||||||||
|
Subroutine
_croak: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 9 | 0 | require Carp; | |||||||||||||||||||
| 10 | 0 | &Carp::croak; | |||||||||||||||||||
| 11 | } | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 14 | ▶ | sub import { | ||||||||||||||||||
|
Subroutine
import: called CC=1 SCAR=0.2
| |||||||||||||||||||||
| 14 | 14 | my ($self, @args) = @_; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 14 | my $inner_target = caller; | |||||||||||||||||||
| 17 | 14 | my $export_data = sub_export_options($inner_target, @args); | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 14 | my $full_exporter; | |||||||||||||||||||
| 20 | 7 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 21 | 7 | ▶ | no warnings 'once'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | 14 | @{"${inner_target}::EXPORT_OK"} = @{$export_data->{exports}}; | |||||||||||||||||||
| 23 | 14 | @{"${inner_target}::EXPORT"} = @{$export_data->{defaults}}; | |||||||||||||||||||
| 24 | 14 | %{"${inner_target}::EXPORT_TAGS"} = %{$export_data->{tags}}; | |||||||||||||||||||
| 25 | 14 | ▶ | *{"${inner_target}::import"} = sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=25.3
| |||||||||||||||||||||
| 26 | 7 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 27 | 7 | my ($self, @args) = @_; | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 7 | ▶ | if ( grep { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 30 | 7 | ▶ | length ref $_ | ||||||||||||||||||
|
Condition33%1/3
length ref $_ || !($_ =~ / \A [:-]? \w+ \z /mx)
MC/DC0%0/2
length ref $_ || !($_ =~ / \A [:-]? \w+ \z /mx)
length ref $_
!($_ =~ / \A [:-]? \w+ \z /mx)
Truth table33%1/3
A || not(B)
A= length ref $_B= !($_ =~ / \A [:-]? \w+ \z /mx)
| |||||||||||||||||||||
| 31 | or | ||||||||||||||||||||
| 32 | $_ !~ / \A [:-]? \w+ \z /xm | ||||||||||||||||||||
| 33 | } @args ) { | ||||||||||||||||||||
| 34 | _croak 'your usage of Sub::Exporter::Progressive requires Sub::Exporter to be installed' | ||||||||||||||||||||
| 35 | 0 | ▶ | unless eval { require Sub::Exporter }; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | 0 | ▶ | $full_exporter ||= Sub::Exporter::build_exporter($export_data->{original}); | ||||||||||||||||||
|
Condition0%0/3
$full_exporter ||= Sub::Exporter::build_exporter($export_data->{"original"})
MC/DC0%0/2
$full_exporter ||= Sub::Exporter::build_exporter($export_data->{"original"})
$full_exporter
Sub::Exporter::build_exporter($export_data->{"original"})
Truth table0%0/3
A ||= B
A= $full_exporterB= Sub::Exporter::build_exporter($export_data->{"original"})
| |||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | goto $full_exporter; | |||||||||||||||||||
| 39 | 7 | } elsif ( defined( (my ($num) = grep { m/^\d/ } @args)[0] ) ) { | |||||||||||||||||||
| 40 | 0 | _croak "cannot export symbols with a leading digit: '$num'"; | |||||||||||||||||||
| 41 | } else { | ||||||||||||||||||||
| 42 | 7 | require Exporter; | |||||||||||||||||||
| 43 | 7 | s/ \A - /:/xm for @args; | |||||||||||||||||||
| 44 | 7 | @_ = ($self, @args); | |||||||||||||||||||
| 45 | 7 | goto \&Exporter::import; | |||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | 14 | }; | |||||||||||||||||||
| 48 | 14 | return; | |||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 7 | my $too_complicated = <<'DEATH'; | |||||||||||||||||||
| 52 | You are using Sub::Exporter::Progressive, but the features your program uses from | ||||||||||||||||||||
| 53 | Sub::Exporter cannot be implemented without Sub::Exporter, so you might as well | ||||||||||||||||||||
| 54 | just use vanilla Sub::Exporter | ||||||||||||||||||||
| 55 | DEATH | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 14 | ▶ | sub sub_export_options { | ||||||||||||||||||
|
Subroutine
sub_export_options: called CC=16 SCAR=29.5
Pod
undocumented
| |||||||||||||||||||||
| 58 | 14 | my ($inner_target, $setup, $options) = @_; | |||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 14 | my @exports; | |||||||||||||||||||
| 61 | my @defaults; | ||||||||||||||||||||
| 62 | 14 | my %tags; | |||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 14 | ▶ | if ( ($setup||'') eq '-setup') { | ||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$setup || ''
MC/DC0%0/1
$setup || ''
$setup
Truth table50%1/2
A
A= $setup
| |||||||||||||||||||||
| 65 | 14 | my %options = %$options; | |||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | OPTIONS: | ||||||||||||||||||||
| 68 | 14 | for my $opt (keys %options) { | |||||||||||||||||||
| 69 | 28 | ▶ | if ($opt eq 'exports') { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 14 | ▶ | _croak $too_complicated if ref $options{exports} ne 'ARRAY'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 72 | 14 | @exports = @{$options{exports}}; | |||||||||||||||||||
| 73 | 14 | ▶ | _croak $too_complicated if grep { length ref $_ } @exports; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | } elsif ($opt eq 'groups') { | ||||||||||||||||||||
| 76 | 14 | %tags = %{$options{groups}}; | |||||||||||||||||||
| 77 | 14 | for my $tagset (values %tags) { | |||||||||||||||||||
| 78 | _croak $too_complicated if grep { | ||||||||||||||||||||
| 79 | 14 | ▶ | length ref $_ | ||||||||||||||||||
|
Condition33%1/3
length ref $_ || $_ =~ / \A - (?! all \b ) /x
MC/DC0%0/2
length ref $_ || $_ =~ / \A - (?! all \b ) /x
length ref $_
$_ =~ / \A - (?! all \b ) /x
Truth table33%1/3
A || B
A= length ref $_B= $_ =~ / \A - (?! all \b ) /x
| |||||||||||||||||||||
| 80 | or | ||||||||||||||||||||
| 81 | $_ =~ / \A - (?! all \b ) /x | ||||||||||||||||||||
| 82 | 14 | ▶ | } @{$tagset}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | 14 | ▶ | @defaults = @{$tags{default} || [] }; | ||||||||||||||||||
|
Condition50%1/2
$tags{'default'} || []
MC/DC0%0/1
$tags{'default'} || []
$tags{'default'}
Truth table50%1/2
A
A= $tags{'default'}
| |||||||||||||||||||||
| 85 | } else { | ||||||||||||||||||||
| 86 | 0 | _croak $too_complicated; | |||||||||||||||||||
| 87 | } | ||||||||||||||||||||
| 88 | } | ||||||||||||||||||||
| 89 | 14 | ▶ | @{$_} = map { / \A [:-] all \z /x ? @exports : $_ } @{$_} for \@defaults, values %tags; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 90 | 14 | ▶ | $tags{all} ||= [ @exports ]; | ||||||||||||||||||
|
Condition50%1/2
$tags{"all"} ||= [@exports]
MC/DC0%0/1
$tags{"all"} ||= [@exports]
$tags{"all"}
Truth table50%1/2
A
A= $tags{"all"}
| |||||||||||||||||||||
| 91 | 14 | my %exports = map { $_ => 1 } @exports; | |||||||||||||||||||
| 92 | 14 | my @errors = grep { not $exports{$_} } @defaults; | |||||||||||||||||||
| 93 | 14 | ▶ | _croak join(', ', @errors) . " is not exported by the $inner_target module\n" if @errors; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 94 | } | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | return { | ||||||||||||||||||||
| 97 | 14 | exports => \@exports, | |||||||||||||||||||
| 98 | defaults => \@defaults, | ||||||||||||||||||||
| 99 | original => $options, | ||||||||||||||||||||
| 100 | tags => \%tags, | ||||||||||||||||||||
| 101 | }; | ||||||||||||||||||||
| 102 | } | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | 7 | 1; | |||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | __END__ | ||||||||||||||||||||