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