| 1 | # ============================================================================ | ||||||||||||||||||||||||||||
| 2 | package MooseX::App::Plugin::MutexGroup::Meta::Class; | ||||||||||||||||||||||||||||
| 3 | # ============================================================================ | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 7 | ▶ | around 'command_check_attributes' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||
| 9 | 7 | my ( $orig, $self, $command_meta, $errors, $params ) = @_; | |||||||||||||||||||||||||||
| 10 | 7 | ▶ | $command_meta ||= $self; | ||||||||||||||||||||||||||
|
Condition33%1/3
$command_meta ||= $self
MC/DC0%0/2
$command_meta ||= $self
$command_meta
$self
Truth table33%1/3
A ||= B
A= $command_metaB= $self
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 7 | my %mutex_groups; | |||||||||||||||||||||||||||
| 13 | 7 | foreach my $attribute ( | |||||||||||||||||||||||||||
| 14 | $self->command_usage_attributes( $command_meta, 'all' ) ) { | ||||||||||||||||||||||||||||
| 15 | 25 | ▶ | push @{ $mutex_groups{ $attribute->mutexgroup } }, $attribute | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$attribute->can("mutexgroup") and defined $attribute->mutexgroup
MC/DC100%2/2
$attribute->can("mutexgroup") and defined $attribute->mutexgroup
$attribute->can("mutexgroup")
defined $attribute->mutexgroup
Truth table100%3/3
A and B
A= $attribute->can("mutexgroup")B= defined $attribute->mutexgroup
| |||||||||||||||||||||||||||||
| 16 | if $attribute->can('mutexgroup') | ||||||||||||||||||||||||||||
| 17 | && defined $attribute->mutexgroup; | ||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 7 | foreach my $options ( values %mutex_groups ) { | |||||||||||||||||||||||||||
| 21 | my @initialized_options = | ||||||||||||||||||||||||||||
| 22 | 7 | grep { defined $params->{ $_->name } } | |||||||||||||||||||||||||||
| 23 | @$options; | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 7 | ▶ | unless ( scalar @initialized_options == 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 2 | my $error_msg; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 2 | ▶ | if (scalar @initialized_options == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 1 | my $last = pop @$options; | |||||||||||||||||||||||||||
| 30 | $error_msg = "Either ". | ||||||||||||||||||||||||||||
| 31 | 1 | join(",", map { $_->cmd_name_primary } @$options). | |||||||||||||||||||||||||||
| 32 | " or ". | ||||||||||||||||||||||||||||
| 33 | $last->cmd_name_primary. | ||||||||||||||||||||||||||||
| 34 | " must be specified"; | ||||||||||||||||||||||||||||
| 35 | } else { | ||||||||||||||||||||||||||||
| 36 | 1 | my @list = map { $_->cmd_name_primary } @initialized_options; | |||||||||||||||||||||||||||
| 37 | 1 | my $last = pop(@list); | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 1 | $error_msg = "Options ". | |||||||||||||||||||||||||||
| 40 | join(",",@list). | ||||||||||||||||||||||||||||
| 41 | " and ". | ||||||||||||||||||||||||||||
| 42 | $last. | ||||||||||||||||||||||||||||
| 43 | " are mutally exclusive"; | ||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 2 | push @$errors, | |||||||||||||||||||||||||||
| 47 | $self->command_message( | ||||||||||||||||||||||||||||
| 48 | header => $error_msg, | ||||||||||||||||||||||||||||
| 49 | type => "error", | ||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 7 | return $self->$orig( $command_meta, $errors, $params ); | |||||||||||||||||||||||||||
| 55 | 3 | }; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 3 | 1; | |||||||||||||||||||||||||||