Khonsu.pm

filter: Statementstmt 94.7% 18 / 19 Branchbran n/a Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 2 totaltotal 75.7% 25 / 33 CC 3 SCAR 6.7
CC
3
Cov
87%
new
3.2
open
2.0
BEGIN
1.0
CRAP 2.0
« Khonsu/Ra.pm ↑ Summary Khonsu/Shape/Box.pm »
1 package Khonsu;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 our $VERSION = '0.05';
5 3 ▶use PDF::API2;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Khonsu::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 sub new {
10 2 ▶ my ($pkg, $name, %args) = @_;
Subroutine new: called CC=3 SCAR=11.7
Pod undocumented
11 my $file = Khonsu::File->new(
12 file_name => $name,
13 pages => [],
14 page_size => $args{page_size} || 'A4',
15 page_args => $args{page_args} || {},
16 pdf => PDF::API2->new( -file => sprintf("%s.pdf", $name) ),
17 configure => $args{configure}
18 2 ▶ );
Condition50%2/4
$args{'page_size'} || 'A4'
l!l
20
$args{'page_args'} || {}
l!l
20
MC/DC0%0/1
$args{'page_size'} || 'A4'
$args{'page_size'}
MC/DC0%0/1
$args{'page_args'} || {}
$args{'page_args'}
Truth table50%1/2
A
A= $args{'page_size'}
Aresult
11
00
Truth table50%1/2
A
A= $args{'page_args'}
Aresult
11
00
19 2 return $file;
20 }
21  
22 0 ▶sub open { ... }
Subroutine open: not called CC=1 SCAR=6.9
Pod undocumented
23  
24 3 1;
25  
26 =head1 NAME
27  
28 Khonsu - PDF Generation!
29  
30 =head1 VERSION
31  
32 Version 0.04
33  
34 =cut
35  
36 =head1 SYNOPSIS
37  
38 Quick summary of what the module does.
39  
40 Perhaps a little code snippet.
41  
42 my @words = ('Aker', 'Anubis', 'Hapi', 'Khepri', 'Maahes', 'Thoth', 'Bastet', 'Hatmehit', 'Tefnut', 'Menhit', 'Imentet');
43  
44 my $generate_text = sub {
45 my $length = shift;
46 return join " ", map { $words[int(rand(scalar @words))] } 1 .. $length;
47 };
48  
49 use Khonsu;
50  
51 my $padding = 20;
52 my $page_padding = $padding * 2;
53 my $khonsu = Khonsu->new(
54 'Ra',
55 page_size => 'A4',
56 page_args => {
57 background => '#3ff'
58 },
59 configure => {
60 page_header => {
61 padding => $padding,
62 show_page_num => 'right',
63 page_num_text => 'page {num}',
64 h => $padding,
65 cb => sub {
66 my ($self, $file, %atts) = @_;
67 $self->add(
68 $file,
69 text => 'Ra',
70 align => 'center',
71 %attrs,
72 );
73 }
74 },
75 page_footer => {
76 padding => $padding,
77 show_page_num => 'left',
78 page_num_text => 'page {num}',
79 h => $padding,
80 cb => sub {
81 my ($self, $file, %atts) = @_;
82 $self->add(
83 $file,
84 text => 'Ra',
85 align => 'center',
86 %attrs,
87 );
88 }
89 },
90 toc => {
91 title => 'Table of contents',
92 title_font_args => {
93 size => 50,
94 },
95 title_padding => 10,
96 font_args => {
97 size => 20,
98 },
99 padding => 5,
100 },
101 h1 => {
102 font => { colour => '#0EE' }
103 }
104 }
105 );
106  
107 $khonsu->add_image(
108 image => 't/test.png',
109 x => $padding,
110 y => $padding,
111 w => $khonsu->page->w - $page_padding,
112 h => $khonsu->page->h - $page_padding,
113 )->add_page;
114  
115 $khonsu->add_toc(
116 x => $padding,
117 y => $padding,
118 w => $khonsu->page->w - $page_padding,
119 h => $khonsu->page->h - $page_padding
120 );
121  
122 $khonsu->add_h1(
123 text => $generate_text->(3),
124 x => $padding,
125 y => $padding,
126 w => $khonsu->page->w - $page_padding,
127 toc => 1,
128 )->add_text(
129 text => $generate_text->(2000),
130 x => $padding,
131 y => ($page_padding) + $khonsu->h1->line_height,
132 w => $khonsu->page->w - $page_padding,
133 h => $khonsu->page->h - ($khonsu->h1->line_height + $page_padding + $padding),
134 indent => 4,
135 font => {
136 colour => '#fff'
137 },
138 overflow => 1,
139 );
140
141 $khonsu->save();
142  
143 =head1 AUTHOR
144  
145 LNATION, C<< <email at lnation.org> >>
146  
147 =head1 BUGS
148  
149 Please report any bugs or feature requests to C<bug-khonsu at rt.cpan.org>, or through
150 the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Khonsu>. I will be notified, and then you'll
151 automatically be notified of progress on your bug as I make changes.
152  
153 =head1 SUPPORT
154  
155 You can find documentation for this module with the perldoc command.
156  
157 perldoc Khonsu
158  
159 You can also look for information at:
160  
161 =over 4
162  
163 =item * RT: CPAN's request tracker (report bugs here)
164  
165 L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Khonsu>
166  
167 =item * CPAN Ratings
168  
169 L<https://cpanratings.perl.org/d/Khonsu>
170  
171 =item * Search CPAN
172  
173 L<https://metacpan.org/release/Khonsu>
174  
175 =back
176  
177  
178 =head1 ACKNOWLEDGEMENTS
179  
180  
181 =head1 LICENSE AND COPYRIGHT
182  
183 This software is Copyright (c) 2023 by LNATION.
184  
185 This is free software, licensed under:
186  
187 The Artistic License 2.0 (GPL Compatible)
188  
189  
190 =cut
191  
192 3 1; # End of Khonsu
« Khonsu/Ra.pm ↑ Summary Khonsu/Shape/Box.pm »