line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Table2YAML::Loader::AsciiTable; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
45415
|
use common::sense; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
4
|
1
|
|
|
1
|
|
65
|
use charnames q(:full); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
5
|
1
|
|
|
1
|
|
3767
|
use English qw[-no_match_vars]; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
13
|
|
6
|
1
|
|
|
1
|
|
2106
|
use Moo::Role; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
18
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.003'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub load_asciitable { |
11
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
|
local $INPUT_RECORD_SEPARATOR = $self->record_separator(); |
14
|
0
|
|
0
|
|
|
|
my $ref = ref $self->input() || q(); |
15
|
0
|
0
|
|
|
|
|
my $ascii_fh |
16
|
|
|
|
|
|
|
= $ref eq q(GLOB) |
17
|
|
|
|
|
|
|
? $self->input() |
18
|
|
|
|
|
|
|
: IO::File->new( $self->input(), q(r) ); |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $sep = qq(\N{VERTICAL LINE}); |
21
|
0
|
|
|
|
|
|
my @asciitable; |
22
|
0
|
|
|
|
|
|
while ( my $record = readline $ascii_fh ) { |
23
|
0
|
|
|
|
|
|
chomp $record; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $length = length $record; |
26
|
0
|
0
|
|
|
|
|
if ( index( $record, $sep ) == 0 ) { |
27
|
0
|
|
|
|
|
|
$record = substr $record, 1, $length; |
28
|
|
|
|
|
|
|
} |
29
|
0
|
0
|
|
|
|
|
if ( substr $record, -1 eq q($sep) ) { |
30
|
0
|
|
|
|
|
|
$record = substr $record, 0, $length - 2; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my @row = split m{\Q$sep\E}msx, $record; |
34
|
0
|
0
|
0
|
|
|
|
if ( @row == 1 && $row[0] =~ m{^-+(?:\+-+)*$}msx ) { |
35
|
0
|
|
|
|
|
|
next; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
foreach (@row) { |
39
|
0
|
|
|
|
|
|
s{\A\p{IsSpace}+}{}msx; |
40
|
0
|
|
|
|
|
|
s{\p{IsSpace}+\z}{}msx; |
41
|
0
|
|
|
|
|
|
s{\\vert(?:\{\})?}{|}gmsx; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
push @asciitable, [@row]; |
45
|
|
|
|
|
|
|
} ## end while ( my $record = readline...) |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return @asciitable; |
48
|
|
|
|
|
|
|
} ## end sub load_asciitable |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
1
|
|
7455
|
no Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
51
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |