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