File Coverage

blib/lib/Reconcile/Accounts/Vin.pm
Criterion Covered Total %
statement 34 37 91.8
branch 5 10 50.0
condition n/a
subroutine 8 8 100.0
pod 3 3 100.0
total 50 58 86.2


line stmt bran cond sub pod time code
1             package Reconcile::Accounts::Vin;
2              
3 3     3   44760 use v5.14;
  3         11  
4 3     3   16 use Carp;
  3         5  
  3         2008  
5              
6             our $VERSION = 1.01;
7              
8             sub new
9             {
10 2     2 1 1446 my ($class) = shift;
11 2         7 my $self = {@_};
12 2         9 $self->{checks} = [ \&_audit, \&_remove, \&_lpad ];
13 2         6 $self->{entry} = 0;
14 2         8 return bless $self, $class;
15             }
16              
17             sub run_checks
18             {
19 9     9 1 18 my ($self, $item) = @_;
20 9         141 $item =~ s/(\w)/\U$1/gi;
21 9         19 $self->{item} = $item;
22            
23 9         13 foreach my $method_name ( @{$self->{checks}} )
  9         21  
24             {
25 27         52 $method_name->($self);
26             }
27              
28 9         60 return $self->{item};
29             }
30              
31             sub _lpad
32             {
33 9     9   12 my $self = shift;
34              
35             eval
36 9         12 {
37 9 100       26 length($self->{item}) == $self->{length} && return;
38 8         29 $self->{item} =~ s/(\w+)/sprintf "%017s",$1/ge;
  8         40  
39             };
40 9 50       28 if ($@)
41             {
42 0         0 carp "error in _pad ";
43             }
44             }
45              
46              
47             sub _remove
48             {
49 9     9   12 my $self = shift;
50            
51             eval
52 9         10 {
53 9         24 $self->{item} =~ s/\W/\w/g;
54 9         218 $self->{item} =~ s/$_/$self->{remove}->{$_}/gi for (keys $self->{remove});# or carp "$_ error";
55             };
56 9 50       32 if ($@)
57             {
58 0         0 carp "error in _replace ";
59             }
60             }
61              
62             sub _audit
63             {
64 9     9   11 my $self = shift;
65             eval
66 9         10 {
67 9         18 $self->{entry}++;
68             };
69 9 50       29 if ($@)
70             {
71 0         0 carp "error in _audit ";
72             }
73             }
74              
75             sub get_length
76             {
77 2     2 1 7 my $self = shift;
78 2 0       15 return $self->{length} or carp "error in get_length ";
79             }
80              
81             1;
82              
83              
84             __END__