File Coverage

blib/lib/App/Embra/Role/ExtraListDeps.pm
Criterion Covered Total %
statement 28 28 100.0
branch 6 10 60.0
condition 4 12 33.3
subroutine 6 6 100.0
pod n/a
total 44 56 78.5


line stmt bran cond sub pod time code
1 6     6   3497 use strict;
  6         13  
  6         265  
2 6     6   30 use warnings;
  6         7  
  6         354  
3              
4             package App::Embra::Role::ExtraListDeps;
5             $App::Embra::Role::ExtraListDeps::VERSION = '0.001'; # TRIAL
6             # ABSTRACT: allow a plugin to add more things to listdeps
7              
8 6     6   687 use Method::Signatures;
  6         59035  
  6         41  
9 6     6   2881 use Moo::Role;
  6         12813  
  6         37  
10              
11              
12             requires 'extra_list_deps';
13              
14              
15 6 50 33 6   178426 method add_extra_deps( $class:, HashRef :$config, CPAN::Meta::Requirements :$reqs ) {
  1 50 33 1   7721  
  1 50 33     6  
  1 50 33     3  
  1         23  
  1         402627  
  1         2  
  1         13  
  1         2011  
  1         5  
  1         4  
16 1         9 for my $extra ( $class->extra_list_deps( config => $config )) {
17 2         141 my ($p, $ver) = split qr{[ ]* = [ ]*}xms, $extra;
18 2 100       7 if( ! defined $ver ) {
19 1         2 $ver = 0;
20             }
21 2         8 $reqs->add_minimum( $p, $ver );
22             }
23             }
24              
25             1;
26              
27             __END__
28              
29             =pod
30              
31             =encoding UTF-8
32              
33             =head1 NAME
34              
35             App::Embra::Role::ExtraListDeps - allow a plugin to add more things to listdeps
36              
37             =head1 VERSION
38              
39             version 0.001
40              
41             =head1 DESCRIPTION
42              
43             This role is used by plugins to add extra pacakges to the list of required dependencies when C<embra listdeps> is executed.
44              
45             Plugins which consume this role must define C<extra_list_deps>, which will be passed the values for the associated section in config and returns a list of package names.
46              
47             =head1 METHODS
48              
49             =head2 add_extra_deps
50              
51             App::Embra::Role::ExtraListDeps->add_extra_deps( $config, $reqs );
52              
53             Static method which adds all of the plugin's extra dependencies to C<$reqs>, which is a L<CPAN::Meta::Requirements>. The values for the plugin set in the relevant config section are passed as C<$config> (HashRef).
54              
55             =head1 AUTHOR
56              
57             Daniel Holz <dgholz@gmail.com>
58              
59             =head1 COPYRIGHT AND LICENSE
60              
61             This software is copyright (c) 2015 by Daniel Holz.
62              
63             This is free software; you can redistribute it and/or modify it under
64             the same terms as the Perl 5 programming language system itself.
65              
66             =cut