File Coverage

blib/lib/Rapi/Blog/Scaffold/Set.pm
Criterion Covered Total %
statement 21 49 42.8
branch 0 14 0.0
condition n/a
subroutine 7 18 38.8
pod 0 9 0.0
total 28 90 31.1


line stmt bran cond sub pod time code
1             package Rapi::Blog::Scaffold::Set;
2 1     1   7 use strict;
  1         2  
  1         31  
3 1     1   5 use warnings;
  1         3  
  1         31  
4              
5 1     1   6 use RapidApp::Util qw(:all);
  1         2  
  1         618  
6 1     1   8 use Rapi::Blog::Util;
  1         2  
  1         32  
7 1     1   6 use List::Util;
  1         32  
  1         61  
8              
9 1     1   6 use Moo;
  1         2  
  1         8  
10 1     1   2893 use Types::Standard ':all';
  1         3  
  1         12  
11              
12             has 'Scaffolds', is => 'ro', required => 1, isa => ArrayRef[InstanceOf['Rapi::Blog::Scaffold']];
13              
14 0     0 0   sub count { scalar(@{(shift)->Scaffolds}) }
  0            
15 0     0 0   sub all { @{(shift)->Scaffolds} }
  0            
16 0     0 0   sub first { (shift)->Scaffolds->[0] }
17              
18              
19             sub BUILD {
20 0     0 0   my $self = shift;
21            
22 0 0         $self->first or die "At least one Scaffold is required";
23             }
24              
25             sub first_with_param {
26 0     0 0   my $self = shift;
27 0 0         my $param = shift or die "no param supplied";
28            
29 0     0     List::Util::first { $_->config->$param } $self->all
  0            
30             }
31              
32             sub first_with_param_file {
33 0     0 0   my $self = shift;
34 0 0         my $param = shift or die "no param supplied";
35            
36             List::Util::first {
37 0     0     my $val = $_->config->$param;
38 0 0         if($val) {
39 0           my $File = $_->dir->file($val);
40 0           -f $File
41             }
42             else {
43 0           0
44             }
45 0           } $self->all
46             }
47              
48             sub first_config_value {
49 0     0 0   my ($self, $param) = @_;
50            
51 0 0         my $Scaffold = $self->first_with_param($param) or return undef;
52 0           $Scaffold->config->$param
53             }
54              
55             sub first_config_value_file {
56 0     0 0   my ($self, $param) = @_;
57            
58 0 0         my $Scaffold = $self->first_with_param_file($param) or return undef;
59 0           $Scaffold->config->$param
60             }
61              
62             sub first_config_value_filepath {
63 0     0 0   my ($self, $param) = @_;
64            
65 0 0         my $Scaffold = $self->first_with_param_file($param) or return undef;
66 0           $Scaffold->dir->file( $Scaffold->config->$param )->stringify
67             }
68              
69              
70              
71              
72             1;