Reformatted documentation
[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 =head2 ACTION_install
31
32 =cut
33
34 sub ACTION_install {
35     my $self = shift;
36     $self->SUPER::ACTION_install;
37     $self->ACTION_install_extras;
38 }
39
40 =head2 ACTION_fakeinstall
41
42 =cut
43
44 sub ACTION_fakeinstall {
45     my $self = shift;
46     $self->SUPER::ACTION_fakeinstall;
47     local $FAKE = 1;
48     $self->ACTION_install_extras;
49 }
50
51 =head2 ACTION_install_extras
52
53 =cut
54
55 sub ACTION_install_extras {
56     my $self    = shift;
57     my $prefix  = $self->{properties}{destdir} || undef;
58     my $sitelib = $self->install_destination('lib');
59     my @path    = defined $prefix ? ( $prefix, $sitelib ) : ($sitelib);
60     my $path    = dir( @path, split( '::', $self->{properties}{module_name} ) );
61     my @files   = $self->_find_extras;
62     print "Installing extras to $path\n";
63     for (@files) {
64         $FAKE
65           ? print "$_ -> $path (FAKE)\n"
66           : $self->copy_if_modified( $_, $path );
67     }
68 }
69
70 sub _find_extras {
71     my $self = shift;
72     my @all  = glob '*';
73     my @files;
74     for my $file (@all) {
75         next if $file =~ /$ignore/;
76         if ( -d $file ) {
77             find(
78                 sub {
79                     return if -d;
80                     push @files, $File::Find::name;
81                 },
82                 $file
83             );
84         }
85         else { push @files, $file }
86     }
87     return @files;
88 }
89
90 =head1 AUTHOR
91
92 Sebastian Riedel, C<sri@oook.de>
93
94 =head1 LICENSE
95
96 This library is free software, you can redistribute it and/or modify it under
97 the same terms as Perl itself.
98
99 =cut
100
101 1;