blib/lib/IPC/PrettyPipe/Render/Struct.pm

filter: Statementstmt 100% 50 / 50 Branchbran 90.0% 9 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 100% 1 / 1 totaltotal 98.6% 72 / 73 CC 7 SCAR 7.5
CC
7
Cov
98%
_render_pipe
4.0
_render_cmd
3.0
_render_stream
2.1
CRAP 2.1
« blib/lib/IPC/PrettyPipe/Format.pm ↑ Summary blib/lib/IPC/PrettyPipe/Queue.pm »
1 package IPC::PrettyPipe::Render::Struct;
2  
3 # ABSTRACT: rendering a pipe as Perl structures
4  
5 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Template::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Safe::Isa;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use Types::Standard -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Type::Params qw[ validate ];
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 2 our $VERSION = '0.13';
16  
17 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34 21 ▶sub render {
Subroutine render: called CC=1 SCAR=0.0
Pod documented
35 21 my ( $self, $pipe ) = @_;
36 21 return _render_pipe( $pipe);
37 }
38  
39 23 ▶sub _render_pipe {
Subroutine _render_pipe: called CC=4 SCAR=13.9
40 23 my $pipe = shift;
41  
42 23 my @elements;
43  
44 23 for my $element ( @{ $pipe->cmds->elements } ) {
45 32 ▶ if ( $element->isa( 'IPC::PrettyPipe' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($element->isa('IPC::PrettyPipe')) { } 2 30 32
46 2 push @elements, _render_pipe( $element );
47 }
48 else {
49 30 push @elements, _render_cmd( $element );
50 }
51 }
52  
53 return {
54 elements => \@elements,
55 23 do {
56 23 my $streams = _render_streams( $pipe->streams );
57 23 ▶ @$streams ? (streams => $streams) : ();
Branch: 1 branch
BranchTrueFalseTotal
@$streams ? : 5 18 23
58 },
59 };
60 }
61  
62 30 ▶sub _render_cmd {
Subroutine _render_cmd: called CC=3 SCAR=11.0
63 30 my ( $cmd ) = @_;
64  
65 return { cmd => $cmd->cmd,
66 do {
67 30 my $args = [ map { $_->render } @{ $cmd->args->elements } ];
68 30 ▶ @$args ? ( args => $args) : ();
Branch: 1 branch
BranchTrueFalseTotal
@$args ? : 23 7 30
69 },
70  
71 30 do {
72 30 my $streams = _render_streams( $cmd->streams );
73 30 ▶ @$streams ? (streams => $streams) : ();
Branch: 1 branch
BranchTrueFalseTotal
@$streams ? : 16 14 30
74 },
75 }
76 }
77  
78 53 ▶sub _render_streams {
Subroutine _render_streams: called CC=1 SCAR=0.0
79 53 my $streams = shift;
80 53 return [ map { _render_stream( $_ ) } @{ $streams->elements } ];
81 }
82  
83 25 ▶sub _render_stream {
Subroutine _render_stream: called CC=2 SCAR=7.2
84 25 my $stream = shift;
85 25 ▶ return [ $stream->spec, $stream->has_file ? $stream->file : () ];
Branch: 1 branch
BranchTrueFalseTotal
$stream->has_file ? : 25 0 25
86 }
87  
88 2 with 'IPC::PrettyPipe::Renderer';
89  
90 2 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__
« blib/lib/IPC/PrettyPipe/Format.pm ↑ Summary blib/lib/IPC/PrettyPipe/Queue.pm »