File Coverage

lib/PatchReader/DiffPrinter/raw.pm
Criterion Covered Total %
statement 38 38 100.0
branch 8 12 66.6
condition 5 7 71.4
subroutine 7 7 100.0
pod 0 6 0.0
total 58 70 82.8


line stmt bran cond sub pod time code
1             package PatchReader::DiffPrinter::raw;
2              
3 8     8   9462 use strict;
  8         23  
  8         4260  
4              
5             sub new {
6 8     8 0 513 my $class = shift;
7 8   33     47 $class = ref($class) || $class;
8 8         15 my $this = {};
9 8         23 bless $this, $class;
10              
11 8 50       85 $this->{OUTFILE} = @_ ? $_[0] : *STDOUT;
12 8         28 my $fh = $this->{OUTFILE};
13              
14 8         92 return $this;
15             }
16              
17 7     7 0 22 sub start_patch {
18             }
19              
20 7     7 0 27 sub end_patch {
21             }
22              
23             sub start_file {
24 8     8 0 14 my $this = shift;
25 8         12 my ($file) = @_;
26              
27 8         21 my $fh = $this->{OUTFILE};
28 8 100       245 if ($file->{rcs_filename}) {
29 6         45 print $fh "Index: $file->{filename}\n";
30 6         18 print $fh "===================================================================\n";
31 6         30 print $fh "RCS file: $file->{rcs_filename}\n";
32             }
33 8 50       31 my $old_file = $file->{is_add} ? "/dev/null" : $file->{filename};
34 8   100     45 my $old_date = $file->{old_date_str} || "";
35 8         28 print $fh "--- $old_file\t$old_date";
36 8 100       39 print $fh "\t$file->{old_revision}" if $file->{old_revision};
37 8         16 print $fh "\n";
38 8 50       28 my $new_file = $file->{is_remove} ? "/dev/null" : $file->{filename};
39 8   100     43 my $new_date = $file->{new_date_str} || "";
40 8         33 print $fh "+++ $new_file\t$new_date";
41 8 50       57 print $fh "\t$file->{new_revision}" if $file->{new_revision};
42 8         34 print $fh "\n";
43             }
44              
45 8     8 0 20 sub end_file {
46             }
47              
48             sub next_section {
49 8     8 0 13 my $this = shift;
50 8         18 my ($section) = @_;
51              
52 8         16 my $fh = $this->{OUTFILE};
53 8         49 print $fh "@@ -$section->{old_start},$section->{old_lines} +$section->{new_start},$section->{new_lines} @@ $section->{func_info}\n";
54 8         17 foreach my $line (@{$section->{lines}}) {
  8         23  
55 66         292 $line =~ s/(\r?\n?)$/\n/;
56 66         220 print $fh $line;
57             }
58             }
59              
60             1