File Coverage

blib/lib/Dist/Zilla/Plugin/ModuleIncluder.pm
Criterion Covered Total %
statement 23 23 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 0 2 0.0
total 31 33 93.9


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::ModuleIncluder;
2             $Dist::Zilla::Plugin::ModuleIncluder::VERSION = '0.006';
3             # vim: ts=4 sts=0 sw=0 noet
4 1     1   1164794 use version;
  1         2  
  1         6  
5 1     1   59 use Moose;
  1         2  
  1         5  
6 1     1   4054 use MooseX::Types::Moose qw/ArrayRef Bool/;
  1         12  
  1         9  
7 1     1   3070 use MooseX::Types::Perl 'VersionObject';
  1         1  
  1         6  
8 1     1   1853 use MooseX::Types::Stringlike 'Stringlike';
  1         27495  
  1         6  
9              
10             with qw/Dist::Zilla::Role::ModuleIncluder Dist::Zilla::Role::FileGatherer/;
11              
12             has module => (
13             isa => ArrayRef[Stringlike],
14             traits => ['Array'],
15             handles => {
16             modules => 'elements',
17             },
18             required => 1,
19             );
20              
21             has blacklist => (
22             isa => ArrayRef[Stringlike],
23             traits => ['Array'],
24             handles => {
25             blacklisted_modules => 'elements',
26             },
27             default => sub { [] },
28             );
29              
30             has background_perl => (
31             is => 'ro',
32             isa => VersionObject,
33             default => sub { version->new('5.008001') },
34             coerce => 1,
35             );
36              
37             has only_deps => (
38             is => 'ro',
39             isa => Bool,
40             default => 0,
41             );
42              
43             sub gather_files {
44 1     1 0 75565 my ($self, $arg) = @_;
45 1         37 $self->include_modules({ map { ($_ => $self->only_deps ) } $self->modules }, $self->background_perl, { blacklist => [ $self->blacklisted_modules ] });
  1         29  
46 1         897 return;
47             }
48              
49             sub mvp_multivalue_args {
50 1     1 0 182 return qw/module blacklist/;
51             }
52              
53             __PACKAGE__->meta->make_immutable;
54              
55 1     1   1168 no Moose;
  1         2  
  1         6  
56              
57             1;
58              
59             #ABSTRACT: explicitly include modules into a distribution
60              
61             __END__
62              
63             =pod
64              
65             =encoding UTF-8
66              
67             =head1 NAME
68              
69             Dist::Zilla::Plugin::ModuleIncluder - explicitly include modules into a distribution
70              
71             =head1 VERSION
72              
73             version 0.006
74              
75             =head1 SYNOPSIS
76              
77             In dist.ini:
78              
79             [ModuleIncluder]
80             module = Foo
81             module = Bar
82             background_perl = 5.008001 #default value
83             only_deps = 0 #default
84             include_dependencies = 1 #default
85              
86             =head1 DESCRIPTION
87              
88             This module allows you to explicitly include a module and its dependencies in C<inc/>. At least one module must be given.
89              
90             =over 4
91              
92             =item * module
93              
94             Add a module to be included. This option can be given more than once.
95              
96             =item * background_perl
97              
98             Set the background perl version. If the (appropriate version of the) module was present in that release of perl, it will be omitted from C<inc>. It defaults to 5.8.1.
99              
100             =item * only_deps
101              
102             Do not include the specified modules, only their dependencies. Note that it still includes the module if something else depends on it.
103              
104             =item * blacklist
105              
106             The name of a module to never include. This option can be given more than once.
107              
108             =back
109              
110             =for Pod::Coverage gather_files
111             mvp_multivalue_args
112             =end
113              
114             =head1 AUTHOR
115              
116             Leon Timmermans <leont@cpan.org>
117              
118             =head1 COPYRIGHT AND LICENSE
119              
120             This software is copyright (c) 2011 by Leon Timmermans.
121              
122             This is free software; you can redistribute it and/or modify it under
123             the same terms as the Perl 5 programming language system itself.
124              
125             =cut