| 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'
MC/DC100%1/1
delete $opts{'resource'} || 'PRG'
delete $opts{'resource'}
Truth table100%2/2
A
A= delete $opts{'resource'}
| |||||||||||||||||||||
| 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
Condition0%0/2
file($save_file)->open(">") or Carp::croak("open failed: $!")
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(">")
| |||||||||||||||||||||
| 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
Condition0%0/2
file($load_file)->open("<") or Carp::croak("open failed: $!")
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("<")
| |||||||||||||||||||||
| 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__ | ||||||||||||||||||||