File Coverage

blib/lib/Perl/Tidy/VerticalAligner/Alignment.pm
Criterion Covered Total %
statement 20 27 74.0
branch 0 2 0.0
condition n/a
subroutine 7 9 77.7
pod 0 5 0.0
total 27 43 62.7


line stmt bran cond sub pod time code
1             #####################################################################
2             #
3             # the Perl::Tidy::VerticalAligner::Alignment class holds information
4             # on a single column being aligned
5             #
6             #####################################################################
7              
8             package Perl::Tidy::VerticalAligner::Alignment;
9 44     44   240 use strict;
  44         107  
  44         1333  
10 44     44   173 use warnings;
  44         71  
  44         14184  
11              
12             our $VERSION = '20260204';
13              
14             sub new {
15              
16 8274     8274 0 11994 my ( $class, $rhash ) = @_;
17              
18             # Create a new VerticalAligner::Alignment object
19             # Given:
20             # $rhash = ref to hash for an alignment column
21             # There are just two values in the hash:
22             # {column} is the alignment column
23             # {saved_column} is used to save a column
24              
25 8274         11239 my $self = bless $rhash, $class;
26 8274         12700 return $self;
27             } ## end sub new
28              
29             sub AUTOLOAD {
30              
31             # Catch any undefined sub calls so that we are sure to get
32             # some diagnostic information. This sub should never be called
33             # except for a programming error.
34 0     0   0 our $AUTOLOAD;
35 0 0       0 return if ( $AUTOLOAD =~ /\bDESTROY$/ );
36 0         0 my ( $pkg, $fname, $lno ) = caller();
37 0         0 my $my_package = __PACKAGE__;
38 0         0 print {*STDERR} <<EOM;
  0         0  
39             ======================================================================
40             Error detected in package '$my_package', version $VERSION
41             Received unexpected AUTOLOAD call for sub '$AUTOLOAD'
42             Called from package: '$pkg'
43             Called from File '$fname' at line '$lno'
44             This error is probably due to a recent programming change
45             ======================================================================
46             EOM
47 0         0 exit 1;
48             } ## end sub AUTOLOAD
49              
50       0     sub DESTROY {
51              
52             # required to avoid call to AUTOLOAD in some versions of perl
53             }
54              
55             sub get_column {
56 9909     9909 0 10955 my $self = shift;
57 9909         16445 return $self->{'column'};
58             }
59              
60             sub increment_column {
61 7191     7191 0 8787 my ( $self, $pad ) = @_;
62 7191         8331 $self->{'column'} += $pad;
63 7191         10573 return;
64             }
65              
66             sub save_column {
67 4033     4033 0 4652 my $self = shift;
68 4033         5690 $self->{'saved_column'} = $self->{'column'};
69 4033         6014 return;
70             }
71              
72             sub restore_column {
73 43     43 0 62 my $self = shift;
74 43         80 $self->{'column'} = $self->{'saved_column'};
75 43         119 return;
76             }
77             1;