File Coverage

blib/lib/App/datasection/Command/extract.pm
Criterion Covered Total %
statement 39 40 97.5
branch 3 6 50.0
condition n/a
subroutine 9 9 100.0
pod 1 1 100.0
total 52 56 92.8


line stmt bran cond sub pod time code
1 1     1   996 use warnings;
  1         2  
  1         64  
2 1     1   17 use 5.020;
  1         3  
3 1     1   5 use experimental qw( signatures );
  1         2  
  1         8  
4 1     1   196 use stable qw( postderef );
  1         2  
  1         8  
5 1     1   79 use true;
  1         3  
  1         8  
6              
7             package App::datasection::Command::extract 0.01 {
8              
9             # ABSTRACT: Extract files from Perl source __DATA__ section
10             # VERSION
11              
12 1     1   2388 use App::datasection -command;
  1         2  
  1         30  
13 1     1   969 use Data::Section::Pluggable 0.08;
  1         7066  
  1         69  
14 1     1   18 use Path::Tiny qw( path );
  1         3  
  1         368  
15              
16 1     1 1 8 sub execute ($self, $opt, $args) {
  1         3  
  1         2  
  1         2  
  1         2  
17              
18 1         4 my @files = map { path($_) } @$args;
  1         7  
19              
20 1         64 my $dir;
21 1 50       8 if($opt->{dir}) {
22 0         0 $dir = path($opt->{dir})->absolute;
23             }
24              
25 1         4 foreach my $file (@files) {
26 1 50       8 my $dir = $dir ? $dir : $file->sibling($file->basename . '.data');
27              
28 1         174 my $dsp = Data::Section::Pluggable
29             ->new( filename => $file );
30              
31 1 50       421 if($dsp->get_data_section->%*) {
32 1         594 $dir->mkdir;
33 1         363 $dsp->extract($dir);
34 1         2402 say $file;
35             }
36             }
37              
38             }
39              
40             }
41              
42             __END__