Website/Command/Build.pm

filter: Statementstmt 48.8% 21 / 43 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 60.0% 6 / 10 Podpod 25.0% 1 / 4 totaltotal 38.3% 28 / 73 CC 7 SCAR 21.2
CC
7
Cov
38%
execute_template
20.4
validate
6.0
execute
6.0
CRAP 8.4
« Website/Command.pm ↑ Summary Website/Command/Init.pm »
1 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package App::PM::Website::Command::Build;
5 {
6 2 $App::PM::Website::Command::Build::VERSION = '0.131611';
7 }
8 2 ▶use base 'App::PM::Website::Command';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 #ABSTRACT: render the website to local disk from the configuration files.
14  
15 sub options
16 0 ▶{
Subroutine options: not called CC=1 SCAR=6.9
Pod undocumented
17 0 my ($class, $app) = @_;
18  
19 return (
20 0 [ 'template-dir=s' => 'template dir path',
21 { default => "template" } ],
22 [ 'build-dir=s' => 'build dir path',
23 { default => "./website" } ],
24 [ 'date=s' => 'which month to build',
25 { default => scalar $class->today() } ],
26 );
27 }
28  
29 sub validate
30 0 ▶{
Subroutine validate: not called CC=2 SCAR=17.9
Pod undocumented
31 0 my ($self, $opt, $args ) = @_;
32 0 $self->validate_or_create_dir($opt,'build_dir');
33 0 $self->validate_required_dir($opt, 'template_dir');
34  
35 0 ▶ die $self->usage_error( "no arguments allowed") if @$args;
Branch: 1 branch
BranchTrueFalseTotal
if @$args 0 0 0
36  
37 0 return 1;
38 }
39  
40 sub execute
41 0 ▶{
Subroutine execute: not called CC=2 SCAR=17.9
Pod documented
42 0 my( $self, $opt, $args ) = @_;
43  
44 0 my ($meeting, @past_meetings) = $self->meetings();
45 my $loc = $meeting->{location} ||
46 0 ▶ $self->{config}{config}{location}{default};
Condition0%0/3
$meeting->{'location'} || $self->{'config'}{'config'}{'location'}{'default'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$meeting->{'location'} || $self->{'config'}{'config'}{'location'}{'default'}
$meeting->{'location'} $self->{'config'}{'config'}{'location'}{'default'}
Truth table0%0/3
A || B
A= $meeting->{'location'}B= $self->{'config'}{'config'}{'location'}{'default'}
ABresult
1X1
011
000
47 my $tt_vars = {
48 m => $meeting,
49 meetings => \@past_meetings,
50 presenter => $self->{config}->get_presenter,
51 locations => $self->{config}->get_location,
52 0 l => $self->{config}->get_location->{$loc},
53 };
54 0 my $execute_options = {
55 template_file => "$opt->{template_dir}/index.tt",
56 output_file => "$opt->{build_dir}/index.html",
57 tt_vars => $tt_vars,
58 };
59 0 $self->execute_template( $opt, $execute_options );
60 }
61  
62 sub execute_template
63 0 ▶{
Subroutine execute_template: not called CC=5 SCAR=30.1
Pod undocumented
64 0 my ($self, $opt, $tt_options) = @_;
65  
66 0 my $template_options = {
67 INCLUDE_PATH => './',
68 INTERPOLATE => 1,
69 };
70 0 ▶ my $tt = Template->new( {} )
Condition0%0/2
'Template'->new({}) || die("$Template::ERROR\n")
l!l
00
MC/DC0%0/1
'Template'->new({}) || die("$Template::ERROR\n")
'Template'->new({})
Truth table0%0/2
A
A= 'Template'->new({})
Aresult
11
00
71 || die "$Template::ERROR\n";
72  
73 my @opts = (
74 0 @$tt_options{ qw( template_file tt_vars output_file ) },
75 ( binmode => ':utf8' )
76 );
77  
78 2 ▶ use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
79 print Dumper { tt_process => \@opts }
80 0 ▶ if $opt->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $opt->{"verbose"} 0 0 0
81  
82 0 my $success = 1;
83 0 ▶ unless ($opt->{dry_run} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($opt->{"dry_run"}) 0 0 0
84 {
85 0 ▶ $success = $tt->process( @opts )
Branch: 1 branch
BranchTrueFalseTotal
$success = $tt->process(@opts) or die $tt->error, "\n" 0 0 0
86 or die $tt->error(), "\n";
87 }
88  
89 0 return $success;
90 }
91  
92  
93 2 1;
94  
95 __END__
« Website/Command.pm ↑ Summary Website/Command/Init.pm »