Embra/Plugin/Sitemap.pm

filter: Statementstmt 100% 48 / 48 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod n/a totaltotal 94.1% 64 / 68 CC 5 SCAR 4.1
CC
5
Cov
93%
__ANON__
2.0
__ANON__
2.0
gather_files
2.0
CRAP 1.5
« Embra/Plugin/Favicon.pm ↑ Summary Embra/Plugin/Cname.pm »
1 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package App::Embra::Plugin::Sitemap;
5 3 $App::Embra::Plugin::Sitemap::VERSION = '0.001'; # TRIAL
6 # ABSTRACT: adds a file which lists the pages in the site
7  
8 3 ▶use Method::Signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 ▶use App::Embra::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15  
16 3 has 'filename' => (
17 is => 'ro',
18 default => 'sitemap.html',
19 );
20  
21  
22 3 ▶has 'sitemap_file' => (
Subroutine __ANON__: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 3 3
23 3 is => 'lazy',
24 default => method { App::Embra::File->new( name => $self->filename ) },
25 );
26 2 ▶ 
Subroutine __ANON__: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 2 2
27 3 # not sure about this, might remove
28 has 'template' => (
29 is => 'lazy',
30 3 default => method { Template->new },
31 );
32  
33 # not sure about this, might remove
34 has 'sitemap_template' => (
35 3 ▶ is => 'ro',
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine gather_files: called CC=2 SCAR=7.0
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 3 3
36 3 default => '<ul>[% FOREACH page IN pages %]<li><a href="[% page.name %]">[% page.notes.title or page.name %]</a></li>[% END %]</ul>',
37 );
38  
39 3 ▶method gather_files {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine transform_files: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 2 2
40 2 $self->add_file( $self->sitemap_file );
41 2 }
42 2  
43 2 method transform_files {
44 2 my @html_files = grep { $_->ext eq 'html' } @{ $self->embra->files };
45 my $sm;
46 my $vars = { pages => \@html_files };
47 3 $self->template->process( \ $self->sitemap_template, $vars, \$sm );
48 3 $self->sitemap_file->content( $sm );
49 }
50 3  
51 with 'App::Embra::Role::FileGatherer';
52 with 'App::Embra::Role::FileTransformer';
53  
54 1;
55  
56 __END__
« Embra/Plugin/Favicon.pm ↑ Summary Embra/Plugin/Cname.pm »