Finger/Request.pm

filter: Statementstmt 96.6% 29 / 30 Branchbran 87.5% 14 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 11 / 12 Podpod 100% 7 / 7 totaltotal 93.8% 61 / 65 CC 9 SCAR 7.5
CC
9
Cov
93%
verbose
3.0
username
3.0
hostnames
3.0
CRAP 2.1
« Finger/Client.pm ↑ Summary Finger.pm »
1 package AnyEvent::Finger::Request;
2  
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 use overload
6 12 ▶ '""' => sub { shift->as_string },
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=1 SCAR=0.0
7 0 ▶ bool => sub { 1 }, fallback => 1;
Subroutine __ANON__: not called CC=1 SCAR=0.2
8  
9 # ABSTRACT: Simple asynchronous finger request
10 6 our $VERSION = '0.14'; # VERSION
11  
12  
13 sub new
14 28 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod documented
15 28 bless { raw => "$_[1]" }, $_[0];
16 }
17  
18  
19 sub verbose
20 18 ▶{
Subroutine verbose: called CC=3 SCAR=11.1
Pod documented
21 18 my($self) = @_;
22 18 ▶ defined $self->{verbose} ? $self->{verbose} : $self->{verbose} = ($self->{raw} =~ /^\/W/ ? 1 : 0);
Branch: 2 branches
BranchTrueFalseTotal
$self->{'raw'} =~ m[^/W] ? : 9 9 18
defined $self->{'verbose'} ? : 0 18 18
23 }
24  
25  
26 sub username
27 39 ▶{
Subroutine username: called CC=3 SCAR=11.0
Pod documented
28 39 my($self) = @_;
29  
30 39 ▶ unless(defined $self->{username})
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"username"}) 22 17 39
31 {
32 22 ▶ if($self->{raw} =~ /^(?:\/W\s*)?([^@]*)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"raw"} =~ m[^(?:/W\s*)?([^\@]*)]) 22 0 22
33 22 { $self->{username} = $1 }
34 }
35  
36 39 $self->{username};
37 }
38  
39  
40 sub hostnames
41 54 ▶{
Subroutine hostnames: called CC=3 SCAR=11.0
Pod documented
42 54 my($self) = @_;
43 54 ▶ return $self->{hostnames} if defined $self->{hostnames};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"hostnames"} 26 28 54
44 28 ▶ $self->{hostnames} = ($self->{raw} =~ /\@(.*)$/ ? [split /\@/, $1] : []);
Branch: 1 branch
BranchTrueFalseTotal
$self->{'raw'} =~ /\@(.*)$/ ? : 14 14 28
45 }
46  
47  
48 sub as_string
49 12 ▶{
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
50 12 my($self) = @_;
51 12 join('@', ($self->username, @{ $self->hostnames }));
52 }
53  
54  
55 8 ▶sub listing_request { shift->username eq '' ? 1 : 0 }
Subroutine listing_request: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
(shift())->username eq '' ? : 2 6 8
56  
57  
58  
59 23 ▶sub forward_request { @{ shift->hostnames } > 0 ? 1 : 0}
Subroutine forward_request: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@{(shift())->hostnames;} > 0 ? : 13 10 23
60  
61 6 1;
62  
63 __END__
« Finger/Client.pm ↑ Summary Finger.pm »