| 1 | package File::Dir::Dumper::App; | ||||||||||
| 2 | 2 | $File::Dir::Dumper::App::VERSION = '0.6.4'; | |||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use 5.012; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 2 | ▶ | use parent 'File::Dir::Dumper::Base'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 2 | ▶ | use Getopt::Long qw(GetOptionsFromArray); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 2 | ▶ | use Pod::Usage qw( pod2usage ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 2 | ▶ | use File::Dir::Dumper::Scanner (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 2 | ▶ | use File::Dir::Dumper::Stream::JSON::Writer (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 2 | use Class::XSAccessor accessors => { | |||||||||
| 17 | _digest_cache => '_digest_cache', | ||||||||||
| 18 | _digest_cache_params => '_digest_cache_params', | ||||||||||
| 19 | _digests => '_digests', | ||||||||||
| 20 | _out_to_stdout => '_out_to_stdout', | ||||||||||
| 21 | _out_filename => '_out_filename', | ||||||||||
| 22 | _dir_to_dump => '_dir_to_dump', | ||||||||||
| 23 | 2 | ▶ | }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | sub _init | ||||||||||
| 27 | { | ||||||||||
| 28 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_init: called CC=5 SCAR=16.4
| |||||||||||
| 29 | 1 | my $args = shift; | |||||||||
| 30 | |||||||||||
| 31 | 1 | my $argv = $args->{'argv'}; | |||||||||
| 32 | |||||||||||
| 33 | 1 | my $output_dest; | |||||||||
| 34 | my @digests; | ||||||||||
| 35 | 1 | my ( $help, $man ); | |||||||||
| 36 | 1 | my $digest_cache = 'Dummy'; | |||||||||
| 37 | 1 | my %cache_params; | |||||||||
| 38 | |||||||||||
| 39 | 1 | ▶ | GetOptionsFromArray( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | $argv, | ||||||||||
| 41 | 'digest-cache=s' => \$digest_cache, | ||||||||||
| 42 | 'digest-cache-param=s' => \%cache_params, | ||||||||||
| 43 | "digest=s" => \@digests, | ||||||||||
| 44 | "output|o=s" => \$output_dest, | ||||||||||
| 45 | 'help|h' => \$help, | ||||||||||
| 46 | 'man' => \$man, | ||||||||||
| 47 | ) or die "parsing options failed - $!"; | ||||||||||
| 48 | |||||||||||
| 49 | 1 | ▶ | pod2usage(1) if $help; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 1 | ▶ | pod2usage( -exitstatus => 0, -verbose => 2 ) if $man; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | |||||||||||
| 52 | 1 | my $dir_to_dump = shift(@$argv); | |||||||||
| 53 | |||||||||||
| 54 | 1 | ▶ | if ( defined($output_dest) ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | { | ||||||||||
| 56 | 1 | $self->_out_to_stdout(0); | |||||||||
| 57 | 1 | $self->_out_filename($output_dest); | |||||||||
| 58 | } | ||||||||||
| 59 | else | ||||||||||
| 60 | { | ||||||||||
| 61 | 0 | $self->_out_to_stdout(1); | |||||||||
| 62 | } | ||||||||||
| 63 | 1 | $self->_digests( \@digests ); | |||||||||
| 64 | 1 | $self->_dir_to_dump($dir_to_dump); | |||||||||
| 65 | 1 | $self->_digest_cache($digest_cache); | |||||||||
| 66 | 1 | $self->_digest_cache_params( \%cache_params ); | |||||||||
| 67 | |||||||||||
| 68 | 1 | return; | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | sub run | ||||||||||
| 72 | { | ||||||||||
| 73 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
run: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||
| 74 | |||||||||||
| 75 | 1 | my $out; | |||||||||
| 76 | 1 | ▶ | if ( $self->_out_to_stdout() ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 77 | { | ||||||||||
| 78 | 0 | open $out, ">&STDOUT"; | |||||||||
| 79 | } | ||||||||||
| 80 | else | ||||||||||
| 81 | { | ||||||||||
| 82 | 1 | open $out, ">", $self->_out_filename(); | |||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | 1 | my $digests = $self->_digests; | |||||||||
| 86 | |||||||||||
| 87 | 1 | ▶ | my $scanner = File::Dir::Dumper::Scanner->new( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 88 | { | ||||||||||
| 89 | dir => $self->_dir_to_dump(), | ||||||||||
| 90 | ( ( @$digests ? ( digests => $digests ) : () ), ), | ||||||||||
| 91 | digest_cache => $self->_digest_cache, | ||||||||||
| 92 | digest_cache_params => $self->_digest_cache_params, | ||||||||||
| 93 | } | ||||||||||
| 94 | ); | ||||||||||
| 95 | 1 | my $writer = File::Dir::Dumper::Stream::JSON::Writer->new( | |||||||||
| 96 | { | ||||||||||
| 97 | output => $out, | ||||||||||
| 98 | } | ||||||||||
| 99 | ); | ||||||||||
| 100 | |||||||||||
| 101 | 1 | ▶ | while ( defined( my $token = $scanner->fetch() ) ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 102 | { | ||||||||||
| 103 | 11 | $writer->put($token); | |||||||||
| 104 | } | ||||||||||
| 105 | |||||||||||
| 106 | 1 | $writer->close(); | |||||||||
| 107 | |||||||||||
| 108 | 1 | return 0; | |||||||||
| 109 | } | ||||||||||
| 110 | |||||||||||
| 111 | |||||||||||
| 112 | 2 | 1; # End of File::Dir::Dumper | |||||||||
| 113 | |||||||||||
| 114 | __END__ | ||||||||||