MetaCurator/HTML.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 49 CC 1 SCAR 6.9
CC
1
Cov
0%
build_html
2.0
load_template
2.0
BEGIN
2.0
CRAP 2.0
1 package CPAN::MetaCurator::HTML;
2  
3 use boolean;
4 use feature 'say';
5 use parent 'CPAN::MetaCurator::Database';
6  
7 use DateTime::Tiny;
8  
9 use File::Slurper qw/read_dir read_text/;
10 use File::Spec;
11  
12 use Mew;
13  
14 has logo_path => (Str, default => '', chained => 1);
15  
16 our $VERSION = '1.33';
17  
18 # ------------------------------------------------
19  
20 sub build_html
21 {
22 my($self, $pad) = @_;
23  
24 $self -> logger -> debug("Entered HTML.build_html()");
25  
26 my($header) = $self -> load_template('header', $pad);
27 my($body) = $self -> load_template('body', $pad);
28 my($footer) = $self -> load_template('footer', $pad);
29 my($now) = DateTime::Tiny -> now; # (time_zone => $$pad{time_zone});# DateTime::Tiny does not handle time_zone.
30 my(%data) = (domain_name => $$pad{domain_name}, logo_path => $$pad{logo_path}, module => 'CPAN::MetaCurator',
31 jstree_html_path => $$pad{jstree_html_path}, time => $now -> as_string, version => $VERSION);
32  
33 for $_ (keys %data)
34 {
35 $header =~ s/!$_!/$data{$_}/;
36 }
37  
38 # Special case. See Database.pm's build_pad().
39  
40 $header =~ s/!packages_id!/$$pad{packages_id}/;
41  
42 $self -> logger -> debug("Leaving HTML.build_html()");
43  
44 return ($header, $body, $footer);
45  
46 } # End of build_html.
47  
48 # ------------------------------------------------
49  
50 sub load_template
51 {
52 my($self, $name, $pad) = @_;
53 my($header_template) = File::Spec -> catfile($self -> home_path, "templates/$name.html");
54  
55 return read_text($header_template);
56  
57 } # End of load_template.
58  
59 # --------------------------------------------------
60  
61 1;
62  
63 =pod
64  
65 =head1 NAME
66  
67 CPAN::MetaCurator::HTML - Manage the cpan.metacurator.sqlite database
68  
69 =head1 Machine-Readable Change Log
70  
71 The file Changes was converted into Changelog.ini by L<Module::Metadata::Changes>.
72  
73 =head1 Version Numbers
74  
75 Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions.
76  
77 =head1 Support
78  
79 Email the author.
80  
81 =head1 Author
82  
83 L<CPAN::MetaCurator> was written by Ron Savage I<E<lt>ron@savage.net.auE<gt>> in 2025.
84  
85 My homepage: L<https://savage.net.au/>.
86  
87 =head1 Copyright
88  
89 Australian copyright (c) 2025, Ron Savage.
90  
91 All Programs of mine are 'OSI Certified Open Source Software';
92 you can redistribute them and/or modify them under the terms of
93 The Perl License, a copy of which is available at:
94 http://dev.perl.org/licenses/
95  
96 =cut