blib/lib/IPC/PrettyPipe/DSL.pm

filter: Statementstmt 97.1% 67 / 69 Branchbran 70.0% 14 / 20 Conditioncond 100% 9 / 9 MC/DCmcdc 100% 6 / 6 Subroutinesub 100% 16 / 16 Podpod 100% 6 / 6 totaltotal 93.6% 118 / 126 CC 14 SCAR 12.5
CC
14
Cov
92%
pparg
7.0
ppstream
5.6
ppcmd
3.0
CRAP 3.5
« blib/lib/IPC/PrettyPipe/Execute/IPC/Run.pm ↑ Summary blib/lib/IPC/PrettyPipe/Render/Template/Tiny.pm »
1 package IPC::PrettyPipe::DSL;
2  
3 # ABSTRACT: shortcuts to building an B<IPC::PrettyPipe> object
4  
5 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 11 our $VERSION = '0.13';
9  
10 11 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 11 our @CARP_NOT;
12  
13 11 ▶use List::MoreUtils qw[ zip ];
Subroutine BEGIN: called CC=1 SCAR=0.0
14 11 ▶use Safe::Isa;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 11 ▶use IPC::PrettyPipe;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 11 ▶use IPC::PrettyPipe::Cmd;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 11 ▶use IPC::PrettyPipe::Arg;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 11 ▶use IPC::PrettyPipe::Stream;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 11 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 11 our %EXPORT_TAGS = (
24 construct => [qw( ppipe ppcmd pparg ppstream )],
25 attributes => [qw( argpfx argsep )],
26 );
27  
28 ## no critic (ProhibitSubroutinePrototypes)
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39 9 ▶sub argsep($) { IPC::PrettyPipe::Arg::Format->new( sep => @_ ) }
Subroutine argsep: called CC=1 SCAR=0.0
Pod documented
40 21 ▶sub argpfx($) { IPC::PrettyPipe::Arg::Format->new( pfx => @_ ) }
Subroutine argpfx: called CC=1 SCAR=0.0
Pod documented
41  
42  
43 11 our @EXPORT_OK = map { @{$_} } values %EXPORT_TAGS;
44 11 $EXPORT_TAGS{all} = \@EXPORT_OK;
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71 5 ▶sub pparg {
Subroutine pparg: called CC=7 SCAR=19.5
Pod documented
72  
73 5 my $fmt = IPC::PrettyPipe::Arg::Format->new;
74  
75 5 ▶ while ( @_ && $_[0]->$_isa( 'IPC::PrettyPipe::Arg::Format' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and $_[0]->$IPC::PrettyPipe::DSL::_isa("IPC::PrettyPipe::Arg::Format")) 3 5 8
Condition100%3/3
@_ and $_[0]->$IPC::PrettyPipe::DSL::_isa("IPC::PrettyPipe::Arg::Format")
!ll&&!rl&&r
143
MC/DC100%2/2
@_ and $_[0]->$IPC::PrettyPipe::DSL::_isa("IPC::PrettyPipe::Arg::Format")
@_ $_[0]->$IPC::PrettyPipe::DSL::_isa("IPC::PrettyPipe::Arg::Format")
Truth table100%3/3
A and B
A= @_B= $_[0]->$IPC::PrettyPipe::DSL::_isa("IPC::PrettyPipe::Arg::Format")
ABresult
0X0
100
111
76  
77 3 shift()->copy_into( $fmt );
78 }
79  
80 5 my @arg = @_;
81  
82 5 ▶ if ( @arg == 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@arg == 1) { } 1 4 5
elsif (@arg == 2) { } 3 1 4
83  
84 1 ▶ unless ( 'HASH' eq ref $arg[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("HASH" eq ref $arg[0]) 1 0 1
85  
86 1 unshift @arg, 'name';
87  
88 }
89 }
90  
91 elsif ( @arg == 2 ) {
92  
93 3 @arg = zip @{ [ 'name', 'value' ] }, @arg;
94  
95 }
96  
97 5 ▶ return IPC::PrettyPipe::Arg->new( @arg,
Branch: 1 branch
BranchTrueFalseTotal
@arg == 1 ? : 0 5 5
98 ( @arg == 1 ? () : ( fmt => $fmt->clone ) ) );
99  
100 }
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124 2 ▶sub ppstream {
Subroutine ppstream: called CC=4 SCAR=17.2
Pod documented
125  
126 2 my @stream = @_;
127  
128 2 ▶ if ( @stream == 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@stream == 1) { } 0 2 2
elsif (@stream == 2) { } 2 0 2
129  
130 0 ▶ unless ( 'HASH' eq ref $stream[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("HASH" eq ref $stream[0]) 0 0 0
131  
132 0 unshift @stream, 'spec';
133  
134 }
135 }
136  
137 elsif ( @stream == 2 ) {
138  
139 2 @stream = zip @{ [ 'spec', 'file' ] }, @stream;
140  
141 }
142  
143 2 return IPC::PrettyPipe::Stream->new( @stream );
144 }
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211 19 ▶sub ppcmd {
Subroutine ppcmd: called CC=3 SCAR=11.0
Pod documented
212  
213 19 my $argfmt = IPC::PrettyPipe::Arg::Format->new;
214  
215 19 ▶ while ( @_ && $_[0]->$_isa( 'IPC::PrettyPipe::Arg::Format' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and $_[0]->$IPC::PrettyPipe::DSL::_isa("IPC::PrettyPipe::Arg::Format")) 4 19 23
Condition100%3/3
@_ and $_[0]->$IPC::PrettyPipe::DSL::_isa("IPC::PrettyPipe::Arg::Format")
!ll&&!rl&&r
1184
MC/DC100%2/2
@_ and $_[0]->$IPC::PrettyPipe::DSL::_isa("IPC::PrettyPipe::Arg::Format")
@_ $_[0]->$IPC::PrettyPipe::DSL::_isa("IPC::PrettyPipe::Arg::Format")
Truth table100%3/3
A and B
A= @_B= $_[0]->$IPC::PrettyPipe::DSL::_isa("IPC::PrettyPipe::Arg::Format")
ABresult
0X0
100
111
216  
217 4 shift->copy_into( $argfmt );
218 }
219  
220 19 my $cmd = IPC::PrettyPipe::Cmd->new( cmd => shift, argfmt => $argfmt );
221  
222 18 $cmd->ffadd( @_ );
223  
224 18 return $cmd;
225 }
226  
227  
228  
229  
230  
231  
232  
233  
234  
235  
236  
237  
238  
239  
240  
241  
242  
243  
244  
245  
246  
247  
248  
249  
250  
251  
252  
253  
254  
255  
256  
257  
258  
259  
260  
261  
262  
263  
264  
265  
266  
267  
268  
269  
270  
271  
272  
273  
274  
275  
276  
277  
278  
279  
280  
281  
282  
283  
284  
285  
286  
287  
288  
289  
290  
291  
292  
293  
294  
295  
296  
297  
298  
299  
300  
301  
302  
303  
304  
305  
306  
307  
308  
309  
310  
311  
312  
313  
314  
315  
316  
317  
318  
319  
320  
321  
322  
323  
324  
325  
326  
327  
328  
329  
330  
331  
332  
333  
334  
335  
336  
337  
338  
339  
340  
341  
342  
343  
344  
345  
346  
347  
348 90 ▶sub ppipe {
Subroutine ppipe: called CC=3 SCAR=11.0
Pod documented
349  
350 90 my $argfmt = IPC::PrettyPipe::Arg::Format->new;
351  
352 90 ▶ while ( @_ && $_[0]->$_isa( 'IPC::PrettyPipe::Arg::Format' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and $_[0]->$IPC::PrettyPipe::DSL::_isa("IPC::PrettyPipe::Arg::Format")) 6 90 96
Condition100%3/3
@_ and $_[0]->$IPC::PrettyPipe::DSL::_isa("IPC::PrettyPipe::Arg::Format")
!ll&&!rl&&r
1896
MC/DC100%2/2
@_ and $_[0]->$IPC::PrettyPipe::DSL::_isa("IPC::PrettyPipe::Arg::Format")
@_ $_[0]->$IPC::PrettyPipe::DSL::_isa("IPC::PrettyPipe::Arg::Format")
Truth table100%3/3
A and B
A= @_B= $_[0]->$IPC::PrettyPipe::DSL::_isa("IPC::PrettyPipe::Arg::Format")
ABresult
0X0
100
111
353  
354 6 shift->copy_into( $argfmt );
355 }
356  
357 90 my $pipe = IPC::PrettyPipe->new( argfmt => $argfmt );
358  
359 90 $pipe->ffadd( @_ );
360  
361 90 return $pipe;
362 }
363  
364  
365 11 1;
366  
367 #
368 # This file is part of IPC-PrettyPipe
369 #
370 # This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory.
371 #
372 # This is free software, licensed under:
373 #
374 # The GNU General Public License, Version 3, June 2007
375 #
376  
377 __END__
« blib/lib/IPC/PrettyPipe/Execute/IPC/Run.pm ↑ Summary blib/lib/IPC/PrettyPipe/Render/Template/Tiny.pm »