All/Format/Fixed.pm

filter: Statementstmt 90.0% 36 / 40 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 3 totaltotal 83.3% 45 / 54 CC 3 SCAR 5.0
CC
3
Cov
88%
pack_template
3.0
expand
2.0
BEGIN
1.0
CRAP 1.6
« All/IO/Base.pm ↑ Summary ._All.pm »
1 package Data::All::Format::Fixed;
2  
3  
4 # $Id: Fixed.pm,v 1.1.1.1 2005/05/10 23:56:20 dmandelbaum Exp $
5  
6  
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Data::All::Format::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use vars qw(@EXPORT $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 @EXPORT = qw();
16 1 $VERSION = 0.11;
17  
18 1 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 our @EXPORT = qw(new internal attribute populate error init);
20  
21 1 attribute 'lengths' => [];
22 1 attribute 'break' => "\n"; # currently useless b/c it's hardcoded below
23  
24 1 attribute 'type';
25  
26 sub expand($);
27 sub contract(\@);
28  
29  
30 # TODO: Forward look to defined lengths if they are blank
31  
32 sub expand($)
33 0 ▶{
Subroutine expand: not called CC=1 SCAR=6.9
Pod undocumented
34 0 my $self = shift;
35 0 my $record = shift;
36 0 my $template = $self->pack_template();
37
38 0 return unpack($template, $record);
39 }
40  
41 sub contract(\@)
42 3 ▶{
Subroutine contract: called CC=1 SCAR=0.0
Pod undocumented
43 3 my $self = shift;
44 3 my $values = shift;
45 3 my $template = $self->pack_template();
46  
47 # NOTE: Line break is hardcoded to \n
48 3 return pack($template, @{ $values })."\n";
49 }
50  
51  
52 sub pack_template()
53 3 ▶{
Subroutine pack_template: called CC=3 SCAR=11.0
Pod undocumented
54 3 my $self = shift;
55 3 my @template;
56
57 3 foreach my $e (@{ $self->lengths })
58 {
59 12 push(@template, "A$e");
60 }
61
62 3 ▶ return !wantarray ? join(' ', @template) : @template;
Branch: 1 branch
BranchTrueFalseTotal
!wantarray ? : 3 0 3
63 }
64  
65  
66  
67  
68 1 1;
« All/IO/Base.pm ↑ Summary ._All.pm »