File Coverage

lib/Dist/Zilla/Util/RoleDB.pm
Criterion Covered Total %
statement 31 31 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod 2 2 100.0
total 42 42 100.0


line stmt bran cond sub pod time code
1 3     3   27096 use 5.006;
  3         7  
  3         86  
2 3     3   11 use strict;
  3         4  
  3         75  
3 3     3   7 use warnings;
  3         4  
  3         178  
4              
5             package Dist::Zilla::Util::RoleDB;
6              
7             our $VERSION = '0.004000'; # TRIAL
8              
9             # ABSTRACT: Shared code for things that communicate data about dzil roles.
10              
11             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
12              
13 3     3   1232 use Moo qw( has );
  3         28868  
  3         15  
14 3     3   3098 use Carp qw( croak );
  3         4  
  3         414  
15              
16             ## no critic (NamingConventions)
17             my $is_ArrayRef = sub {
18             return 'ARRAY' eq ref $_[0] unless $_[1];
19             return unless 'ARRAY' eq ref $_[0];
20             for ( @{ $_[0] } ) {
21             return unless $_[1]->($_);
22             }
23             1;
24             };
25              
26              
27              
28              
29              
30              
31              
32             has items => (
33             isa => sub {
34             $is_ArrayRef->( $_[0], sub { $_[0]->isa('Dist::Zilla::Util::RoleDB::Entry') } ) or croak 'Must be ArrayRef[ RoleDB::Entry ]';
35             },
36             is => ro =>,
37             lazy => 1,
38             builder => '_build_items',
39             );
40              
41 3     3   13 no Moo;
  3         5  
  3         10  
42              
43             sub _build_items {
44 2     2   1688 require Dist::Zilla::Util::RoleDB::Items;
45 2         12 return [ Dist::Zilla::Util::RoleDB::Items->all() ];
46             }
47              
48              
49              
50              
51              
52              
53              
54             sub roles {
55 1     1 1 926 my ($self) = @_;
56 1         2 return @{ [ sort { $a->name cmp $b->name } @{ $self->items } ] };
  1         1  
  193         184  
  1         4  
57             }
58              
59              
60              
61              
62              
63              
64              
65             sub phases {
66 1     1 1 888 my ($self) = @_;
67 1         1 return @{ [ sort { $a->name cmp $b->name } grep { $_->is_phase } @{ $self->items } ] };
  1         2  
  23         29  
  54         77  
  1         3  
68             }
69              
70             1;
71              
72             __END__