File Coverage

lib/Log/Shiras/Report/Test2Diag.pm
Criterion Covered Total %
statement 35 56 62.5
branch 0 10 0.0
condition n/a
subroutine 12 13 92.3
pod 1 1 100.0
total 48 80 60.0


line stmt bran cond sub pod time code
1             package Log::Shiras::Report::Test2Diag;
2             our $AUTHORITY = 'cpan:JANDREW';
3 1     1   545 use version; our $VERSION = version->declare("v0.46.0");
  1         2  
  1         7  
4 1     1   74 use strict;
  1         3  
  1         18  
5 1     1   3 use warnings;
  1         1  
  1         25  
6 1     1   21 use 5.010;
  1         3  
7 1     1   3 use utf8;
  1         2  
  1         6  
8 1     1   17 use Moose;
  1         1  
  1         5  
9 1     1   4145 use namespace::autoclean;
  1         1  
  1         9  
10 1     1   55 use MooseX::StrictConstructor;
  1         1  
  1         8  
11 1     1   1899 use Data::Dumper;
  1         2  
  1         47  
12 1     1   4 use Test2::Tools::Basic;
  1         1  
  1         142  
13              
14             #########1 Public Methods 3#########4#########5#########6#########7#########8#########9
15              
16 0           sub add_line{
17 0     0 1   shift;
18             my @input = ( ref $_[0]->{message} eq 'ARRAY' ) ?
19 0 0         @{$_[0]->{message}} : $_[0]->{message};
  0            
20 0           my ( @print_list, @initial_list, $first_line, $last_line, $sprintf_string );
21 1     1   5 no warnings 'uninitialized';
  1         1  
  1         196  
22 0           for my $value ( @input ){
23 0 0         push @initial_list, (( ref $value ) ? Dumper( $value ) : $value );
24             }
25 0           $first_line = shift @initial_list;
26 0           chomp $first_line;
27 0           $first_line =~ s/\r//g;
28 0           $first_line =~ s/\n//g;
29 0 0         if( !@initial_list ){
30 0           $sprintf_string = "| level - %-6s | name_space - %-s\n| line - %04d | file_name - %-s\n\t:(\t%s ):";
31             }else{
32 0           $last_line = pop @initial_list;
33 0           chomp $last_line;
34 0 0         $last_line = length( $last_line ) ? $last_line : "''";
35 0           $sprintf_string = "| level - %-6s | name_space - %-s\n| line - %04d | file_name - %-s\n\t:( %s";
36             }
37             diag sprintf( $sprintf_string,
38             $_[0]->{level}, $_[0]->{name_space},
39 0           $_[0]->{line}, $_[0]->{filename}, $first_line );
40 0           for my $middle_line ( @initial_list ){
41 0           diag sprintf( "\t %s", $middle_line );
42             }
43 0 0         diag sprintf( "\t %s ):", $last_line ) if $last_line;
44            
45 1     1   4 use warnings 'uninitialized';
  1         1  
  1         110  
46             }
47              
48             #########1 Phinish 3#########4#########5#########6#########7#########8#########9
49              
50             __PACKAGE__->meta->make_immutable;
51              
52             1;
53             # The preceding line will help the module return a true value
54              
55             #########1 main pod docs 3#########4#########5#########6#########7#########8#########9
56              
57             __END__
58              
59             =head1 NAME
60              
61             Log::Shiras::Report::Test2Diag - Log::Shiras Test2 diag output
62              
63             =head1 SYNOPSIS
64              
65             use Test2::Bundle::Extended qw( !meta );
66             use Test2::Plugin::UTF8;
67             plan( ? );
68             use Log::Shiras::Report::Test2Diag;
69             use Log::Shiras::Switchboard;
70             my( $switchboard, $test_class );
71             ok( lives{ my $switchboard = Log::Shiras::Switchboard->get_operator(
72             name_space_bounds =>{
73             UNBLOCK =>{
74             log_file => 'warn',
75             },
76             },
77             reports =>{
78             log_file =>[ Log::Shiras::Report::Test2Diag->new ], #Raise visibility to the actions being tested
79             },) }, "Start the switchboard");
80            
81             =head1 DESCRIPTION
82              
83             This is a simple L<Report|Log::Shiras::Report> class that can be used to provide
84             troubleshooting output to L<Test2> tests with L<Log::Shiras> content. The goal
85             is for the messages to integrate with the TAP format.
86              
87             =head2 Attributes
88              
89             None
90              
91             =head2 Methods
92              
93             =head3 new
94              
95             =over
96              
97             B<Definition:> This creates a new instance of the Test2Note L<report
98             |Log::Shiras::Switchboard/reports> class.
99              
100             B<Returns:> A report class to be stored in the switchboard.
101              
102             =back
103              
104             =head3 add_line( $ref )
105              
106             =over
107              
108             B<Definition:> This only accepts a switchboard scrubbed message ref.
109              
110             B<Returns:> 1 (or dies)
111              
112             =back
113              
114             =head1 SUPPORT
115              
116             =over
117              
118             L<Log-Shiras/issues|https://github.com/jandrew/Log-Shiras/issues>
119              
120             =back
121              
122             =head1 TODO
123              
124             =over
125              
126             B<1.> Nothing L<currently|/SUPPORT>
127              
128             =back
129              
130             =head1 AUTHOR
131              
132             =over
133              
134             =item Jed Lund
135              
136             =item jandrew@cpan.org
137              
138             =back
139              
140             =head1 COPYRIGHT
141              
142             This program is free software; you can redistribute
143             it and/or modify it under the same terms as Perl itself.
144              
145             The full text of the license can be found in the
146             LICENSE file included with this module.
147              
148             =head1 DEPENDENCIES
149              
150             =over
151              
152             L<version>
153              
154             L<Data::Dumper>
155              
156             L<Test2::Tools::Basic>
157              
158             =back
159              
160             =cut
161              
162             #########1#########2 main pod documentation end 5#########6#########7#########8#########9