| 1 | package Exporter::Declare::Specs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 5 | our @CARP_NOT = qw/Exporter::Declare/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 19 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 19 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 19 | my ( $package, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 19 | my $self = bless( [$package,{},{},[]], $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 19 | ▶ | @args = (':default') unless @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 19 | $self->_process( "import list", @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 19 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 129 | ▶ | sub package { shift->[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
package: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 168 | ▶ | sub config { shift->[1] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 275 | ▶ | sub exports { shift->[2] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exports: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 41 | ▶ | sub excludes { shift->[3] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
excludes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 15 | ▶ | sub export { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
export: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 15 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 15 | my ( $dest ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 15 | for my $item ( keys %{ $self->exports }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 77 | my ( $export, $conf, $args ) = @{ $self->exports->{$item} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 77 | my ( $sigil, $name ) = ( $item =~ m/^([\&\%\$\@])(.*)$/ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | $name = $conf->{as} || join( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | $conf->{prefix} || $self->config->{prefix} || '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 77 | ▶ | $conf->{suffix} || $self->config->{suffix} || '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition84%11/13
$conf->{'as'} || join('', $conf->{'prefix'} || $self->config->{'prefix'} || '', $name, $conf->{'suffix'} || $self->config->{'suffix'} || '')
$conf->{'prefix'} || $self->config->{'prefix'} || ''
$conf->{"prefix"} or $self->config->{"prefix"}
$conf->{'suffix'} || $self->config->{'suffix'} || ''
$conf->{"suffix"} or $self->config->{"suffix"}
MC/DC0%0/2
$conf->{'as'} || join('', $conf->{'prefix'} || $self->config->{'prefix'} || '', $name, $conf->{'suffix'} || $self->config->{'suffix'} || '')
$conf->{'as'}
join('', $conf->{'prefix'} || $self->config->{'prefix'} || '', $name, $conf->{'suffix'} || $self->config->{'suffix'} || '')
MC/DC100%2/2
$conf->{'prefix'} || $self->config->{'prefix'} || ''
$conf->{"prefix"}
$self->config->{"prefix"}
MC/DC50%1/2
$conf->{'suffix'} || $self->config->{'suffix'} || ''
$conf->{"suffix"}
$self->config->{"suffix"}
Truth table66%2/3
A || B
A= $conf->{'as'}B= join('', $conf->{'prefix'} || $self->config->{'prefix'} || '', $name, $conf->{'suffix'} || $self->config->{'suffix'} || '')
Truth table100%3/3
A or B
A= $conf->{"prefix"}B= $self->config->{"prefix"}
Truth table66%2/3
A or B
A= $conf->{"suffix"}B= $self->config->{"suffix"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 77 | $export->inject( $dest, $name, @$args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 3 | ▶ | sub add_export { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_export: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 3 | my ( $name, $value, $config ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | ▶ | my $type = ref $value eq 'CODE' ? 'Sub' : 'Variable'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 3 | "Exporter::Declare::Export::$type"->new( $value, exported_by => scalar caller() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | ▶ | $self->exports->{$name} = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config || {}
MC/DC0%0/1
$config || {}
$config
Truth table50%1/2
A
A= $config
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | $value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | $config || {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub arguments { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arguments: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my $meta = $self->package->export_meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | return grep { $meta->is_argument($_) } keys %{$self->config}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
options: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $meta = $self->package->export_meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | return grep { $meta->is_option($_) } keys %{$self->config}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub tags { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tags: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $meta = $self->package->export_meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | return grep { $meta->is_tag($_) } keys %{$self->config}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub _make_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_info: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my $config = $self->config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | return { map { $_, $config->{$_} } @_ }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub argument_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
argument_info: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | return $self->_make_info($self->arguments); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub option_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
option_info: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | return $self->_make_info($self->options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub tag_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tag_info: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my $all_tags = $self->package->export_meta->export_tags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return { map { $_, $all_tags->{$_} } $self->tags }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 19 | ▶ | sub _process { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 19 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 19 | my ( $tag, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 19 | my $argnum = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 19 | ▶ | while ( my $item = shift( @args )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 47 | ▶ | croak "not sure what to do with $item ($tag argument: $argnum)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | if ref $item; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 47 | $argnum++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 47 | ▶ | if ( $item =~ m/^(!?)[:-](.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 16 | my ( $neg, $param ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 16 | ▶ | if ( $self->package->export_meta->arguments_has( $param )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 2 | $self->config->{$param} = shift( @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | $argnum++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 14 | ▶ | $self->config->{$param} = ref( $args[0] ) ? $args[0] : !$neg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 45 | ▶ | if ( $item =~ m/^!(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 2 | $self->_exclude_item( $1 ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | elsif ( my $type = ref( $args[0] )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 4 | my $arg = shift( @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 4 | $argnum++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 4 | ▶ | if ( $type eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | $self->_include_item( $item, undef, $arg ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | elsif ( $type eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 3 | $self->_include_item( $item, $arg, undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | croak "Not sure what to do with $item => $arg ($tag arguments: " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | . ($argnum - 1) . " and $argnum)"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 39 | $self->_include_item( $item ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 19 | delete $self->exports->{$_} for @{ $self->excludes }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 108 | ▶ | sub _item_name { my $in = shift; $in =~ m/^[\&\$\%\@]/ ? $in : "\&$in" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_item_name: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 20 | ▶ | sub _exclude_item { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exclude_item: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 20 | my ( $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 20 | ▶ | if ( $item =~ m/^[:-](.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | $self->_exclude_item( $_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 3 | for $self->_export_tags_get( $1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 17 | push @{ $self->excludes } => _item_name($item); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 100 | ▶ | sub _include_item { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_include_item: called CC=13 SCAR=25.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 100 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 100 | my ( $item, $conf, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 100 | ▶ | $conf ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$conf ||= {}
MC/DC100%1/1
$conf ||= {}
$conf
Truth table100%2/2
A
A= $conf
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 100 | ▶ | $args ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args ||= []
MC/DC100%1/1
$args ||= []
$args
Truth table100%2/2
A
A= $args
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 5 | ▶ | use Carp qw/confess/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 100 | ▶ | confess $item if $item =~ m/^&?aaa_/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | push @$args => @{ delete $conf->{'-args'} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 100 | ▶ | if defined $conf->{'-args'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 100 | for my $key ( keys %$conf ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 20 | ▶ | next if $key =~ m/^[:-]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 3 | push @$args => ( $key, delete $conf->{$key} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 100 | ▶ | if ( $item =~ m/^[:-](.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 14 | my $name = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 14 | ▶ | return if $self->package->export_meta->options_has( $name ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 14 | for my $tagitem ( $self->_export_tags_get( $name ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 52 | my ( $negate, $name ) = ( $tagitem =~ m/^(!)?(.*)$/ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 52 | ▶ | if ( $negate ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $self->_exclude_item( $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 52 | $self->_include_item( $tagitem, $conf, $args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 14 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 86 | $item = _item_name($item); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 86 | my $existing = $self->exports->{ $item }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 86 | ▶ | unless ( $existing ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 79 | $existing = [ $self->_get_item( $item ), {}, []]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 79 | $self->exports->{ $item } = $existing; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 86 | push @{ $existing->[2] } => @$args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 86 | for my $param ( keys %$conf ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 14 | my ( $name ) = ( $param =~ m/^[-:](.*)$/ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 14 | $existing->[1]->{$name} = $conf->{$param}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 80 | ▶ | sub _get_item { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_item: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 80 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 80 | my ( $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 80 | $self->package->export_meta->exports_get( $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 18 | ▶ | sub _export_tags_get { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_export_tags_get: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 18 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 18 | my ( $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 18 | $self->package->export_meta->export_tags_get( $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | Exporter::Declare::Specs - Import argument parser for Exporter::Declare | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | Import arguments can get complicated. All arguments are assumed to be exports | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | unless they have a - or : prefix. The prefix may denote a tag, a boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | option, or an option that takes the next argument as a value. In addition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | almost all these can be negated with the ! prefix. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | This class takes care of parsing the import arguments and generating data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | structures that can be used to find what the exporter needs to know. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | =item $class->new( $package, @args ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | Create a new instance and parse @args. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | =item $specs->package() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | Get the name of the package that should do the exporting. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | =item $hashref = $specs->config() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | Get the configuration hash, All specified options and tags are the keys. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | value will be true/false/undef for tags/boolean options. For options that take | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | arguments the value will be that argument. When a config hash is provided to a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | tag it will be the value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | =item @names = $specs->arguments() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | =item @names = $specs->options() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | =item @names = $specs->tags() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | Get the argument, option, or tag names that were specified for the import. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | =item $hashref = $specs->argument_info() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | Get the arguments that were specified for the import. The key is the name of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | argument and the value is what the user supplied during import. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | =item $hashref = $specs->option_info() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | Get the options that were specified for the import. The key is the name of the user | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | supplied option and the value will evaluate to true. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | =item $hashref = $specs->tag_info() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | Get the values associated with the tags used during import. The key is the name of the tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | and the value is an array ref containing the values given to export_tag() for the associated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | =item $hashref = $specs->exports() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | Get the exports hash. The keys are names of the exports. Values are an array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | containing the export, item specific config hash, and arguments array. This is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | generally not intended for direct consumption. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | =item $arrayref = $specs->excludes() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | Get the arrayref containing the names of all excluded exports. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | =item $specs->export( $package ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | Do the actual exporting. All exports will be injected into $package. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | =item $specs->add_export( $name, $value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | =item $specs->add_export( $name, $value, \%config ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | Add an export. Name is required, including sigil. Value is required, if it is a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | sub it will be blessed as a ::Sub, otherwise blessed as a ::Variable. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | $specs->add_export( '&foo' => sub { return 'foo' }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | Chad Granum L<exodist7@gmail.com> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | Copyright (C) 2010 Chad Granum | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | Exporter-Declare is free software; Standard perl licence. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | Exporter-Declare is distributed in the hope that it will be useful, but | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||