line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IPC::PrettyPipe::Render::Struct; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: rendering a pipe as Perl structures |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
567
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
70
|
|
6
|
1
|
|
|
1
|
|
467
|
use Template::Tiny; |
|
1
|
|
|
|
|
1522
|
|
|
1
|
|
|
|
|
35
|
|
7
|
1
|
|
|
1
|
|
7
|
use Safe::Isa; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
143
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
7
|
use Types::Standard -all; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
16
|
|
10
|
1
|
|
|
1
|
|
51461
|
use Type::Params qw[ validate ]; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
12
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
299
|
use Moo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
12
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
781
|
use namespace::clean; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
11
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub render { |
35
|
21
|
|
|
21
|
1
|
256
|
my ( $self, $pipe ) = @_; |
36
|
21
|
|
|
|
|
79
|
return _render_pipe( $pipe); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _render_pipe { |
40
|
23
|
|
|
23
|
|
46
|
my $pipe = shift; |
41
|
|
|
|
|
|
|
|
42
|
23
|
|
|
|
|
47
|
my @elements; |
43
|
|
|
|
|
|
|
|
44
|
23
|
|
|
|
|
49
|
for my $element ( @{ $pipe->cmds->elements } ) { |
|
23
|
|
|
|
|
123
|
|
45
|
32
|
100
|
|
|
|
193
|
if ( $element->isa( 'IPC::PrettyPipe' ) ) { |
46
|
2
|
|
|
|
|
11
|
push @elements, _render_pipe( $element ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
30
|
|
|
|
|
84
|
push @elements, _render_cmd( $element ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
return { |
54
|
|
|
|
|
|
|
elements => \@elements, |
55
|
23
|
|
|
|
|
70
|
do { |
56
|
23
|
|
|
|
|
438
|
my $streams = _render_streams( $pipe->streams ); |
57
|
23
|
100
|
|
|
|
183
|
@$streams ? (streams => $streams) : (); |
58
|
|
|
|
|
|
|
}, |
59
|
|
|
|
|
|
|
}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _render_cmd { |
63
|
30
|
|
|
30
|
|
77
|
my ( $cmd ) = @_; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
return { cmd => $cmd->cmd, |
66
|
|
|
|
|
|
|
do { |
67
|
30
|
|
|
|
|
59
|
my $args = [ map { $_->render } @{ $cmd->args->elements } ]; |
|
25
|
|
|
|
|
153
|
|
|
30
|
|
|
|
|
128
|
|
68
|
30
|
100
|
|
|
|
126
|
@$args ? ( args => $args) : (); |
69
|
|
|
|
|
|
|
}, |
70
|
|
|
|
|
|
|
|
71
|
30
|
|
|
|
|
97
|
do { |
72
|
30
|
|
|
|
|
111
|
my $streams = _render_streams( $cmd->streams ); |
73
|
30
|
100
|
|
|
|
279
|
@$streams ? (streams => $streams) : (); |
74
|
|
|
|
|
|
|
}, |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _render_streams { |
79
|
53
|
|
|
53
|
|
125
|
my $streams = shift; |
80
|
53
|
|
|
|
|
86
|
return [ map { _render_stream( $_ ) } @{ $streams->elements } ]; |
|
25
|
|
|
|
|
80
|
|
|
53
|
|
|
|
|
140
|
|
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub _render_stream { |
84
|
25
|
|
|
25
|
|
101
|
my $stream = shift; |
85
|
25
|
50
|
|
|
|
524
|
return [ $stream->spec, $stream->has_file ? $stream->file : () ]; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
with 'IPC::PrettyPipe::Renderer'; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# |
93
|
|
|
|
|
|
|
# This file is part of IPC-PrettyPipe |
94
|
|
|
|
|
|
|
# |
95
|
|
|
|
|
|
|
# This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory. |
96
|
|
|
|
|
|
|
# |
97
|
|
|
|
|
|
|
# This is free software, licensed under: |
98
|
|
|
|
|
|
|
# |
99
|
|
|
|
|
|
|
# The GNU General Public License, Version 3, June 2007 |
100
|
|
|
|
|
|
|
# |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |