App-Module-Template

 view release on metacpan or  search on metacpan

lib/App/Module/Template.pm  view on Meta::CPAN

        croak "Destination directory $dist_dir exists. exiting...";
    }

    my $template_dir = _get_template_path($opt{t});

    my $config_file = _get_config_path($opt{c}, $template_dir);

    my $cfg = _get_config($config_file);

    # Setting this lets TT2 handle creating the destination files/directories
    $cfg->{template_toolkit}{OUTPUT_PATH} = $dist_dir;

    my $tt2 = Template->new( $cfg->{template_toolkit} );

    # don't need this in the $tmpl_vars
    delete $cfg->{template_toolkit};

    my $dirs = _get_module_dirs( $module );

    # Template Vars
    $tmpl_vars = $cfg;

t/process_dirs_abs.t  view on Meta::CPAN

use_ok( 'App::Module::Template', '_process_dirs' );

ok( my $a1 = File::Spec->catdir( File::Spec->curdir, 't', '.module-template', 'templates' ), 'set template path' );

ok( my $abs_tmpl_path = File::Spec->rel2abs( $a1 ), 'set absolute template path' );

ok( my $a2 = File::Spec->catdir( File::Spec->curdir, 'test_dir' ), 'set output path' );

ok( my $abs_output_path = File::Spec->rel2abs( $a2 ), 'set absolute output path' );

ok( my $abs_tt2 = Template->new({ABSOLUTE => 1, OUTPUT_PATH => $abs_output_path}), 'create absolute TT2 object' );

ok( my $tmpl_vars = {}, 'set $tmpl_vars' );

ok( my $cant_read = File::Spec->catdir( File::Spec->curdir, 'cant_read' ), 'set cant_read' );

ok( make_path($cant_read), 'create cant_read' );

SKIP: {
    skip( 'Running under windows', 2 ) if $^O eq 'MSWin32';

t/process_dirs_rel.t  view on Meta::CPAN

use File::Path qw/remove_tree/;
use File::Spec;
use Template;

use_ok( 'App::Module::Template', '_process_dirs' );

ok( my $rel_tmpl_path = File::Spec->catfile( File::Spec->curdir, 't', '.module-template', 'templates' ), 'set relative template path' );

ok( my $rel_output_path = File::Spec->catdir( File::Spec->curdir, 'test_dir' ), 'set relative output path' );

ok( my $rel_tt2 = Template->new({RELATIVE => 1, OUTPUT_PATH => $rel_output_path}), 'create relative TT2 object' );

ok( my $tmpl_vars = {}, 'set $tmpl_vars' );

ok( _process_dirs($rel_tt2, $tmpl_vars, $rel_tmpl_path, $rel_tmpl_path), '_process_dirs() w/ relative paths' );

ok( -d File::Spec->catdir( $rel_output_path, 'bin' ), 'bin exists' );
ok( -d File::Spec->catdir( $rel_output_path, 'lib' ), 'lib exists' );
ok( -d File::Spec->catdir( $rel_output_path, 't' ), 't exists' );
ok( -d File::Spec->catdir( $rel_output_path, 'xt' ), 'xt exists' );
ok( -d File::Spec->catdir( $rel_output_path, 'xt', 'author' ), 'xt/author exists' );

t/process_template.t  view on Meta::CPAN

use Template;

use_ok( 'App::Module::Template', '_process_template' );

ok( my $fake_tmpl_path = File::Spec->catdir( File::Spec->curdir, 'some-non-dir' ), 'set fake template path' );

ok( my $abs_tmpl_path = File::Spec->catfile( File::Spec->curdir, 't', '.module-template', 'templates', 'Changes' ), 'set fake template path' );
#
ok( my $abs_output_path = File::Spec->catdir( File::Spec->curdir, 'test_dir' ), 'set output path' );

ok( my $tt2 = Template->new({ABSOLUTE => 1, OUTPUT_PATH => $abs_output_path}), 'create absolute TT2 object' );

ok( my $tmpl_vars = {}, 'set $tmpl_vars' );

throws_ok{ _process_template($tt2, $tmpl_vars, $fake_tmpl_path, undef) } qr/some/, '_process_template throws error';

ok( _process_template($tt2, $tmpl_vars, $abs_tmpl_path, undef), '_process_template()' );



( run in 0.494 second using v1.01-cache-2.11-cpan-c6e0e5ac2a7 )