Gantry

 view release on metacpan or  search on metacpan

lib/Gantry/Build.pm  view on Meta::CPAN


}

sub ACTION_install {
    my $self = shift;
    $self->SUPER::ACTION_install();
    my $p = $self->{properties};

    my $tmpl_dir = $p->{web_dir};

    if( $tmpl_dir && $tmpl_dir ne '__skip__' ) {

        if ( not -d $tmpl_dir and $p->{ create_web_dir } =~ /^n/i ) {
            exit;
        }

        eval {
            File::Path::mkpath( $tmpl_dir );
        };
        if ( $@ ) {
            print "Error: unable to create directory $tmpl_dir\n";
            $@ =~ s/ at .+?$//;
            die( "$@\n" );
        }

        my $blib_tmpl_dir = File::Spec->catdir(
            $self->blib, 'web', $p->{build_web_directory} 
        );

        my $num;
        eval {
            $num = dircopy($blib_tmpl_dir, $tmpl_dir);
        };
        if ( $@ ) {
            print "Error coping templates:\n";
            print $@ . "\n";
        }
        else {
            print "Web content copied: $num\n";
        }
    }
    else {
        print "SKIPPING WEB CONTENT INSTALL\n";
    }
    print "-" x 80;
    print "\n";

} # end ACTION_install

sub _process_web_files {
    my $self    = shift;
    my $p       = $self->{properties};
    my $files   = $p->{web_files};
    
    return unless @$files;

    my $tmpl_dir = File::Spec->catdir($self->blib, 'web');
    File::Path::mkpath( $tmpl_dir );

    foreach my $file (@$files) {
        my $result = $self->copy_if_modified("$file", $tmpl_dir);
    }
}

1;

=head1 NAME

Gantry::Build - a Module::Build subclass for Gantry apps

=head1 SYNOPSIS

Sample Build.PL:

    use strict;
    use Gantry::Build;

    my $build = Gantry::Build->new(
        build_web_directory => 'html',
        install_web_directories =>  {
            # XXX unix specific paths
            'dev'   => '/home/httpd/html/Contact',
            'qual'  => '/home/httpd/html/Contact',
            'prod'  => '/home/httpd/html/Contact',
        },
        create_makefile_pl => 'passthrough',
        license            => 'perl',
        module_name        => 'Contact',
        requires           => {
            'perl'      => '5',
            'Gantry'    => '3.0',
            'HTML::Prototype' => '0',
        },
        create_makefile_pl  => 'passthrough',

        # XXX unix specific paths
        script_files        => [ glob('bin/*') ],
        'recursive_test_files' => 1,

        # XXX unix specific paths
        install_path        => { script => '/usr/local/bin' },
    );

    $build->create_build_script;

=head1 DESCRIPTION

Use this module instead of Module::Build (which it subclasses).  Use
any or all of the Module::Build constructor keys as needed.  Include these
keys to make the module sing:

=over 4

=item build_web_directory

Usually C<html>.  This is the top level directory of your web content.
Put your content in subdirectories of this dir.  Example: if you
are in the build directory (the one where Build.PL lives), your templates
should live in C<html/templates>.

=item install_web_directories



( run in 4.108 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )