Automaton/Plugin/Source/File.pm

filter: Statementstmt 87.5% 28 / 32 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 84.7% 39 / 46 CC 5 SCAR 9.8
CC
5
Cov
82%
go
4.2
_logger
2.0
BEGIN
1.0
CRAP 2.7
« Automaton/Plugin/Filter/Unshorten.pm ↑ Summary
1 package App::Automaton::Plugin::Source::File;
2  
3 # ABSTRACT: File input module
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶sub go {
Subroutine go: called CC=4 SCAR=14.5
Pod documented
10 2 my $self = shift;
11 2 my $in = shift;
12
13 2 my $d = $in->{debug};
14  
15 2 my $file = $in->{path};
16 2 _logger($d, "Processing file: $file");
17 2 ▶ open(my $fh, "<", $in->{path}) || return 1;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $in->{"path"} or return 1 2 0 2
18 2 my @lines = <$fh>;
19 2 close($fh);
20
21 2 ▶ if ($in->{empty}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in->{"empty"}) 0 2 2
22 0 _logger($d, "emptying the file: $file");
23 0 open(my $fh, '>', $in->{path});
24 0 print $fh '';
25 0 close($fh);
26 }
27
28 2 ▶ if ($in->{delete}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in->{"delete"}) 1 1 2
29 1 _logger($d, "deleting file: $file");
30 1 unlink $file;
31 }
32
33 2 chomp(@lines);
34  
35 2 return(@lines);
36 }
37  
38 3 ▶sub _logger {
Subroutine _logger: called CC=2 SCAR=7.0
39 3 my $level = shift;
40 3 my $message = shift;
41 3 ▶ print "$message\n" if $level;
Branch: 1 branch
BranchTrueFalseTotal
if $level 0 3 3
42 3 return 1;
43 }
44  
45 1 1;
46  
47 __END__
« Automaton/Plugin/Filter/Unshorten.pm ↑ Summary