Changed default match to use path instead of result
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Build.pm
1 package Catalyst::Build;
2
3 use strict;
4 use Module::Build;
5 use base 'Module::Build';
6 use Path::Class;
7 use File::Find 'find';
8
9 our @ignore =
10   qw/Build Build.PL Changes MANIFEST META.yml Makefile.PL Makefile README
11   _build blib lib script t/;
12
13 our $FAKE;
14 our $ignore = '^(' . join( '|', @ignore ) . ')$';
15
16 =head1 NAME
17
18 Catalyst::Build - Module::Build extension for Catalyst
19
20 =head1 SYNOPSIS
21
22 See L<Catalyst>
23
24 =head1 DESCRIPTION
25
26 L<Module::Build> extension for Catalyst.
27
28 =head1 METHODS
29
30 =over 4
31
32 =item ACTION_install
33
34 =cut
35
36 sub ACTION_install {
37     my $self = shift;
38     $self->SUPER::ACTION_install;
39     $self->ACTION_install_extras;
40 }
41
42 =item ACTION_fakeinstall
43
44 =cut
45
46 sub ACTION_fakeinstall {
47     my $self = shift;
48     $self->SUPER::ACTION_fakeinstall;
49     local $FAKE = 1;
50     $self->ACTION_install_extras;
51 }
52
53 =item ACTION_install_extras
54
55 =cut
56
57 sub ACTION_install_extras {
58     my $self    = shift;
59     my $prefix  = $self->{properties}{destdir} || undef;
60     my $sitelib = $self->install_destination('lib');
61     my @path    = defined $prefix ? ( $prefix, $sitelib ) : ($sitelib);
62     my $path    = dir( @path, split( '::', $self->{properties}{module_name} ) );
63     my @files   = $self->_find_extras;
64     print "Installing extras to $path\n";
65     for (@files) {
66         $FAKE
67           ? print "$_ -> $path (FAKE)\n"
68           : $self->copy_if_modified( $_, $path );
69     }
70 }
71
72 sub _find_extras {
73     my $self = shift;
74     my @all  = glob '*';
75     my @files;
76     for my $file (@all) {
77         next if $file =~ /$ignore/;
78         if ( -d $file ) {
79             find(
80                 sub {
81                     return if -d;
82                     push @files, $File::Find::name;
83                 },
84                 $file
85             );
86         }
87         else { push @files, $file }
88     }
89     return @files;
90 }
91
92 =back
93
94 =head1 AUTHOR
95
96 Sebastian Riedel, C<sri@oook.de>
97
98 =head1 LICENSE
99
100 This library is free software, you can redistribute it and/or modify it under
101 the same terms as Perl itself.
102
103 =cut
104
105 1;