NAME
Path::Maker - make files and directories as scaffolding
SYNOPSIS
use Path::Maker;
my $maker = Path::Maker->new(base_dir => $ENV{HOME});
$maker->render_to_file('gitconfig.mt' => '.gitconfig', $ENV{USER});
$maker->create_dir('.swap');
$maker->write_file('.vimrc', "set directory=~/.swap\n");
$maker->chmod('.ssh/id_rsa', 0400);
__DATA__
@@ gitconfig.mt
[user]
name = <?= $_[0] ?>
DESCRIPTION
Path::Maker helps you make files or directories as scaffolding. When I wrote a CLI script for mojo, I found that Mojolicious::Command is very useful. This module provides some functionality of that module with template syntax Text::MicroTemplate.
CONSTRUCTOR
Constructor $maker = Path::Maker->new(%options) accepts following options:
-
base_dir
If relative path is specified to methods
chmod,create_dir,render_to_fileorwrite_file, then it is assumed to relative to thebase_dir. Default: current working directory. -
package
Whose
__DATA__section to be read. Default:caller. -
template_header
If
template_headeris provided, it is inserted to every template files. Seeeg/template-header.plfor example. -
template_dir
By default, Path::Maker searches for template files in
__DATA__section. Iftemplate_diris provided, it also searches for template files intemplate_dir. Seeeg/module-scaffold.plfor example.
METHOD
-
$maker->chmod($path, $mode)Change permission of
$path. -
$maker->create_dir($dir)Create directory
$dir. -
$string = $maker->render($template_name, @arg)Render
$template_namewith@arg. -
$maker->render_to_file($template_name, $file, @arg)Render
$template_nameto$filewith@arg. -
$maker->write_file($file, $string)Write
$stringto$file.
SEE ALSO
Text::MicroTemplate::DataSection
LICENSE
Copyright (C) Shoichi Kaji.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
Shoichi Kaji skaji@cpan.org