File Coverage

lib/Log/Shiras/Report/Test2Note.pm
Criterion Covered Total %
statement 49 50 98.0
branch 9 10 90.0
condition n/a
subroutine 11 11 100.0
pod 1 1 100.0
total 70 72 97.2


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