Verby::Action::MkPath - Action to create a directory path


Verby documentation Contained in the Verby distribution.

Index


Code Index:

NAME

Top

Verby::Action::MkPath - Action to create a directory path

SYNOPSIS

Top

	use Verby::Step::Closure qw/step/;

	step "Verby::Action::MkPath" => sub {
		my ($self, $c) = @_;
		$c->path("/some/path/that/will/be/created");
	}

DESCRIPTION

Top

This Action uses mkpath in File::Path to create a directory path.

METHODS

Top

do

Creates the directory $c->path.

verfiy

Ensures that the directory $c->path exists.

BUGS

Top

None that we are aware of. Of course, if you find a bug, let us know, and we will be sure to fix it.

CODE COVERAGE

Top

We use Devel::Cover to test the code coverage of the tests, please refer to COVERAGE section of the Verby module for more information.

SEE ALSO

Top

AUTHOR

Top

Yuval Kogman, <nothingmuch@woobling.org>

COPYRIGHT AND LICENSE

Top


Verby documentation Contained in the Verby distribution.

#!/usr/bin/perl

package Verby::Action::MkPath;
use Moose;

with qw/Verby::Action/;

use File::Path qw/mkpath/;

our $VERSION = "0.05";

sub do {
	my $self = shift;
	my $c = shift;

	my $path = $c->path;

	if ( !defined($path) || !length($path) ){
		$c->logger->log_and_die(level => "error", message => "invalid path");
	}

	$c->logger->info("creating path '$path'");

	mkpath($path)
		or $c->logger->log_and_die(level => "error", message => "couldn't mkpath('$path'): $!");

	$self->confirm($c);
}

sub verify {
	my $self = shift;
	my $c = shift;

	-d $c->path;
}

__PACKAGE__

__END__