Any-Template-ProcessDir

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

0.07  May 14, 2012

- Make writability test author-only as it does not work on all cpantesters

0.06  Dec 1, 2011

- Pass full path to ignore_files

0.05  Nov 29, 2011

- Don't chmod non-template files in single-dir mode

0.04  Nov 27, 2011

- Allow result files to be generated inside same dir instead of separate dir
- Document that process_file and process_text take object as second arg

0.03  Jun 15, 2011

- Ignore errors when symlinking, e.g. for win32

lib/Any/Template/ProcessDir.pm  view on Meta::CPAN

    }
    else {
        return;
    }

    if ( $self->same_dir ) {
        unlink($dest_file);
    }
    else {
        make_path( dirname($dest_file) );
        chmod( $self->dir_create_mode(), dirname($dest_file) )
          if defined( $self->dir_create_mode() );
    }

    write_file( $dest_file, $dest_text );
    chmod( $self->file_create_mode(), $dest_file )
      if defined( $self->file_create_mode() );
}

sub _build_process_file {
    return sub {
        my ( $file, $self ) = @_;

        my $code = $self->process_text;
        return $code->( read_file($file), $self );
      }

t/process-single-dir.t  view on Meta::CPAN

    $pd->process_dir();

    is( read_file("$dir/foo"),         "THIS IS FOO.SRC\n",     "foo.src" );
    is( read_file("$dir/bar/baz"),     "THIS IS BAR/BAZ.SRC\n", "bar/baz.src" );
    is( read_file("$dir/fop.txt"),     "this is fop.txt\n",     "fop.txt" );
    is( read_file("$dir/bar/bap.txt"), "this is bar/bap.txt\n", "bar/bap.txt" );

    ok( !-f "$dir/README", "no README" );
    ok( -w "$dir/fop.txt", "fop.txt writable" );

    # This test fails on some cpantesters even though chmod is being done,
    # not sure why
    ok( !-w "$dir/bar/baz", "bar/baz not writable" ) if $ENV{AUTHOR_TESTING};

    write_file( "$dir/bar/baz.src", "overwrote\n" );
    $pd->process_dir();

    is( read_file("$dir/bar/baz"), "OVERWROTE\n",       "bar/baz.src" );
    is( read_file("$dir/fop.txt"), "this is fop.txt\n", "fop.txt" );
}



( run in 0.489 second using v1.01-cache-2.11-cpan-496ff517765 )