lib/Grimlock/Web/View/HTML.pm

filter: Statementstmt 66.6% 36 / 54 Branchbran 18.7% 3 / 16 Conditioncond 27.2% 3 / 11 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 90.0% 9 / 10 Podpod 75.0% 3 / 4 totaltotal 54.4% 55 / 101 CC 16 SCAR 34.5
CC
16
Cov
52%
__ANON__
72.0
new
32.7
serialize
3.0
CRAP 31.6
↑ Summary lib/Grimlock/Web/Controller/Draft.pm »
1 package Grimlock::Web::View::HTML;
2 {
3 4 $Grimlock::Web::View::HTML::VERSION = '0.11';
4 }
5  
6 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use base 'Catalyst::View::TT';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Grimlock::Web;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use File::ShareDir 'dist_dir';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 __PACKAGE__->config({
12 PRE_PROCESS => 'shared/base.tt',
13 WRAPPER => 'wrapper.tt',
14 TEMPLATE_EXTENSION => '.tt',
15 INCLUDE_PATH => [
16 dist_dir('Grimlock'),
17 Grimlock::Web->path_to('root','site')
18 ],
19 TIMER => 0,
20 static_root => '/static',
21 static_build => 0,
22 render_die => 1
23 });
24  
25 22 ▶sub template_vars {
Subroutine template_vars: called CC=1 SCAR=0.0
Pod documented
26 22 my $self = shift;
27 return (
28 $self->next::method(@_),
29 static_root => $self->{static_root},
30 static_build => $self->{static_build}
31 22 );
32 }
33  
34 3 ▶sub new {
Subroutine new: called CC=6 SCAR=34.9
Pod documented
35 3 my ( $class, $c, $arguments ) = @_;
36 3 my $formats = $class->config->{formats};
37  
38 3 ▶ return $class->next::method( $c, $arguments ) unless ref $formats eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $formats eq "HASH" 3 0 3
39  
40 0 ▶ $class->config->{FILTERS} ||= {};
Condition0%0/2
$class->config->{"FILTERS"} ||= {}
l!l
00
MC/DC0%0/1
$class->config->{"FILTERS"} ||= {}
$class->config->{"FILTERS"}
Truth table0%0/2
A
A= $class->config->{"FILTERS"}
Aresult
11
00
41  
42 0 my $filters = $class->config->{FILTERS};
43  
44 0 foreach my $key ( keys %$formats ) {
45 0 ▶ if ( $key eq 'date' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "date") 0 0 0
46 0 foreach my $date_key ( keys %{$formats->{$key}} ) {
47 0 ▶ $filters->{"${key}_$date_key"} = sub {
Subroutine __ANON__: not called CC=8 SCAR=42.8
48 0 my $date = shift;
49 0 ▶ return unless defined $date;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $date 0 0 0
50 0 ▶ unless ( blessed $date and $date->can("stringify") ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($date->blessed and $date->can("stringify")) 0 0 0
Condition0%0/3
$date->blessed and $date->can("stringify")
!ll&&!rl&&r
000
MC/DC0%0/2
$date->blessed and $date->can("stringify")
$date->blessed $date->can("stringify")
Truth table0%0/3
A and B
A= $date->blessedB= $date->can("stringify")
ABresult
0X0
100
111
51 0 $date = DateTime::Format::DateParse->parse_datetime($date);
52 }
53 0 ▶ unless ( $date ) { return $date; }
Branch: 1 branch
BranchTrueFalseTotal
unless ($date) 0 0 0
54 $date->set_locale($class->config->{default_locale})
55 0 ▶ if defined $class->config->{default_locale};
Branch: 1 branch
BranchTrueFalseTotal
if defined $class->config->{"default_locale"} 0 0 0
56 # Only apply a timezone if we have a complete date.
57 0 ▶ unless ( "$date" =~ /T00:00:00$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("$date" =~ /T00:00:00$/) 0 0 0
58 0 ▶ $date->set_time_zone( $class->config->{default_tz} || 'America/Los_Angeles' );
Condition0%0/2
$class->config->{'default_tz'} || 'America/Los_Angeles'
l!l
00
MC/DC0%0/1
$class->config->{'default_tz'} || 'America/Los_Angeles'
$class->config->{'default_tz'}
Truth table0%0/2
A
A= $class->config->{'default_tz'}
Aresult
11
00
59 }
60 0 $date->strftime($formats->{$key}->{$date_key});
61 0 };
62 }
63 }
64 }
65  
66 0 return $class->next::method( $c, $arguments );
67 }
68  
69 22 ▶sub process {
Subroutine process: called CC=2 SCAR=6.9
Pod documented
70 22 my ( $self, $c, $stash_key ) = @_;
71 22 my $output;
72 22 eval {
73 22 $output = $self->serialize( $c, $c->stash->{$stash_key} );
74 };
75 22 ▶ return $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 3 19 22
76
77 19 $c->response->body( $output );
78 19 return 1; # important
79 }
80  
81 22 ▶sub serialize {
Subroutine serialize: called CC=3 SCAR=11.0
Pod undocumented
82 22 my ( $self, $c, $data ) = @_;
83 22 ▶ my $template = $c->stash->{'template'} || $c->action . ".tt";
Condition100%2/2
$c->stash->{'template'} || $c->action . '.tt'
l!l
616
MC/DC100%1/1
$c->stash->{'template'} || $c->action . '.tt'
$c->stash->{'template'}
Truth table100%2/2
A
A= $c->stash->{'template'}
Aresult
11
00
84 22 my $view = $c->view('HTML');
85 22 ▶ my $serialized = $view->render($c, $template, $data) || die $view->tt_error;
Condition50%1/2
$view->render($c, $template, $data) || die($view->tt_error)
l!l
190
MC/DC0%0/1
$view->render($c, $template, $data) || die($view->tt_error)
$view->render($c, $template, $data)
Truth table50%1/2
A
A= $view->render($c, $template, $data)
Aresult
11
00
86
87 19 return $serialized;
88 }
89  
90  
91 =head1 NAME
92  
93 Grimlock::Web::View::HTML - Catalyst TT::Bootstrap::YUI View
94  
95 =head1 SYNOPSIS
96  
97 See L<Grimlock::Web>
98  
99 =head1 DESCRIPTION
100  
101 Catalyst TT::Bootstrap View.
102  
103 =head1 AUTHOR
104  
105 Devin Austin
106  
107 =head1 LICENSE
108  
109 This library is free software, you can redistribute it and/or modify
110 it under the same terms as Perl itself.
111  
112 =cut
113  
114 4 1;
↑ Summary lib/Grimlock/Web/Controller/Draft.pm »