Petitcom.pm

filter: Statementstmt 81.6% 58 / 71 Branchbran 0.0% 0 / 4 Conditioncond 33.3% 2 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 85.7% 12 / 14 Podpod 100% 5 / 5 totaltotal 75.7% 78 / 103 CC 6 SCAR 15.2
CC
6
Cov
74%
SaveFile
12.0
LoadFile
12.0
Save
2.0
CRAP 4.6
« Petitcom/BMP.pm ↑ Summary Petitcom/QRCode.pm »
1 package Data::Petitcom;
2  
3 2 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 our $VERSION = '0.03';
7  
8 2 ▶use parent qw{ Exporter };
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 our @EXPORT = qw{ Save Load QRCode };
10 2 our @EXPORT_OK = qw{ SaveFile LoadFile };
11 2 our %EXPORT_TAGS = ( all => [qw{ Save Load QRCode SaveFile LoadFile }] );
12  
13 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Data::Petitcom::PTC;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use Data::Petitcom::QRCode;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use Data::Petitcom::Resource;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶use Path::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 4 ▶sub Save {
Subroutine Save: called CC=2 SCAR=6.9
Pod documented
20 4 my $raw_data = shift;
21 4 my %opts = @_;
22 4 ▶ my $resource = delete $opts{resource} || 'PRG';
Condition100%2/2
delete $opts{'resource'} || 'PRG'
l!l
22
MC/DC100%1/1
delete $opts{'resource'} || 'PRG'
delete $opts{'resource'}
Truth table100%2/2
A
A= delete $opts{'resource'}
Aresult
11
00
23 4 my $obj_resource = get_resource( resource => $resource, %opts );
24 4 $obj_resource->data($raw_data);
25 4 my $obj_ptc = $obj_resource->save(%opts);
26 4 return $obj_ptc->dump;
27 }
28  
29 3 ▶sub Load {
Subroutine Load: called CC=1 SCAR=0.0
Pod documented
30 3 my $raw_ptc = shift;
31 3 my %opts = @_;
32 3 my $obj_ptc = Data::Petitcom::PTC->new->load($raw_ptc);
33 3 my $obj_resource = $obj_ptc->restore(%opts);
34 3 return $obj_resource->data;
35 }
36  
37 3 ▶sub QRCode {
Subroutine QRCode: called CC=1 SCAR=0.0
Pod documented
38 3 my $ptc = shift;
39 3 my %opts = @_;
40 3 my $qr_type = delete $opts{type};
41 3 my $qr_ecc = delete $opts{ecc};
42 3 my $qr_version = delete $opts{version};
43  
44 3 my $raw_ptc = undef;
45 3 given ($ptc) {
46 3 when ( ref $ptc eq 'Data::Petitcom::PTC' ) {
47 1 $raw_ptc = $ptc->dump;
48 }
49 2 when ( ! Data::Petitcom::PTC->is_ptc($ptc) ) {
50 1 $raw_ptc = Save($ptc, %opts);
51 }
52 1 default { $raw_ptc = $ptc }
53 }
54  
55 3 my $qr = Data::Petitcom::QRCode->new(
56 type => $qr_type,
57 ecc => $qr_ecc,
58 version => $qr_version
59 );
60 3 return $qr->plot($raw_ptc);
61 }
62  
63 0 ▶sub SaveFile {
Subroutine SaveFile: not called CC=3 SCAR=24.8
Pod documented
64 0 my $save_file = shift;
65 0 my $raw_data = shift;
66 0 ▶ my $save_fh
Branch: 1 branch
BranchTrueFalseTotal
ref $save_file eq 'GLOB' ? : 0 0 0
Condition0%0/2
file($save_file)->open(">") or Carp::croak("open failed: $!")
l!l
00
MC/DC0%0/1
file($save_file)->open(">") or Carp::croak("open failed: $!")
file($save_file)->open(">")
Truth table0%0/2
A
A= file($save_file)->open(">")
Aresult
11
00
67 = ( ref $save_file eq 'GLOB' )
68 ? $save_file
69 : file($save_file)->open('>') || Carp::croak "open failed: $!";
70 0 my $raw_ptc = Save($raw_data, @_);
71 0 binmode $save_fh;
72 0 print $save_fh $raw_ptc;
73 }
74  
75 0 ▶sub LoadFile {
Subroutine LoadFile: not called CC=3 SCAR=24.8
Pod documented
76 0 my $load_file = shift;
77 0 ▶ my $load_fh
Branch: 1 branch
BranchTrueFalseTotal
ref $load_file eq 'GLOB' ? : 0 0 0
Condition0%0/2
file($load_file)->open("<") or Carp::croak("open failed: $!")
l!l
00
MC/DC0%0/1
file($load_file)->open("<") or Carp::croak("open failed: $!")
file($load_file)->open("<")
Truth table0%0/2
A
A= file($load_file)->open("<")
Aresult
11
00
78 = ( ref $load_file eq 'GLOB' )
79 ? $load_file
80 : file($load_file)->open('<') || Carp::croak "open failed: $!";
81 0 binmode $load_fh;
82 0 my $raw_data = Load( do { local $/; <$load_fh> }, @_ );
83 0 return $raw_data;
84 }
85  
86 2 1;
87 __END__
« Petitcom/BMP.pm ↑ Summary Petitcom/QRCode.pm »