| 1 | 3 | ▶ | use 5.006; # our | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | package Statocles::AppRole::ExtraFeeds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | our $VERSION = '0.001003'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # ABSTRACT: Generate additional feed sets for apps | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use Moo::Role qw( has around ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use Statocles::App 0.070 (); # 0.70 required for ->template | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use Statocles::Page::List (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | has 'extra_feeds' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | default => sub { {} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | ▶ | use constant PATH_INDEX_PREFIX => qr{ \A (.*) / index [.](\w+) \z}sx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | ▶ | use constant PATH_GENERIC_PREFIX => qr{ \A (.*) / ([^/.]+) [.](\w+) \z}sx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # This separation is to help Coverage tools not lie to me that I did a perfect job | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | around pages => \&_around_pages; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | ▶ | sub _around_pages { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_around_pages: called CC=13 SCAR=51.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | my ( $orig, $self, @rest ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | my (@pages) = $self->$orig(@rest); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | return @pages unless @pages; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my %feed_cache; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | my @out_pages; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | while (@pages) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | my $page = shift @pages; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | push @out_pages, $page; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my (@existing_feeds) = $page->links('feed'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | next if not @existing_feeds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | for my $feed_id ( sort keys %{ $self->extra_feeds } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $feed = $self->extra_feeds->{$feed_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $feed_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $reference_path = $existing_feeds[0]->href; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | my $feed_suffix = $feed->{name} || $feed_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$feed->{'name'} || $feed_id
MC/DC0%0/2
$feed->{'name'} || $feed_id
$feed->{'name'}
$feed_id
Truth table0%0/3
A || B
A= $feed->{'name'}B= $feed_id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if ( $reference_path =~ PATH_INDEX_PREFIX ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $feed_path = "$1/$feed_suffix"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | elsif ( $reference_path =~ PATH_GENERIC_PREFIX ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $feed_path = "$1/$2.$feed_suffix"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | croak "Don't know how to derive feed path from $reference_path for $feed_suffix"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if ( not exists $feed_cache{$feed_path} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | my $feed_page = $feed_cache{$feed_path}{feed_page} = Statocles::Page::List->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | app => $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | pages => $page->pages, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | path => $feed_path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | template => $self->template( $feed->{template} || $feed->{name} || $feed_id ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | links => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | alternate => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | $self->link( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | href => $page->path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | title => ( $feed->{'index_title'} || $page->title || 'Web Index' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/11
$feed->{'template'} || $feed->{'name'} || $feed_id
$feed->{"template"} or $feed->{"name"}
$feed->{'index_title'} || $page->title || 'Web Index'
$feed->{"index_title"} or $page->title
MC/DC0%0/3
$feed->{'template'} || $feed->{'name'} || $feed_id
$feed->{"template"}
$feed->{"name"}
$feed_id
MC/DC0%0/2
$feed->{'index_title'} || $page->title || 'Web Index'
$feed->{"index_title"}
$page->title
Truth table0%0/4
A or B || C
A= $feed->{"template"}B= $feed->{"name"}C= $feed_id
Truth table0%0/3
A or B
A= $feed->{"index_title"}B= $page->title
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | type => $page->type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | $feed_cache{$feed_path}{feed_link} = $self->link( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | text => $feed->{text}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | href => $feed_page->path->stringify, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | type => $feed_page->type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $page->links( feed => $feed_cache{$feed_path}{feed_link} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | return @out_pages, map { $feed_cache{$_}{feed_page} } sort keys %feed_cache; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||