| 1 | package Rapi::Blog::Scaffold::ViewWrapper; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use RapidApp::Util qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Rapi::Blog::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Types::Standard ':all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 2 | has 'Scaffold', is => 'ro', required => 1, isa => InstanceOf['Rapi::Blog::Scaffold']; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 2 | has 'path', is => 'ro', required => 1, isa => Str; | |||||||||||||||||||||||||||
| 14 | 2 | has 'type', is => 'ro', required => 1, isa => Enum[qw/include insert/]; | |||||||||||||||||||||||||||
| 15 | 2 | has 'wrapper', is => 'ro', required => 1, isa => Str; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 0 | ▶ | has 'not_found_template', is => 'ro', isa => Maybe[Str], default => sub {undef}; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | my $path = $self->path or die "ViewWrapper: path is required"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my $wrapper = $self->wrapper or die "ViewWrapper: wrapper is required"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | die "ViewWrapper: bad path '$path' - must start with a normal alpha character" unless ($path =~ /^\w/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | die "ViewWrapper: bad path '$path' - must end with a trailing slash (/)" unless ($path =~ /\/$/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub _enforce_wrapper_exists { | ||||||||||||||||||||||||||
|
Subroutine
_enforce_wrapper_exists: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 31 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 32 | 0 | my $wrapper = $self->wrapper; | |||||||||||||||||||||||||||
| 33 | 0 | ▶ | $self->Scaffold->resolve_file($wrapper) or die join('', | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | "Error! view wrapper '$wrapper' not found within scaffold" | ||||||||||||||||||||||||||||
| 35 | ) | ||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub valid_not_found_template { | ||||||||||||||||||||||||||
|
Subroutine
valid_not_found_template: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 40 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 41 | 0 | my $nft = $self->not_found_template; | |||||||||||||||||||||||||||
| 42 | 0 | ▶ | $nft && $self->Scaffold->resolve_file($nft) ? $nft : undef | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$nft and $self->Scaffold->resolve_file($nft)
MC/DC0%0/2
$nft and $self->Scaffold->resolve_file($nft)
$nft
$self->Scaffold->resolve_file($nft)
Truth table0%0/3
A and B
A= $nftB= $self->Scaffold->resolve_file($nft)
| |||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub handles_not_found { | ||||||||||||||||||||||||||
|
Subroutine
handles_not_found: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 46 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 47 | 0 | ▶ | $self->valid_not_found_template ? 1 : 0 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub resolve_subpath { | ||||||||||||||||||||||||||
|
Subroutine
resolve_subpath: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 52 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | my $template = shift or return undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | # First check to see if this is even our path prefix: | ||||||||||||||||||||||||||||
| 56 | 0 | my ($pfx,$name) = split($self->path,$template,2); | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | ($name && $pfx eq '') ? $name : undef | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$name and $pfx eq ""
MC/DC0%0/2
$name and $pfx eq ""
$name
$pfx eq ""
Truth table0%0/3
A and B
A= $nameB= $pfx eq ""
| |||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | #sub template_content_for { | ||||||||||||||||||||||||||||
| 64 | # my ($self, $path) = @_; | ||||||||||||||||||||||||||||
| 65 | # my $name = $self->resolve_claimed_post_name($path) or return undef; | ||||||||||||||||||||||||||||
| 66 | # | ||||||||||||||||||||||||||||
| 67 | # unless ($self->Scaffold->Post_exists_fn->($name)) { | ||||||||||||||||||||||||||||
| 68 | # $name = $self->not_found_template or return undef; | ||||||||||||||||||||||||||||
| 69 | # } | ||||||||||||||||||||||||||||
| 70 | # | ||||||||||||||||||||||||||||
| 71 | # my $directive = | ||||||||||||||||||||||||||||
| 72 | # $self->type eq 'include' ? 'INCLUDE' : | ||||||||||||||||||||||||||||
| 73 | # $self->type eq 'insert' ? 'INSERT' : | ||||||||||||||||||||||||||||
| 74 | # die "Unexpected error -- 'type' must be 'include' or 'insert'"; | ||||||||||||||||||||||||||||
| 75 | # | ||||||||||||||||||||||||||||
| 76 | # return join("\n", | ||||||||||||||||||||||||||||
| 77 | # join('','[% META local_name = "',$name,'" %]'), | ||||||||||||||||||||||||||||
| 78 | # join('','[% WRAPPER "',$self->wrapper,'" %]'), | ||||||||||||||||||||||||||||
| 79 | # join('','[% ', $directive, ' "',$self->Scaffold->unique_int_post_path,$name,'" %]'), | ||||||||||||||||||||||||||||
| 80 | # '[% END %]' | ||||||||||||||||||||||||||||
| 81 | # ) | ||||||||||||||||||||||||||||
| 82 | #} | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub render_post_wrapper { | ||||||||||||||||||||||||||
|
Subroutine
render_post_wrapper: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 87 | 0 | my ($self, $name) = @_; | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | $self->_enforce_wrapper_exists; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | ▶ | my $directive = | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 92 | $self->type eq 'include' ? 'INCLUDE' : | ||||||||||||||||||||||||||||
| 93 | $self->type eq 'insert' ? 'INSERT' : | ||||||||||||||||||||||||||||
| 94 | die "Unexpected error -- 'type' must be 'include' or 'insert'"; | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | return join("\n", | |||||||||||||||||||||||||||
| 97 | join('','[% META local_name = "',$name,'" %]'), | ||||||||||||||||||||||||||||
| 98 | join('','[% WRAPPER "',$self->wrapper,'" %]'), | ||||||||||||||||||||||||||||
| 99 | join('','[% ', $directive, ' "',$self->Scaffold->unique_int_post_path,$name,'" %]'), | ||||||||||||||||||||||||||||
| 100 | '[% END %]' | ||||||||||||||||||||||||||||
| 101 | ) | ||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 2 | 1; | |||||||||||||||||||||||||||