Circle/CommandInvocation.pm

filter: Statementstmt 83.3% 35 / 42 Branchbran 33.3% 4 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 11 / 12 Podpod 0.0% 0 / 7 totaltotal 68.4% 50 / 73 CC 7 SCAR 12.6
CC
7
Cov
72%
peek_token
6.6
pull_token
6.6
nest
2.0
CRAP 3.5
« Circle/Widget/Box.pm ↑ Summary Circle/Net/Raw.pm »
1 # You may distribute under the terms of the GNU General Public License
2 #
3 # (C) Paul Evans, 2008-2010 -- leonerd@leonerd.org.uk
4  
5 package Circle::CommandInvocation;
6  
7 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 our $VERSION = '0.173320';
11  
12 4 ▶use Scalar::Util qw( weaken );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub new
15 5 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
16 5 my $class = shift;
17 5 my ( $text, $connection, $invocant ) = @_;
18  
19 5 $text =~ s/^\s+//;
20  
21 # Weaken the connection to ensure that this object doesn't hold on to the
22 # connection longer than required
23 5 my $self = bless [ $text, $connection, $invocant ], $class;
24 5 weaken( $self->[1] );
25 5 return $self;
26 }
27  
28 sub nest
29 0 ▶{
Subroutine nest: not called CC=1 SCAR=6.9
Pod undocumented
30 0 my $self = shift;
31 0 my ( $text ) = @_;
32 0 return (ref $self)->new( $text, $self->connection, $self->invocant );
33 }
34  
35 sub connection
36 14 ▶{
Subroutine connection: called CC=1 SCAR=0.0
Pod undocumented
37 14 my $self = shift;
38 14 return $self->[1];
39 }
40  
41 sub invocant
42 19 ▶{
Subroutine invocant: called CC=1 SCAR=0.0
Pod undocumented
43 19 my $self = shift;
44 19 return $self->[2];
45 }
46  
47 sub peek_token
48 8 ▶{
Subroutine peek_token: called CC=4 SCAR=18.9
Pod undocumented
49 8 my $self = shift;
50  
51 8 ▶ if( $self->[0] =~ m/^"/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[0] =~ /^"/) { } 0 8 8
52 0 ▶ $self->[0] =~ m/^"(.*)"/ and return $1;
Branch: 1 branch
BranchTrueFalseTotal
$self->[0] =~ /^"(.*)"/ and return $1 0 0 0
53 }
54 else {
55 8 ▶ $self->[0] =~ m/^(\S+)/ and return $1;
Branch: 1 branch
BranchTrueFalseTotal
$self->[0] =~ /^(\S+)/ and return $1 8 0 8
56 }
57  
58 0 return undef;
59 }
60  
61 sub pull_token
62 15 ▶{
Subroutine pull_token: called CC=4 SCAR=18.9
Pod undocumented
63 15 my $self = shift;
64  
65 15 ▶ if( $self->[0] =~ m/^"/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[0] =~ /^"/) { } 0 15 15
66 0 ▶ $self->[0] =~ s/^"(.*)"\s*// and return $1;
Branch: 1 branch
BranchTrueFalseTotal
$self->[0] =~ s/^"(.*)"\s*// and return $1 0 0 0
67 }
68 else {
69 15 ▶ $self->[0] =~ s/^(\S+)\s*// and return $1;
Branch: 1 branch
BranchTrueFalseTotal
$self->[0] =~ s/^(\S+)\s*// and return $1 15 0 15
70 }
71  
72 0 return undef;
73 }
74  
75 sub peek_remaining
76 21 ▶{
Subroutine peek_remaining: called CC=1 SCAR=0.0
Pod undocumented
77 21 my $self = shift;
78 21 return $self->[0];
79 }
80  
81 # delegate these to invocant
82 4 foreach my $method (qw(
83 respond
84 respondwarn
85 responderr
86 respond_table
87 )) {
88 4 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
89 5 ▶ *$method = sub { shift->invocant->$method( @_ ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
90 }
91  
92 4 0x55AA;
« Circle/Widget/Box.pm ↑ Summary Circle/Net/Raw.pm »