| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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__ | ||||||||||