Spoon/Command.pm

filter: Statementstmt 25.0% 14 / 56 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 30.7% 4 / 13 Podpod 0.0% 0 / 5 totaltotal 17.6% 18 / 102 CC 13 SCAR 27.2
CC
13
Cov
18%
get_action
30.0
command_usage
30.0
process
13.8
CRAP 15.3
« Spoon/Hub.pm ↑ Summary Spoon/Config.pm »
1 package Spoon::Command;
2 1 ▶use Spoon::Base -Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 field quiet => 0;
5  
6 0 ▶sub process {
Subroutine process: not called CC=4 SCAR=26.3
Pod undocumented
7 1 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 0 ▶ local *boolean_arguments = sub { qw( -q -quiet ) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
9 0 my ($args, @values) = $self->parse_arguments(@_);
10 $self->quiet(1)
11 0 ▶ if $args->{-q} || $args->{-quiet};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"-q"} or $args->{"-quiet"} 0 0 0
Condition0%0/3
$args->{"-q"} or $args->{"-quiet"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->{"-q"} or $args->{"-quiet"}
$args->{"-q"} $args->{"-quiet"}
Truth table0%0/3
A or B
A= $args->{"-q"}B= $args->{"-quiet"}
ABresult
1X1
011
000
12 my $action = $self->get_action(shift(@values)) ||
13 0 ▶ sub { $self->default_action(@_) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$self->get_action(shift @values) || sub { $self->default_action(@_); }
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->get_action(shift @values) || sub { $self->default_action(@_); }
$self->get_action(shift @values) sub { $self->default_action(@_); }
Truth table0%0/3
A || B
A= $self->get_action(shift @values)B= sub { $self->default_action(@_); }
ABresult
1X1
011
000
14 0 $action->(@values);
15 0 return $self;
16 }
17  
18 0 ▶sub get_action {
Subroutine get_action: not called CC=5 SCAR=34.0
Pod undocumented
19 0 ▶ my $action = shift
Branch: 1 branch
BranchTrueFalseTotal
my $action = shift() or return 0 0 0
20 or return;
21 0 ▶ $action =~ s/^-//
Branch: 1 branch
BranchTrueFalseTotal
$action =~ s/^-// or return 0 0 0
22 or return;
23 0 my $method = "handle_$action";
24 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
25 0 $self->$method(@_);
26 0 ▶ } if $self->can($method);
Branch: 1 branch
BranchTrueFalseTotal
if $self->can($method) 0 0 0
27 0 ▶ my $array = $self->hub->registry->lookup->{command}{$action}
Branch: 1 branch
BranchTrueFalseTotal
my $array = $self->hub->registry->lookup->{"command"}{$action} or return 0 0 0
28 or return;
29 0 my $class_id = shift @$array;
30 0 my $object = $self->hub->$class_id;
31 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
32 0 $object->$method(@_);
33 0 };
34 }
35  
36 0 ▶sub default_action {
Subroutine default_action: not called CC=1 SCAR=6.9
Pod undocumented
37 0 $self->usage;
38 }
39  
40 0 ▶sub command_usage {
Subroutine command_usage: not called CC=5 SCAR=34.0
Pod undocumented
41 0 my $pattern = shift;
42 0 my $lookup = $self->hub->registry->lookup;
43 0 ▶ my $commands = $lookup->{command} || {};
Condition0%0/2
$lookup->{'command'} || {}
l!l
00
MC/DC0%0/1
$lookup->{'command'} || {}
$lookup->{'command'}
Truth table0%0/2
A
A= $lookup->{'command'}
Aresult
11
00
44 my %descriptions = map {
45 0 my $array = $commands->{$_};
46 0 shift @$array;
47 0 my %hash = @$array;
48 0 ▶ my $description = $hash{description} || '';
Condition0%0/2
$hash{'description'} || ''
l!l
00
MC/DC0%0/1
$hash{'description'} || ''
$hash{'description'}
Truth table0%0/2
A
A= $hash{'description'}
Aresult
11
00
49 0 ($_, $description);
50 } keys %$commands;
51 0 my $usage = '';
52 0 for my $plugin (@{$lookup->plugins}) {
53 0 my $class_id = $plugin->{id};
54 0 for my $command (@{$lookup->add_order->{$class_id}{command}}) {
55 0 $usage .= sprintf($pattern, $command, $descriptions{$command});
56 }
57 }
58 0 return $usage;
59 }
60  
61 0 ▶sub msg {
Subroutine msg: not called CC=2 SCAR=17.9
Pod undocumented
62 0 ▶ warn @_ unless $self->quiet;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->quiet 0 0 0
63 }
64  
65 1 __DATA__
« Spoon/Hub.pm ↑ Summary Spoon/Config.pm »