| 1 | package Business::NAB::FileContainer; | ||||||||||
| 2 | 8 | $Business::NAB::FileContainer::VERSION = '0.11'; | |||||||||
| 3 | # undocument abstract class | ||||||||||
| 4 | |||||||||||
| 5 | 8 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 8 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 8 | ▶ | use feature qw/ signatures /; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 8 | ▶ | use autodie qw/ :all /; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 8 | ▶ | use Carp qw/ croak /; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 8 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 8 | ▶ | no warnings qw/ experimental::signatures /; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 8 | ▶ | use Business::NAB::Types qw/ decamelize /; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 7 | ▶ | sub new_from_file ( | ||||||||
|
Subroutine
new_from_file: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||
| 17 | $self, | ||||||||||
| 18 | $parent, | ||||||||||
| 19 | $file, | ||||||||||
| 20 | $sub_class_map, | ||||||||||
| 21 | 7 | $split_char = undef, | |||||||||
| 22 | ) { | ||||||||||
| 23 | 7 | open( my $fh, '<', $file ); | |||||||||
| 24 | |||||||||||
| 25 | 7 | ▶ | while ( my $line = <$fh> ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | |||||||||||
| 27 | 70 | $line =~ s/\r\n$//; | |||||||||
| 28 | |||||||||||
| 29 | 70 | ▶ | my ( $type ) = $split_char | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | ? ( split( $split_char, $line ) )[ 0 ] | ||||||||||
| 31 | : substr( $line, 0, 1 ); | ||||||||||
| 32 | |||||||||||
| 33 | 70 | ▶ | next if !length( $type ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | |||||||||||
| 35 | 70 | my $sub_class = $sub_class_map->{ $type }; | |||||||||
| 36 | 70 | my $attr = decamelize( $sub_class ); | |||||||||
| 37 | 70 | my $push = "add_${attr}"; | |||||||||
| 38 | |||||||||||
| 39 | 70 | ▶ | $sub_class || croak( "Unrecognised record type ($type) at line $." ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 70 | $sub_class = "${parent}::${sub_class}"; | |||||||||
| 41 | |||||||||||
| 42 | 70 | my $Instance = $sub_class->new_from_record( $line ); | |||||||||
| 43 | |||||||||||
| 44 | 70 | $self->$push( $Instance ); | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 7 | return $self; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 8 | 1; | |||||||||