AlignDB-Stopwatch
view release on metacpan or search on metacpan
lib/AlignDB/Stopwatch.pm view on Meta::CPAN
my $right_length = $div_length - $title_length - $left_length;
$divider_str .= $div_char x $left_length;
$divider_str .= $title;
$divider_str .= $div_char x $right_length;
$divider_str .= "\n";
}
return $divider_str;
}
sub _prompt {
my $self = shift;
return "==> ";
}
sub _empty_line {
my $self = shift;
return "\n";
}
sub _time {
lib/AlignDB/Stopwatch.pm view on Meta::CPAN
return Time::Duration::duration( time - $self->start_time );
}
sub block_message {
my $self = shift;
my $message = shift;
my $with_duration = shift;
my $text;
$text .= $self->_empty_line;
$text .= $self->_prompt;
$text .= $self->_message($message);
if ($with_duration) {
$text .= $self->_prompt;
$text .= $self->_duration;
}
$text .= $self->_empty_line;
print $text;
return;
}
sub start_message {
t/03.message.t view on Meta::CPAN
use Test::Output;
use AlignDB::Stopwatch;
my $stopwatch = AlignDB::Stopwatch->new;
is( $stopwatch->_message, "\n" );
stdout_is(
sub { $stopwatch->block_message },
$stopwatch->_empty_line . $stopwatch->_prompt . $stopwatch->_message . $stopwatch->_empty_line
);
stdout_is(
sub { $stopwatch->block_message },
"\n==> \n\n"
);
stdout_is(
sub { $stopwatch->block_message("Hello") },
"\n==> Hello\n\n"
( run in 0.482 second using v1.01-cache-2.11-cpan-6aa56a78535 )