Rudesind

 view release on metacpan or  search on metacpan

inc/Rudesind/Build.pm  view on Meta::CPAN

}

sub ACTION_install
{
    my $self = shift;

    $self->SUPER::ACTION_install(@_);
    $self->dispatch('install_htdocs');
    $self->dispatch('make_image_dirs');
    $self->dispatch('write_config_file');
#    $self->dispatch('print_apache_config');
}

sub ACTION_install_htdocs
{
    my $self = shift;

    # Don't use "use", or we'll short-circuit attempts to figure out
    # this distro's prereqs.
    require File::Find::Rule;
    my $rule = File::Find::Rule->new;

    my @files =
        $rule->or( $rule->new
                   ->directory
                   ->name('.svn')
                   ->prune
                   ->discard,

                   $rule->new
                   ->directory
                   ->name('images')
                   ->prune
                   ->discard,

                   $rule->new
                   ->directory
                   ->name('image-cache')
                   ->prune
                   ->discard,

                   $rule->new
                   ->name(qr/~$/)
                   ->prune
                   ->discard,

                   $rule->new,
                 )->file->in('htdocs');


    foreach my $file (@files)
    {
        my $dir = File::Basename::dirname($file);
        $dir =~ s:.*htdocs::;

        my $to =
            File::Spec->catfile( $self->notes('Rudesind_root'),
                                 $dir,
                                 File::Basename::basename($file) );

        $self->copy_if_modified( from => $file,
                                 to   => $to,
                                 flatten => 1,
                               );
    }
}

sub ACTION_make_image_dirs
{
    my $self = shift;

    foreach my $d ( qw( images image-cache ) )
    {
        my $dir = File::Spec->catdir( $self->notes('Rudesind_root'), $d );

        unless ( -d $dir )
        {
            print "Creating $dir directory.\n";

            mkdir $dir, 0755
                or die "Cannot make dir $dir: $!";
        }
    }
}

sub ACTION_write_config_file
{
    my $self = shift;

    my $dir = $self->notes('Rudesind_config_dir');

    return unless defined $dir;

    File::Path::mkpath( $dir, 0, 0755 );

    my $file = File::Spec->catfile( $dir, 'Rudesind.conf' );

    print "Writing boilerplate config file at $file.  You may want to edit this.\n";

    open my $fh, ">$file"
        or die "Cannot write to $file: $!";
    print $fh $self->_config_boilerplate
        or die "Cannot write to $file: $!";
    close $fh;
}

sub _config_boilerplate
{
    my $self = shift;

    my $root = $self->notes('Rudesind_root');

    return <<"EOF";
#
# The root_dir parameter is the directory under which Rudesind's Mason
# components are stored, as well as the images to be displayed, and
# cached images created by Rudesind.  The image directories will need
# to be accessible via your web server.  It is required.
#
# You should not change this unless you have manually moved the files
# located under this directory.



( run in 2.264 seconds using v1.01-cache-2.11-cpan-364913b4093 )