File Coverage

lib/Dist/Zilla/Util/RoleDB.pm
Criterion Covered Total %
statement 13 15 86.6
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 18 20 90.0


line stmt bran cond sub pod time code
1 3     3   32093 use 5.008; # utf8
  3         9  
  3         93  
2 3     3   11 use strict;
  3         5  
  3         100  
3 3     3   12 use warnings;
  3         4  
  3         85  
4 3     3   1560 use utf8;
  3         24  
  3         14  
5              
6             package Dist::Zilla::Util::RoleDB;
7              
8             our $VERSION = '0.003001';
9              
10             # ABSTRACT: Shared code for things that communicate data about dzil roles.
11              
12             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
13              
14 3     3   2331 use Moose qw( has );
  0            
  0            
15              
16              
17              
18              
19              
20              
21              
22             has items => (
23             isa => 'ArrayRef[Dist::Zilla::Util::RoleDB::Entry]',
24             is => ro =>,
25             lazy_build => 1,
26             );
27              
28             __PACKAGE__->meta->make_immutable;
29             no Moose;
30              
31             sub _build_items {
32             require Dist::Zilla::Util::RoleDB::Items;
33             return [ Dist::Zilla::Util::RoleDB::Items->all() ];
34             }
35              
36              
37              
38              
39              
40              
41              
42             sub roles {
43             my ($self) = @_;
44             return @{ [ sort { $a->name cmp $b->name } @{ $self->items } ] };
45             }
46              
47              
48              
49              
50              
51              
52              
53             sub phases {
54             my ($self) = @_;
55             return @{ [ sort { $a->name cmp $b->name } grep { $_->is_phase } @{ $self->items } ] };
56             }
57              
58             1;
59              
60             __END__
61              
62             =pod
63              
64             =encoding UTF-8
65              
66             =head1 NAME
67              
68             Dist::Zilla::Util::RoleDB - Shared code for things that communicate data about dzil roles.
69              
70             =head1 VERSION
71              
72             version 0.003001
73              
74             =head1 DESCRIPTION
75              
76             This utility is a hard-coded list of various known C<Dist::Zilla> roles and their properties.
77              
78             It's not generally usable by most people, and is more useful for query tools, such as
79              
80             dzil dumpphases
81              
82             Certain entries may have additional markers indicating they are C<phase> roles,
83             and will have relevant data indicating what methods are invoked in that C<phase>.
84              
85             =head1 METHODS
86              
87             =head2 C<roles>
88              
89             Returns a list of all roles in the database, sorted by name.
90              
91             =head2 C<phases>
92              
93             Returns a list of all roles that are also phases, sorted by name.
94              
95             =head1 ATTRIBUTES
96              
97             =head2 C<items>
98              
99             Contains all items in this data set, as an array ref.
100              
101             =head1 AUTHOR
102              
103             Kent Fredric <kentnl@cpan.org>
104              
105             =head1 COPYRIGHT AND LICENSE
106              
107             This software is copyright (c) 2015 by Kent Fredric <kentfredric@gmail.com>.
108              
109             This is free software; you can redistribute it and/or modify it under
110             the same terms as the Perl 5 programming language system itself.
111              
112             =cut