File Coverage

blib/lib/DataCube/Report/Formatter.pm
Criterion Covered Total %
statement 6 27 22.2
branch 0 6 0.0
condition 0 3 0.0
subroutine 2 6 33.3
pod 0 4 0.0
total 8 46 17.3


line stmt bran cond sub pod time code
1              
2              
3             package DataCube::Report::Formatter;
4              
5              
6 1     1   2039 use strict;
  1         3  
  1         40  
7 1     1   6 use warnings;
  1         1  
  1         456  
8              
9              
10             sub new {
11 0     0 0   my($class,%opts) = @_;
12 0   0       bless {}, ref($class) || $class;
13             }
14              
15             sub dir {
16 0     0 0   my($self,$path) = @_;
17 0 0         opendir(my $D, $path) or die "DataCube::FileSplitter(dir):\ncant open directory:$path\n$!\n";
18 0           grep {/[^\.]/} readdir($D);
  0            
19             }
20              
21             sub sort_format {
22 0     0 0   my($self,$path) = @_;
23 0           my @lines = $self->fcon($path);
24 0           @lines[1..$#lines] = sort @lines[1..$#lines];
25             {
26 0           local $| = 1;
  0            
27 0 0         open(my $F, '>', $path)
28             or die "DataCube::Report::Formatter(sort_format):\ncant open file for writing:\n$path\n$!\n";
29 0           print $F join("\n",@lines);
30 0           close $F;
31             }
32 0           return $self;
33             }
34              
35             sub fcon {
36 0     0 0   my($self,$path) = @_;
37 0 0         open(my $F, '<' , $path)
38             or die "DataCube::Report::Formatter(fcon):\ncant open:\n$path\n$!\n";
39 0           my @lines = grep {/\S/} <$F>;
  0            
40 0           $_ =~ s/\n//g for @lines;
41 0           return @lines;
42             }
43              
44              
45              
46              
47              
48              
49             1;
50              
51              
52              
53             __DATA__