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