PrettyCure/Girl/Role.pm

filter: Statementstmt 76.3% 42 / 55 Branchbran 36.3% 8 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.8% 13 / 14 Podpod 40.0% 2 / 5 totaltotal 67.7% 65 / 96 CC 13 SCAR 28.0
CC
13
Cov
65%
image
56.0
transform
3.0
say
3.0
CRAP 16.4
↑ Summary PrettyCure/Girl/Role/DokiDoki.pm »
1 package Acme::PrettyCure::Girl::Role;
2 20 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 20 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 20 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 20 ▶use Furl;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 20 ▶use Cache::LRU;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 20 ▶use Net::DNS::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 20 ▶use Imager;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 20 $Net::DNS::Lite::CACHE = Cache::LRU->new(size => 256);
12  
13 20 requires qw(human_name precure_name challenge image_url);
14  
15 has 'is_precure' => (
16 is => 'rw',
17 399 ▶ isa => sub { die "$_[0] is not a boolean" if $_[0] !~ /^[01]$/ },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
if not $_[0] =~ /^[01]$/ 0 399 399
18 292 ▶ default => sub {0}
Subroutine __ANON__: called CC=1 SCAR=0.0
19 20 );
20  
21 205 ▶sub say {
Subroutine say: called CC=3 SCAR=11.0
Pod undocumented
22 205 my ($self, $text) = @_;
23 205 my $color = $self->color;
24 205 ▶ if ( defined $color ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $color) 179 26 205
25 179 print "\e[38;5;${color}m";
26 }
27 205 print encode_utf8("$text\n");
28 205 ▶ if ( defined $color ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $color) 179 26 205
29 179 print "\e[0m";
30 }
31 }
32  
33 26 ▶sub color { undef }
Subroutine color: called CC=1 SCAR=0.0
Pod undocumented
34  
35 80 ▶sub name {
Subroutine name: called CC=2 SCAR=6.9
Pod documented
36 80 my $self = shift;
37  
38 80 ▶ return $self->is_precure ? $self->precure_name : $self->human_name;
Branch: 1 branch
BranchTrueFalseTotal
$self->is_precure ? : 38 42 80
39 }
40  
41 99 ▶sub transform {
Subroutine transform: called CC=3 SCAR=11.1
Pod documented
42 99 my ($self, $buddy) = @_;
43  
44 99 ▶ die "already transformed" if $self->is_precure;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_precure 0 99 99
45  
46 99 $self->is_precure(1);
47  
48 99 $self->say($_) for $self->challenge;
49  
50 99 return $self;
51 }
52  
53 0 ▶sub image {
Subroutine image: not called CC=7 SCAR=40.3
Pod undocumented
54 0 my $self = shift;
55  
56 0 my $furl = Furl::HTTP->new(
57 agent => 'Acme-PrettyCure',
58 inet_aton => \&Net::DNS::Lite::inet_aton,
59 timeout => 60,
60 );
61 0 my ( $minor_version, $status, $message, $headers, $content ) =
62 $furl->request( method => 'GET', url => $self->image_url, );
63  
64 0 my $img = Imager->new();
65 0 my $type;
66 0 ▶ if ($self->image_url =~ /\.gif$/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->image_url =~ /\.gif$/) { } 0 0 0
elsif ($self->image_url =~ /\.png$/) { } 0 0 0
elsif ($self->image_url =~ /\.jpe?g$/) { } 0 0 0
67 0 $type = 'gif';
68 }
69 elsif ($self->image_url =~ /\.png$/) {
70 0 $type = 'png';
71 }
72 elsif ($self->image_url =~ /\.jpe?g$/) {
73 0 $type = 'jpeg';
74 }
75 0 ▶ $img->read(data => $content, type => $type) or die $img->errstr;
Branch: 1 branch
BranchTrueFalseTotal
$img->read("data", $content, "type", $type) or die $img->errstr 0 0 0
76  
77 0 ▶ open my $ah, '|-', qw/aview -reverse -driver curses/ or die "aview:$!";
Branch: 1 branch
BranchTrueFalseTotal
open my $ah, "|-", ("aview", "-reverse", "-driver", "curses") or die "aview:$!" 0 0 0
78 0 ▶ $img->write( fh => $ah, type => 'pnm' ) or die $img->errstr;
Branch: 1 branch
BranchTrueFalseTotal
$img->write("fh", $ah, "type", "pnm") or die $img->errstr 0 0 0
79 0 close($ah);
80 }
81  
82 20 1;
83 __END__
↑ Summary PrettyCure/Girl/Role/DokiDoki.pm »