blib/lib/App/optex/Tmpfile.pm

filter: Statementstmt 42.2% 19 / 45 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 6 / 14 Podpod 0.0% 0 / 8 totaltotal 33.3% 25 / 75 CC 5 SCAR 14.4
CC
5
Cov
36%
new
12.0
write
6.0
rewind
6.0
CRAP 4.2
« lib/App/optex/Config.pm ↑ Summary blib/lib/App/optex.pm »
1 package App::optex::Tmpfile;
2  
3 # DEPRECATED: superseded by Command::Run::Tmpfile (use new(raw => 1) for
4 # byte-transparent behavior). Kept only for backward compatibility with
5 # external consumers (App::optex::git, ::msdoc, ::textconv) that still
6 # "use App::optex::Tmpfile". Remove once those have migrated to
7 # Command::Run::Tmpfile and been released.
8  
9 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Fcntl;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
17 0 my $class = shift;
18 0 ▶ my $fh = new_tmpfile IO::File or die "new_tmpfile: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
my $fh = "IO::File"->new_tmpfile or die "new_tmpfile: $!\n" 0 0 0
19 0 ▶ $fh->fcntl(F_SETFD, 0) or die "fcntl F_SETFD: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
$fh->fcntl(2, 0) or die "fcntl F_SETFD: $!\n" 0 0 0
20 0 bless { FH => $fh }, $class;
21 }
22  
23 0 ▶sub write {
Subroutine write: not called CC=2 SCAR=17.9
Pod undocumented
24 0 my $obj = shift;
25 0 my $fh = $obj->fh;
26 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
27 0 my $data = join '', @_;
28 0 $fh->print($data);
29 }
30 0 $obj;
31 }
32  
33 0 ▶sub flush {
Subroutine flush: not called CC=1 SCAR=6.9
Pod undocumented
34 0 my $obj = shift;
35 0 $obj->fh->flush;
36 0 $obj;
37 }
38  
39 0 ▶sub rewind {
Subroutine rewind: not called CC=2 SCAR=17.9
Pod undocumented
40 0 my $obj = shift;
41 0 ▶ $obj->fh->seek(0, 0) or die;
Branch: 1 branch
BranchTrueFalseTotal
$obj->fh->seek(0, 0) or die 0 0 0
42 0 $obj;
43 }
44  
45 0 ▶sub reset {
Subroutine reset: not called CC=1 SCAR=6.9
Pod undocumented
46 0 my $obj = shift;
47 0 $obj->rewind;
48 0 $obj->fh->truncate(0);
49 0 $obj;
50 }
51  
52 0 ▶sub fh {
Subroutine fh: not called CC=1 SCAR=6.9
Pod undocumented
53 0 my $obj = shift;
54 0 $obj->{FH};
55 }
56  
57 0 ▶sub fd {
Subroutine fd: not called CC=1 SCAR=6.9
Pod undocumented
58 0 my $obj = shift;
59 0 $obj->fh->fileno;
60 }
61  
62 0 ▶sub path {
Subroutine path: not called CC=1 SCAR=6.9
Pod undocumented
63 0 my $obj = shift;
64 0 sprintf "/dev/fd/%d", $obj->fd;
65 }
66  
67 1 1;
« lib/App/optex/Config.pm ↑ Summary blib/lib/App/optex.pm »