lib/IRC/Indexer/Output.pm

filter: Statementstmt 69.4% 25 / 36 Branchbran 0.0% 0 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 87.5% 7 / 8 Podpod 100% 3 / 3 totaltotal 62.0% 36 / 58 CC 7 SCAR 24.7
CC
7
Cov
57%
write
30.0
new
3.0
BEGIN
1.0
CRAP 11.8
« lib/IRC/Indexer/Trawl/Bot.pm ↑ Summary lib/IRC/Indexer/Conf.pm »
1 package IRC::Indexer::Output;
2  
3 4 ▶use 5.10.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶use Scalar::Util qw/openhandle/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 5 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
11 5 my $class = shift;
12 5 my $self = {};
13 5 bless $self, $class;
14  
15 5 my %args = @_;
16
17 5 $args{lc $_} = delete $args{$_} for keys %args;
18
19 $self->{Input} = delete $args{input}
20 5 ▶ || croak "No input specified in new" ;
Condition50%1/2
delete $args{'input'} || croak('No input specified in new')
l!l
50
MC/DC0%0/1
delete $args{'input'} || croak('No input specified in new')
delete $args{'input'}
Truth table50%1/2
A
A= delete $args{'input'}
Aresult
11
00
21  
22 5 return $self
23 }
24  
25 2 ▶sub dump {
Subroutine dump: called CC=1 SCAR=0.0
Pod documented
26 2 my ($self) = @_;
27 2 my $output = $self->{Output};
28 2 return $output
29 }
30  
31 0 ▶sub write {
Subroutine write: not called CC=5 SCAR=34.0
Pod documented
32 0 my ($self, $path) = @_;
33
34 0 ▶ unless ($path) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($path) 0 0 0
35 0 croak "write() called but no path specified" ;
36 }
37
38 0 my $out;
39 0 ▶ unless ($out = $self->{Output}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($out = $self->{"Output"}) 0 0 0
40 0 croak "write() called but no Output to write" ;
41 }
42  
43 0 ▶ if ( openhandle($path) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&openhandle($path)) { } 0 0 0
44 0 print $path $out;
45 } else {
46 0 ▶ open my $fh, '>:encoding(utf8)', $path
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">:encoding(utf8)", $path or croak("open failed in write(): $!") 0 0 0
47 or croak "open failed in write(): $!";
48 0 print $fh $out;
49 0 close $fh;
50 }
51 }
52  
53 4 1;
54 __END__
« lib/IRC/Indexer/Trawl/Bot.pm ↑ Summary lib/IRC/Indexer/Conf.pm »