Labels/Producer.pm

filter: Statementstmt 23.8% 16 / 67 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 35.7% 5 / 14 Podpod 0.0% 0 / 9 totaltotal 17.3% 21 / 121 CC 14 SCAR 24.9
CC
14
Cov
17%
generate
20.0
next_location
20.0
layout
20.0
CRAP 12.0
« Labels/base.pm ↑ Summary Labels/Layout.pm »
1  
2 package PDF::Labels::Producer;
3  
4 1 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use base qw(PDF::Labels::base);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Paper::Specs strict => 1, layout => "pdf";
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use PDF::API2;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 0 ▶sub filename {
Subroutine filename: not called CC=3 SCAR=24.8
Pod undocumented
13  
14 0 my $self=shift;
15 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
16 0 $self->{'filename'} = shift;
17 }
18  
19 0 ▶ $self->{'filename'} ||= "labels.pdf";
Condition0%0/2
$self->{"filename"} ||= "labels.pdf"
l!l
00
MC/DC0%0/1
$self->{"filename"} ||= "labels.pdf"
$self->{"filename"}
Truth table0%0/2
A
A= $self->{"filename"}
Aresult
11
00
20 0 return $self->{'filename'};
21  
22 }
23  
24 0 ▶sub generate {
Subroutine generate: not called CC=4 SCAR=30.0
Pod undocumented
25  
26 0 my $self=shift;
27  
28 0 my $pdf=PDF::API2->new;
29 0 my $page;
30  
31 0 my $layout=$self->layout;
32 0 my $form =$self->form;
33 0 $layout->prep( pdf => $pdf, size => [ $form->label_size ] );
34  
35 0 ▶ while (my $data = $self->fetch) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $data = $self->fetch) 0 0 0
36  
37 0 my ($r, $c) = $self->next_location;
38  
39 0 ▶ if ($r == 1 && $c == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r == 1 and $c == 1) 0 0 0
Condition0%0/3
$r == 1 and $c == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$r == 1 and $c == 1
$r == 1 $c == 1
Truth table0%0/3
A and B
A= $r == 1B= $c == 1
ABresult
0X0
100
111
40 0 $page = $pdf->page();
41 0 $page->mediabox( $form->sheet_size );
42 }
43  
44 0 $layout->print( data => $data, loc => [ $form->label_location( $r, $c), $form->label_size ],
45 page => $page, r => $r, c => $c );
46  
47 }
48  
49 0 $pdf->saveas( $self->filename );
50 0 $pdf->end;
51  
52 }
53  
54 0 ▶sub form {
Subroutine form: not called CC=3 SCAR=24.8
Pod undocumented
55  
56 0 my $self=shift;
57 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
58 0 ▶ if ( ref $_[0] eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'ARRAY') { } 0 0 0
59 0 $self->{'form'} = Paper::Specs->find( @{$_[0]} );
60 } else {
61 0 $self->{'form'} = Paper::Specs->find( @_ );
62 }
63 }
64 0 return $self->{'form'};
65  
66 }
67  
68 0 ▶sub skip_first {
Subroutine skip_first: not called CC=1 SCAR=6.9
Pod undocumented
69  
70 return {
71  
72 0 };
73  
74 }
75  
76 0 ▶sub skip_all {
Subroutine skip_all: not called CC=1 SCAR=6.9
Pod undocumented
77  
78 return {
79  
80 0 };
81  
82 }
83  
84  
85 0 ▶sub next_location {
Subroutine next_location: not called CC=4 SCAR=30.0
Pod undocumented
86  
87 0 my $self=shift;
88  
89 # XXX provision for skipping empty spots
90 0 $self->{'c'}++;
91  
92 0 ▶ if ($self->{'c'} > $self->form->label_cols) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"c"} > $self->form->label_cols) 0 0 0
93 0 $self->{'c'}=1;
94 0 $self->{'r'}++;
95 }
96  
97 0 ▶ if ($self->{'r'} > $self->form->label_rows) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"r"} > $self->form->label_rows) 0 0 0
98 0 $self->{'c'}=1; $self->{'r'}=1;
99 }
100  
101 0 ▶ $self->{'r'} ||=1;
Condition0%0/2
$self->{"r"} ||= 1
l!l
00
MC/DC0%0/1
$self->{"r"} ||= 1
$self->{"r"}
Truth table0%0/2
A
A= $self->{"r"}
Aresult
11
00
102  
103 0 return ($self->{'r'}, $self->{'c'} );
104  
105 }
106  
107 0 ▶sub fetch {
Subroutine fetch: not called CC=1 SCAR=6.9
Pod undocumented
108  
109 0 my $self=shift;
110 0 return shift @{$self->{'data'}};
111  
112 }
113  
114 0 ▶sub data {
Subroutine data: not called CC=1 SCAR=6.9
Pod undocumented
115  
116 0 my $self=shift;
117 0 $self->{'data'} = [ @_ ];
118  
119 }
120  
121 0 ▶sub layout {
Subroutine layout: not called CC=4 SCAR=30.0
Pod undocumented
122  
123 0 my $self=shift;
124  
125 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
126 0 $self->{'layout'} = shift;
127 }
128  
129 0 ▶ unless ($self->{'layout'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"layout"}) 0 0 0
130 0 eval "use PDF::Labels::Layout::Simple";
131 0 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
132 0 $self->{'layout'} = PDF::Labels::Layout::Simple->new;
133 }
134  
135 0 return $self->{'layout'};
136  
137 }
138  
139 1 1;
« Labels/base.pm ↑ Summary Labels/Layout.pm »