TempFile.pm

filter: Statementstmt 61.5% 32 / 52 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 69.2% 9 / 13 Podpod 100% 1 / 1 totaltotal 58.3% 42 / 72 CC 4 SCAR 13.1
CC
4
Cov
55%
_null_handle
12.0
run
5.3
__ANON__
2.0
CRAP 3.7
↑ Summary Wgnuplot.pm »
1 package Gnuplot::Builder::TempFile;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use File::Temp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use IPC::Open3 qw(open3);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Gnuplot::Builder 0.13 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Gnuplot::Builder::Process;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our $VERSION = "0.03";
13  
14 1 our @EXPORT_OK = qw(run);
15  
16 {
17 1 my $null_handle;
18  
19 0 ▶ sub _null_handle {
Subroutine _null_handle: not called CC=3 SCAR=24.8
20 0 ▶ return $null_handle if defined $null_handle;
Branch: 1 branch
BranchTrueFalseTotal
if defined $null_handle 0 0 0
21 0 my $devnull = File::Spec->devnull;
22 0 ▶ open $null_handle, ">", $devnull or confess("Cannot open $devnull: $!");
Branch: 1 branch
BranchTrueFalseTotal
open $null_handle, ">", $devnull or confess("Cannot open ${devnull}: $!") 0 0 0
23 0 return $null_handle;
24 }
25 }
26  
27 1 ▶sub run {
Subroutine run: not called CC=2 SCAR=16.6
Pod documented
28 0 my (@gnuplot_command) = @_;
29 0 local $| = 1;
30 0 ▶ if(!@gnuplot_command) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@gnuplot_command) 0 0 0
31 0 @gnuplot_command = qw(gnuplot --persist);
32 }
33 0 my $tempfile = File::Temp->new;
34 0 $tempfile->unlink_on_destroy(0);
35 0 ▶ Gnuplot::Builder::Process::MockTool::receive_from_builder *STDIN, *STDOUT, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
36 0 my ($data) = @_;
37 0 $tempfile->print($data);
38 0 };
39 0 $tempfile->close;
40 0 _execute(@gnuplot_command, $tempfile->filename);
41 0 _execute("gnuplot_builder_tempfile_remover", $tempfile->filename);
42 }
43  
44 0 ▶sub _execute {
Subroutine _execute: not called CC=1 SCAR=6.9
45 0 my (@command) = @_;
46 0 my $pid = open3(my $in, _null_handle(), undef, @command);
47 0 close $in;
48 0 return $pid;
49 }
50  
51 1 1;
52 __END__
↑ Summary Wgnuplot.pm »