line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::LTSV::Liner; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
42848
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
82
|
|
4
|
2
|
|
|
2
|
|
14
|
use warnings; |
|
2
|
|
|
|
|
1052
|
|
|
2
|
|
|
|
|
3265
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
4105
|
use Term::ANSIColor; |
|
2
|
|
|
|
|
25271
|
|
|
2
|
|
|
|
|
1217
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = "0.03"; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
2
|
|
|
2
|
1
|
1319
|
my $class = shift; |
12
|
2
|
|
|
|
|
6
|
my %args = @_; |
13
|
2
|
50
|
|
|
|
8
|
unless ( $args{key} ) { |
14
|
2
|
|
|
|
|
6
|
$args{all} = 1; |
15
|
|
|
|
|
|
|
} |
16
|
2
|
|
|
|
|
9
|
bless \%args, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub run { |
20
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
21
|
0
|
|
|
|
|
0
|
my $line = shift; |
22
|
0
|
|
|
|
|
0
|
chomp($line); |
23
|
0
|
|
|
|
|
0
|
print $self->parse($line) . "\n"; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub parse { |
27
|
2
|
|
|
2
|
1
|
11
|
my $self = shift; |
28
|
2
|
|
|
|
|
3
|
my $line = shift; |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
57
|
my %wants; |
31
|
2
|
50
|
|
|
|
17
|
if ( $self->{key} ) { |
32
|
0
|
|
|
|
|
0
|
%wants = map { $_ => 1 } @{ $self->{key} }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
4
|
my %stash; |
36
|
|
|
|
|
|
|
my @original; |
37
|
2
|
|
|
|
|
9
|
for my $kv ( map { [ split( /:/, $_, 2 ) ] } split( /\t/, $line ) ) { |
|
6
|
|
|
|
|
25
|
|
38
|
6
|
0
|
33
|
|
|
19
|
next if ( not $self->{all} and not $wants{ $kv->[0] } ); |
39
|
6
|
|
|
|
|
14
|
$stash{ $kv->[0] } = $kv->[1]; |
40
|
6
|
|
|
|
|
15
|
push( @original, $kv->[0] ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
7
|
my @out; |
44
|
2
|
50
|
|
|
|
10
|
my @ordered = $self->{key} ? @{ $self->{key} } : @original; |
|
0
|
|
|
|
|
0
|
|
45
|
2
|
|
|
|
|
5
|
for my $_key (@ordered) { |
46
|
6
|
|
50
|
|
|
16
|
my ( $key, $value ) = ( $_key, $stash{$_key} || q{} ); |
47
|
6
|
50
|
|
|
|
14
|
if ( not $self->{'no-color'} ) { |
48
|
0
|
|
|
|
|
0
|
$key = color('green') . $key . color('reset'); |
49
|
0
|
|
|
|
|
0
|
$value = color('magenta') . $value . color('reset'); |
50
|
|
|
|
|
|
|
} |
51
|
6
|
100
|
|
|
|
10
|
if ($self->{'no-key'}) { |
52
|
3
|
|
|
|
|
8
|
push(@out, $value); |
53
|
|
|
|
|
|
|
} else { |
54
|
3
|
|
|
|
|
9
|
push(@out, join(q{:}, $key, $value)); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
13
|
return join( "\t", @out ); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
__END__ |