lib/App/Followme/CreateSitemap.pm

filter: Statementstmt 100% 44 / 44 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 50.0% 2 / 4 totaltotal 96.6% 57 / 59 CC 3 SCAR 3.8
CC
3
Cov
100%
list_urls
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« lib/App/Followme/WebData.pm ↑ Summary lib/App/Followme/JpegData.pm »
1 package App::Followme::CreateSitemap;
2  
3 2 ▶use 5.008005;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use lib '../..';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use base qw(App::Followme::Module);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use File::Spec::Functions qw(catfile);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use App::Followme::FIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 our $VERSION = "2.03";
15  
16 #----------------------------------------------------------------------
17 # Read the default parameter values
18  
19 16 ▶sub parameters {
Subroutine parameters: called CC=1 SCAR=0.0
Pod documented
20 16 my ($pkg) = @_;
21  
22 return (
23 16 sitemap => 'sitemap.txt',
24 include_index => 1,
25 data_pkg => 'App::Followme::WebData',
26 );
27 }
28  
29 #----------------------------------------------------------------------
30 # Write a list of urls in a directory tree
31  
32 3 ▶sub run {
Subroutine run: called CC=1 SCAR=0.0
Pod undocumented
33 3 my ($self, $folder) = @_;
34  
35 3 my @urls = $self->list_urls($folder);
36 3 my $page = join("\n", @urls) . "\n";
37  
38 3 my $filename = catfile($folder, $self->{sitemap});
39 3 fio_write_page($filename, $page);
40  
41 3 return;
42 }
43  
44 #----------------------------------------------------------------------
45 # Return a list of the urls of all web pages in a directory
46  
47 7 ▶sub list_urls {
Subroutine list_urls: called CC=3 SCAR=11.0
Pod undocumented
48 7 my ($self, $folder) = @_;
49  
50 7 my @urls;
51 7 my $index_file = $self->to_file($folder);
52 7 my $files = $self->{data}->build('files_by_name', $index_file);
53  
54 7 foreach my $file (@$files) {
55 # build returns a reference, so must dereference
56 21 my $url = $self->{data}->build('remote_url', $file);
57 21 push(@urls, $$url);
58 }
59  
60 7 my $folders = $self->{data}->build('folders', $index_file);
61  
62 7 foreach my $subfolder (@$folders) {
63 3 push(@urls, $self->list_urls($subfolder));
64 }
65  
66 7 return @urls;
67 }
68  
69 #----------------------------------------------------------------------
70 # Initialize the extension
71  
72 4 ▶sub setup {
Subroutine setup: called CC=1 SCAR=0.0
Pod documented
73 4 my ($self) = @_;
74  
75 4 $self->{extension} = $self->{web_extension};
76 4 return;
77 }
78  
79 2 1;
80 __END__
« lib/App/Followme/WebData.pm ↑ Summary lib/App/Followme/JpegData.pm »