lib/PDF/Boxer/Doc.pm

filter: Statementstmt 44.6% 21 / 47 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 25.0% 3 / 12 Podpod 0.0% 0 / 2 totaltotal 36.9% 24 / 65 CC 3 SCAR 13.7
CC
3
Cov
41%
font
12.0
_build_pdf
2.0
_build_page
2.0
CRAP 3.9
« lib/PDF/Boxer/Role/Text.pm ↑ Summary blib/lib/PDF/Boxer/Role/BoxDev.pm »
1 package PDF::Boxer::Doc;
2 {
3 3 $PDF::Boxer::Doc::VERSION = '0.004';
4 }
5 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 # ABSTRACT: Hold PDF::API2 stuff
7  
8 3 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶use PDF::API2;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 has 'file' => ( isa => 'Str', is => 'ro' );
13  
14 3 has 'pdf' => ( isa => 'Object', is => 'ro', lazy_build => 1 );
15 0 ▶sub _build_pdf{
Subroutine _build_pdf: not called CC=1 SCAR=6.9
16 0 return PDF::API2->new( -file => shift->file );
17 }
18  
19 3 has 'page' => ( isa => 'Object', is => 'rw', lazy_build => 1 );
20 0 ▶sub _build_page{
Subroutine _build_page: not called CC=1 SCAR=6.9
21 0 my ($self) = @_;
22 0 my $page = $self->pdf->page;
23 0 $page->mediabox(0,0,$self->page_width, $self->page_height);
24 #$page->cropbox($self->page_width-10, $self->page_height);
25 0 return $page;
26 }
27  
28 # default to A4
29 3 has 'page_width' => ( isa => 'Int', is => 'ro', lazy_build => 1 );
30 3 has 'page_height' => ( isa => 'Int', is => 'ro', lazy_build => 1 );
31 0 ▶sub _build_page_width{ 595 }
Subroutine _build_page_width: not called CC=1 SCAR=6.9
32 0 ▶sub _build_page_height{ 842 }
Subroutine _build_page_height: not called CC=1 SCAR=6.9
33  
34 3 has 'gfx' => ( isa => 'Object', is => 'rw', lazy_build => 1 );
35 0 ▶sub _build_gfx{ shift->page->gfx }
Subroutine _build_gfx: not called CC=1 SCAR=6.9
36  
37 3 has 'text' => ( isa => 'Object', is => 'rw', lazy_build => 1 );
38 0 ▶sub _build_text{
Subroutine _build_text: not called CC=1 SCAR=6.9
39 0 my ($self) = @_;
40 0 $self->gfx;
41 0 my $txt = $self->page->text;
42 0 $txt->compressFlate;
43 0 return $txt;
44 }
45  
46 3 has 'fonts' => ( isa => 'HashRef', is => 'ro', lazy_build => 1 );
47 0 ▶sub _build_fonts{
Subroutine _build_fonts: not called CC=1 SCAR=6.9
48 0 my ($self) = @_;
49 return {
50 0 'Helvetica' => { type => 'corefont', id => 'Helvetica', -encoding => 'latin1' },
51 'Helvetica-Bold' => { type => 'corefont', id => 'Helvetica-Bold', -encoding => 'latin1' },
52 'Helvetica-Italic' => { type => 'corefont', id => 'Helvetica-Oblique', -encoding => 'latin1' },
53 'Times' => { type => 'corefont', id => 'Times', -encoding => 'latin1' },
54 'Times-Bold' => { type => 'corefont', id => 'Times-Bold', -encoding => 'latin1' },
55 }
56 }
57  
58 0 ▶sub new_page{
Subroutine new_page: not called CC=1 SCAR=6.9
Pod undocumented
59 0 my ($self) = @_;
60 0 $self->clear_page;
61 0 $self->clear_text;
62 0 $self->clear_gfx;
63 }
64  
65 0 ▶sub font{
Subroutine font: not called CC=3 SCAR=24.8
Pod undocumented
66 0 my ($self, $name) = @_;
67 0 my $font = $self->fonts->{$name};
68 0 ▶ die "cannot find font '$name' in fonts list" unless $font;
Branch: 1 branch
BranchTrueFalseTotal
unless $font 0 0 0
69 0 ▶ return $font unless ref($font) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $font eq "HASH" 0 0 0
70 0 my $font_type = delete $font->{type};
71 0 my $font_id = delete $font->{id};
72 0 return $self->fonts->{$name} = $self->pdf->$font_type($font_id, %$font);
73 }
74  
75 3 __PACKAGE__->meta->make_immutable;
76  
77 3 1;
78  
79 __END__
« lib/PDF/Boxer/Role/Text.pm ↑ Summary blib/lib/PDF/Boxer/Role/BoxDev.pm »