blib/lib/App/adler32.pm

filter: Statementstmt 60.4% 29 / 48 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 9 / 12 Podpod 100% 3 / 3 totaltotal 59.4% 41 / 69 CC 4 SCAR 13.7
CC
4
Cov
54%
validate_args
12.0
execute
6.0
opt_spec
2.0
CRAP 3.9
↑ Summary
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package App::adler32;
5 # ABSTRACT: Comand-line utility for computing Adler32 digest
6 1 our $VERSION = '0.001'; # VERSION
7 1 ▶use base 'App::Cmd::Simple';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use charnames qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use open qw( :encoding(UTF-8) :std );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Module::Load qw(load);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Getopt::Long::Descriptive;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Digest::Adler32 qw(adler32);
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 =pod
18  
19 =encoding utf8
20  
21 =head1 NAME
22  
23 adler32 - Command-line utility for computing Adler32 digest
24  
25 =head1 VERSION
26  
27 version 0.001
28  
29 =head1 SYNOPSIS
30  
31 $ echo Hey | adler32
32 31014f03
33  
34 =head1 OPTIONS
35  
36 =head2 version / v
37  
38 Shows the current version number
39  
40 $ adler32 --version
41  
42 =head2 help / h
43  
44 Shows a brief help message
45  
46 $ adler32 --help
47  
48 =cut
49  
50 0 ▶sub opt_spec {
Subroutine opt_spec: not called CC=1 SCAR=6.9
Pod documented
51 return (
52 0 [ 'version|v' => "show version number" ],
53 [ 'help|h' => "display a usage message" ],
54 );
55 }
56  
57 0 ▶sub validate_args {
Subroutine validate_args: not called CC=3 SCAR=24.8
Pod documented
58 0 my ($self, $opt, $args) = @_;
59  
60 0 ▶ if ($opt->{'help'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($opt->{'help'}) { } 0 0 0
elsif ($opt->{'version'}) { } 0 0 0
61 0 my ($opt, $usage) = describe_options(
62 $self->usage_desc(),
63 $self->opt_spec(),
64 );
65 0 print $usage;
66 0 print "\n";
67 0 print "For more detailed help see 'perldoc App::adler32'\n";
68  
69 0 print "\n";
70 0 exit;
71 }
72 elsif ($opt->{'version'}) {
73 0 print $App::adler32::VERSION, "\n";
74 0 exit;
75 }
76  
77 0 return;
78 }
79  
80 0 ▶sub execute {
Subroutine execute: not called CC=2 SCAR=17.9
Pod documented
81 0 my ($self, $opt, $args) = @_;
82  
83 0 ▶ while (<>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline ARGV)) 0 0 0
84 0 my $a32 = Digest::Adler32->new;
85 0 $a32->add($_);
86 0 my $digest = unpack 'H*', pack 'N', unpack 'L', $a32->digest;
87 0 print $digest, "\n";
88 }
89  
90 0 return;
91 }
92  
93 1 1;
94  
95 __END__
↑ Summary