blib/lib/Module/Install/Catalyst.pm

filter: Statementstmt 92.4% 49 / 53 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 10 / 12 Podpod 100% 4 / 4 totaltotal 90.6% 68 / 75 CC 7 SCAR 10.6
CC
7
Cov
92%
catalyst_files
6.0
catalyst
2.0
catalyst_ignore_all
2.0
CRAP 2.9
« blib/lib/Catalyst/Restarter/Win32.pm ↑ Summary blib/lib/Catalyst/Devel.pm »
1 package Module::Install::Catalyst;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use base qw/ Module::Install::Base /;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 our @ISA;
7 1 require Module::Install::Base;
8  
9 1 ▶use File::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use FindBin;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use File::Copy::Recursive;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Getopt::Long ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 my $SAFETY = 0;
17  
18 1 our @IGNORE =
19 qw/Build Build.PL Changes MANIFEST META.yml Makefile.PL Makefile README
20 _build blib lib script t inc .*\.svn \.git _darcs \.bzr \.hg
21 debian build-stamp install-stamp configure-stamp/;
22  
23 =head1 NAME
24  
25 Module::Install::Catalyst - Module::Install extension for Catalyst
26  
27 =head1 SYNOPSIS
28  
29 use lib '.';
30 use inc::Module::Install;
31  
32 name 'MyApp';
33 all_from 'lib/MyApp.pm';
34  
35 requires 'Catalyst::Runtime' => '5.7014';
36  
37 catalyst_ignore('.*temp');
38 catalyst_ignore('.*tmp');
39 catalyst;
40 WriteAll;
41  
42 =head1 DESCRIPTION
43  
44 L<Module::Install> extension for Catalyst.
45  
46 =head1 METHODS
47  
48 =head2 catalyst
49  
50 Calls L<catalyst_files>. Should be the last catalyst*
51 command called in C<Makefile.PL>.
52  
53 =cut
54  
55 1 ▶sub catalyst {
Subroutine catalyst: called CC=2 SCAR=7.0
Pod documented
56 1 my $self = shift;
57  
58 1 ▶ if($Module::Install::AUTHOR) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Module::Install::AUTHOR) 1 0 1
59 1 $self->include("File::Copy::Recursive");
60 }
61  
62 1 print <<EOF;
63 *** Module::Install::Catalyst
64 EOF
65 1 $self->catalyst_files;
66 1 print <<EOF;
67 *** Module::Install::Catalyst finished.
68 EOF
69 }
70  
71 =head2 catalyst_files
72  
73 Collect a list of all files a Catalyst application consists of and copy it
74 inside the blib/lib/ directory. Files and directories that match the modules
75 ignore list are excluded (see L<catalyst_ignore> and L<catalyst_ignore_all>).
76  
77 =cut
78  
79 1 ▶sub catalyst_files {
Subroutine catalyst_files: called CC=6 SCAR=17.9
Pod documented
80 1 my $self = shift;
81  
82 1 chdir $FindBin::Bin;
83  
84 1 my @files;
85 1 opendir CATDIR, '.';
86 1 CATFILES: for my $name ( readdir CATDIR ) {
87 12 for my $ignore (@IGNORE) {
88 138 ▶ next CATFILES if $name =~ /^$ignore$/;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /^$ignore$/ 7 131 138
89 131 ▶ next CATFILES if $name !~ /\w/;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /\w/ 2 129 131
90 }
91 3 push @files, $name;
92 }
93 1 closedir CATDIR;
94 1 my @path = split '-', $self->name;
95 1 for my $orig (@files) {
96 3 my $path = File::Spec->catdir( 'blib', 'lib', @path, $orig );
97 3 File::Copy::Recursive::rcopy( $orig, $path );
98 }
99 }
100  
101 =head2 catalyst_ignore_all(\@ignore)
102  
103 This function replaces the built-in default ignore list with the given list.
104  
105 =cut
106  
107 0 ▶sub catalyst_ignore_all {
Subroutine catalyst_ignore_all: not called CC=1 SCAR=6.9
Pod documented
108 0 my ( $self, $ignore ) = @_;
109 0 @IGNORE = @$ignore;
110 }
111  
112 =head2 catalyst_ignore(@ignore)
113  
114 Add a regexp to the list of ignored patterns. Can be called multiple times.
115  
116 =cut
117  
118 0 ▶sub catalyst_ignore {
Subroutine catalyst_ignore: not called CC=1 SCAR=6.9
Pod documented
119 0 my ( $self, @ignore ) = @_;
120 0 push @IGNORE, @ignore;
121 }
122  
123 =head1 AUTHORS
124  
125 Catalyst Contributors, see Catalyst.pm
126  
127 =head1 LICENSE
128  
129 This library is free software. You can redistribute it and/or modify it under
130 the same terms as Perl itself.
131  
132 =cut
133  
134 1 1;
« blib/lib/Catalyst/Restarter/Win32.pm ↑ Summary blib/lib/Catalyst/Devel.pm »