Moose/DataFile/Gnuplot/Compressed.pm

filter: Statementstmt 93.3% 42 / 45 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 12 / 13 Podpod 100% 2 / 2 totaltotal 89.3% 59 / 66 CC 4 SCAR 4.7
CC
4
Cov
88%
_open_filehandle
3.1
_suffix
2.1
add_plot
2.0
CRAP 1.6
« Moose.pm ↑ Summary Moose/Instrument/KeysightE3633E.pm »
1 package Lab::Moose::DataFile::Gnuplot::Compressed;
2 2 $Lab::Moose::DataFile::Gnuplot::Compressed::VERSION = '3.931';
3 #ABSTRACT: Text based data file ('Gnuplot style'), auto-compressed
4  
5 2 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use File::Basename qw/dirname basename/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Lab::Moose::Catfile 'our_catfile';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Module::Load;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2 extends 'Lab::Moose::DataFile::Gnuplot';
17  
18 2 has compression => (
19 is => 'ro',
20 isa => 'Str',
21 default => 'Bzip2',
22 );
23  
24  
25 1 ▶sub _suffix {
Subroutine _suffix: called CC=2 SCAR=7.4
26 1 my %suffixtable=(
27 None => '',
28 Gzip => '.gz',
29 Bzip2 => '.bz2',
30 Lzf => '.lzf',
31 Xz => '.xz'
32 );
33  
34 1 my $module = shift;
35 1 ▶ if (defined $suffixtable{$module}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $suffixtable{$module}) { } 1 0 1
36 1 return $suffixtable{$module};
37 } else {
38 0 croak "Unsupported compression module $module";
39 };
40 }
41  
42 1 ▶sub _modify_file_path {
Subroutine _modify_file_path: called CC=1 SCAR=0.0
43 1 my $self = shift;
44 1 my $path = shift;
45 1 return $path . _suffix($self->compression());
46 }
47  
48 1 ▶sub _open_filehandle {
Subroutine _open_filehandle: called CC=3 SCAR=11.3
49 1 my $self = shift;
50 1 my $path = shift;
51  
52 1 my $fh;
53  
54 1 ▶ if ($self->compression() eq 'None') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->compression eq 'None') { } 0 1 1
55  
56 0 $fh = super();
57  
58 } else {
59  
60 1 my $modulename = "IO::Compress::" . $self->compression();
61 1 load $modulename;
62  
63 1 ▶ $fh = ("IO::Compress::".$self->compression())->new($path)
Branch: 1 branch
BranchTrueFalseTotal
$fh = ('IO::Compress::' . $self->compression)->new($path) or croak("cannot open '${path}': $!") 1 0 1
64 or croak "cannot open '$path': $!";
65  
66 }
67  
68 1 return $fh;
69 }
70  
71 0 ▶sub add_plot {
Subroutine add_plot: not called CC=1 SCAR=6.9
Pod documented
72 0 croak("Compressed data files do not (yet) support plots.");
73 }
74  
75 4 ▶sub refresh_plots {
Subroutine refresh_plots: called CC=1 SCAR=0.0
Pod documented
76 }
77  
78 2 1;
79  
80 __END__
« Moose.pm ↑ Summary Moose/Instrument/KeysightE3633E.pm »