File Coverage

blib/lib/KiokuDB/Role/Verbosity.pm
Criterion Covered Total %
statement 10 11 90.9
branch 2 4 50.0
condition n/a
subroutine 4 4 100.0
pod 0 2 0.0
total 16 21 76.1


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2              
3             package KiokuDB::Role::Verbosity;
4 3     3   1436 use Moose::Role;
  3         7  
  3         21  
5              
6 3     3   12138 use namespace::clean -except => 'meta';
  3         6  
  3         24  
7              
8             has verbose => (
9             isa => "Bool",
10             is => "ro",
11             );
12              
13             sub BUILD {
14 35     35 0 43 my $self = shift;
15              
16 35 50       968 STDERR->autoflush(1) if $self->verbose;
17             }
18              
19             sub v {
20 53     53 0 55 my $self = shift;
21 53 50       1415 return unless $self->verbose;
22              
23 0           STDERR->print(@_);
24             }
25              
26             __PACKAGE__
27              
28             __END__
29              
30             =pod
31              
32             =head1 NAME
33              
34             KiokuDB::Role::Verbosity - A role for printing diagnosis to STDERR
35              
36             =head1 SYNOPSIS
37              
38             $self->v("blah blah\n"); # only printed if $self->verbose is true
39              
40             =head1 DESCRIPTION
41              
42             This role provides the C<verbose> attribute and a C<v> method that you can use
43             to emit verbose output to C<STDERR>.