blib/lib/Zuzu/Module/IO.pm

filter: Statementstmt 50.3% 225 / 447 Branchbran 29.7% 41 / 138 Conditioncond 33.3% 16 / 48 MC/DCmcdc 14.8% 4 / 27 Subroutinesub 45.4% 40 / 88 Podpod 0.0% 0 / 1 totaltotal 43.5% 326 / 749 CC 95 SCAR 23.2
CC
95
Cov
45%
_glob_flags_from_options
42.0
__ANON__
42.0
__ANON__
30.0
CRAP 10.1
« blib/lib/Zuzu/Module/Eval.pm ↑ Summary lib/Zuzu/Tidy/CLI.pm »
1 package Zuzu::Module::IO;
2  
3 61 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 61 our $VERSION = '0.007000';
6  
7 61 ▶use Encode qw( decode_utf8 );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 61 ▶use Errno qw( EEXIST );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 61 ▶use File::Glob qw( bsd_glob GLOB_NOCHECK GLOB_QUOTE GLOB_BRACE GLOB_TILDE GLOB_NOCASE );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 61 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 61 use Path::Tiny qw(
12 cwd
13 path
14 rootdir
15 tempdir
16 tempfile
17 61 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 61 ▶use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 61 use Zuzu::Util::NativeHelpers qw(
21 native_class
22 native_function
23 native_functions
24 native_object
25 perl_to_zuzu
26 zuzu_bool
27 zuzu_to_perl
28 61 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
29 61 ▶use Zuzu::Value::BinaryString;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 61 ▶use Zuzu::Value::Function;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 61 ▶use Zuzu::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 sub _bool {
34 2 ▶ my ( $value ) = @_;
Subroutine _bool: called CC=2 SCAR=7.2
35  
36 2 ▶ return $value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 2 0 2
37 }
38  
39 sub _raw_mode {
40 5 ▶ my ( $value ) = @_;
Subroutine _raw_mode: called CC=2 SCAR=7.2
41  
42 5 ▶ return zuzu_bool( $value, 0 ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
zuzu_bool($value, 0) ? : 0 5 5
43 }
44  
45 sub _to_path_tiny {
46 23 ▶ my ( $obj ) = @_;
Subroutine _to_path_tiny: called CC=5 SCAR=22.7
47  
48 23 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($obj) and $obj->isa("Zuzu::Value::Object") and exists $obj->slots->{"_path_tiny"}) 23 0 23
Condition33%2/6
builtin::blessed($obj) and $obj->isa("Zuzu::Value::Object") and exists $obj->slots->{"_path_tiny"}
!ll&&!rl&&r
0023
builtin::blessed($obj) and $obj->isa("Zuzu::Value::Object")
!ll&&!rl&&r
0023
MC/DC0%0/3
builtin::blessed($obj) and $obj->isa("Zuzu::Value::Object") and exists $obj->slots->{"_path_tiny"}
builtin::blessed($obj) $obj->isa("Zuzu::Value::Object") exists $obj->slots->{"_path_tiny"}
Truth table25%1/4
A and B and C
A= builtin::blessed($obj)B= $obj->isa("Zuzu::Value::Object")C= exists $obj->slots->{"_path_tiny"}
ABCresult
0XX0
10X0
1100
1111
49 blessed($obj)
50 and $obj->isa('Zuzu::Value::Object')
51 and exists $obj->slots->{_path_tiny}
52 ) {
53 23 return $obj->slots->{_path_tiny};
54 }
55  
56 0 ▶ return path( defined $obj ? "$obj" : '' );
Branch: 1 branch
BranchTrueFalseTotal
defined $obj ? : 0 0 0
57 }
58  
59 sub _has_named_temp_option {
60 9 ▶ my ( $args, $name ) = @_;
Subroutine _has_named_temp_option: called CC=4 SCAR=19.7
61  
62 9 ▶ for ( my $i = 0; $i < @{$args} - 1; $i += 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$args;} - 1) 0 9 9
63 0 ▶ next if ref $args->[$i];
Branch: 1 branch
BranchTrueFalseTotal
if ref $args->[$i] 0 0 0
64 0 ▶ return 1 if uc( $args->[$i] ) eq $name;
Branch: 1 branch
BranchTrueFalseTotal
if uc $args->[$i] eq $name 0 0 0
65 }
66  
67 9 return 0;
68 }
69  
70 sub _new_path_object {
71 1310 ▶ my ( $class_obj, $path_obj, $demolish_hook ) = @_;
Subroutine _new_path_object: called CC=2 SCAR=6.9
72  
73 1310 my $object = native_object(
74 class => $class_obj,
75 slots => {
76 _path_tiny => $path_obj,
77 _line_cursor => undef,
78 _line_done => 0,
79 _line_mode => undef,
80 },
81 const => {
82 _path_tiny => 1,
83 _line_cursor => 0,
84 _line_done => 0,
85 _line_mode => 0,
86 },
87 );
88 1310 ▶ $object->demolish_hook($demolish_hook)
Branch: 1 branch
BranchTrueFalseTotal
if ref $demolish_hook eq "CODE" 9 1301 1310
89 if ref($demolish_hook) eq 'CODE';
90  
91 1310 return $object;
92 }
93  
94 sub _temp_path_cleanup {
95 9 ▶ my ( $path_obj, $recursive ) = @_;
Subroutine _temp_path_cleanup: called CC=1 SCAR=0.1
96  
97 return sub {
98 3 ▶ local $@;
Subroutine __ANON__: called CC=2 SCAR=7.1
99 3 eval {
100 3 ▶ if ($recursive) {
Branch: 1 branch
BranchTrueFalseTotal
if ($recursive) { } 0 3 3
101 0 $path_obj->remove_tree({ safe => 0 });
102 }
103 else {
104 3 $path_obj->remove;
105 }
106 3 1;
107 };
108 3 return;
109 9 };
110 }
111  
112 sub _new_path_array {
113 0 ▶ my ( $class_obj, $paths ) = @_;
Subroutine _new_path_array: not called CC=1 SCAR=6.9
114  
115 my @wrapped = map {
116 0 _new_path_object( $class_obj, $_ )
117 0 } @{ $paths };
118  
119 0 return perl_to_zuzu( \@wrapped );
120 }
121  
122 sub _stat_to_dict {
123 0 ▶ my ( $st ) = @_;
Subroutine _stat_to_dict: not called CC=2 SCAR=17.9
124  
125 0 ▶ return undef if not defined $st;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $st 0 0 0
126  
127 0 my %fields = (
128 dev => $st->dev,
129 ino => $st->ino,
130 mode => $st->mode,
131 nlink => $st->nlink,
132 uid => $st->uid,
133 gid => $st->gid,
134 rdev => $st->rdev,
135 size => $st->size,
136 atime => $st->atime,
137 mtime => $st->mtime,
138 ctime => $st->ctime,
139 blksize => $st->blksize,
140 blocks => $st->blocks,
141 );
142  
143 0 return perl_to_zuzu( \%fields );
144 }
145  
146 sub _call_callback {
147 2 ▶ my ( $runtime, $callback, $args ) = @_;
Subroutine _call_callback: called CC=3 SCAR=12.0
148  
149 2 ▶ return if not blessed($callback)
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($callback) and $callback->isa("Zuzu::Value::Function") 0 2 2
Condition33%1/3
builtin::blessed($callback) and $callback->isa("Zuzu::Value::Function")
!ll&&!rl&&r
002
MC/DC0%0/2
builtin::blessed($callback) and $callback->isa("Zuzu::Value::Function")
builtin::blessed($callback) $callback->isa("Zuzu::Value::Function")
Truth table33%1/3
A and B
A= builtin::blessed($callback)B= $callback->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
150 or not $callback->isa('Zuzu::Value::Function');
151  
152 2 $runtime->_call_function( $callback, $args, '<std/io>', 0 );
153  
154 2 return;
155 }
156  
157 sub _decode_if_utf8 {
158 0 ▶ my ( $line, $raw ) = @_;
Subroutine _decode_if_utf8: not called CC=2 SCAR=17.9
159  
160 0 ▶ return $line if $raw;
Branch: 1 branch
BranchTrueFalseTotal
if $raw 0 0 0
161 0 return decode_utf8( $line, 1 );
162 }
163  
164 sub _type_name {
165 2 ▶ my ( $value ) = @_;
Subroutine _type_name: called CC=4 SCAR=14.1
166  
167 2 ▶ return 'Null' if not defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 2 2
168 2 ▶ return 'BinaryString'
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString") 1 1 2
Condition66%2/3
builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
101
MC/DC50%1/2
builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString")
builtin::blessed($value) $value->isa("Zuzu::Value::BinaryString")
Truth table66%2/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
169 if blessed($value) and $value->isa('Zuzu::Value::BinaryString');
170 1 return 'String';
171 }
172  
173 sub _assert_binary_string {
174 3 ▶ my ( $value, $label ) = @_;
Subroutine _assert_binary_string: called CC=3 SCAR=11.0
175  
176 3 ▶ return if blessed($value) and $value->isa('Zuzu::Value::BinaryString');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString") 2 1 3
Condition66%2/3
builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
102
MC/DC50%1/2
builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString")
builtin::blessed($value) $value->isa("Zuzu::Value::BinaryString")
Truth table66%2/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
177  
178 1 my $type = _type_name( $value );
179 1 die Zuzu::Error->new_runtime(
180 message => "TypeException: $label expects BinaryString, got $type",
181 file => '<std/io>',
182 line => 0,
183 );
184 }
185  
186 sub _assert_text_string {
187 6 ▶ my ( $value, $label ) = @_;
Subroutine _assert_text_string: called CC=3 SCAR=11.0
188  
189 6 ▶ return if not blessed($value);
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) 5 1 6
190 1 ▶ return if not $value->isa('Zuzu::Value::BinaryString');
Branch: 1 branch
BranchTrueFalseTotal
unless $value->isa("Zuzu::Value::BinaryString") 0 1 1
191  
192 1 my $type = _type_name( $value );
193 1 die Zuzu::Error->new_runtime(
194 message => "TypeException: $label expects String, got $type",
195 file => '<std/io>',
196 line => 0,
197 );
198 }
199  
200 sub _async_task {
201 2 ▶ my ( $runtime, $name, $work, $wrap ) = @_;
Subroutine _async_task: called CC=1 SCAR=0.0
202  
203 2 my $worker = $runtime->_new_task(
204 name => "$name.worker",
205 start => 1,
206 schedule => 1,
207 thunk => $work,
208 );
209 return $runtime->_new_task(
210 name => $name,
211 schedule => 1,
212 thunk => sub {
213 2 ▶ my $value = $worker->await;
Subroutine __ANON__: called CC=2 SCAR=7.2
214 2 ▶ return defined $wrap ? $wrap->($value) : $value;
Branch: 1 branch
BranchTrueFalseTotal
defined $wrap ? : 0 2 2
215 },
216 2 );
217 }
218  
219 sub _warn_blocking_operation {
220 19 ▶ my ( $runtime, $operation ) = @_;
Subroutine _warn_blocking_operation: called CC=2 SCAR=7.1
221  
222 19 ▶ $runtime->_warn_blocking_operation($operation)
Branch: 1 branch
BranchTrueFalseTotal
if $runtime->can("_warn_blocking_operation") 19 0 19
223 if $runtime->can('_warn_blocking_operation');
224  
225 19 return;
226 }
227  
228 sub _glob_flags_from_options {
229 0 ▶ my ( $options ) = @_;
Subroutine _glob_flags_from_options: not called CC=6 SCAR=37.4
230  
231 0 ▶ return GLOB_NOCHECK | GLOB_QUOTE if ref($options) ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $options ne "HASH" 0 0 0
232  
233 0 my $flags = GLOB_QUOTE;
234 0 ▶ if ( zuzu_bool( $options->{nocheck}, 1 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (zuzu_bool($options->{"nocheck"}, 1)) 0 0 0
235 0 $flags |= GLOB_NOCHECK;
236 }
237 0 ▶ if ( zuzu_bool( $options->{brace}, 1 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (zuzu_bool($options->{"brace"}, 1)) 0 0 0
238 0 $flags |= GLOB_BRACE;
239 }
240 0 ▶ if ( zuzu_bool( $options->{tilde}, 1 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (zuzu_bool($options->{"tilde"}, 1)) 0 0 0
241 0 $flags |= GLOB_TILDE;
242 }
243 0 ▶ if ( zuzu_bool( $options->{nocase}, 0 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (zuzu_bool($options->{"nocase"}, 0)) 0 0 0
244 0 $flags |= GLOB_NOCASE;
245 }
246  
247 0 return $flags;
248 }
249  
250 sub _normalize_join_parts {
251 0 ▶ my ( $parts ) = @_;
Subroutine _normalize_join_parts: not called CC=4 SCAR=30.0
252  
253 0 my @out;
254 0 ▶ if ( ref($parts) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $parts eq 'ARRAY') { } 0 0 0
255 0 ▶ @out = map { defined $_ ? "$_" : '' } @{ $parts };
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
256 }
257 else {
258 0 ▶ @out = ( defined $parts ? "$parts" : '' );
Branch: 1 branch
BranchTrueFalseTotal
defined $parts ? : 0 0 0
259 }
260  
261 0 return @out;
262 }
263  
264 sub IMPORT {
265 481 ▶ my ( $class, $runtime ) = @_;
Subroutine IMPORT: called CC=9 SCAR=33.1
Pod undocumented
266  
267 481 my $path_class = native_class(
268 name => 'Path',
269 );
270 481 my $path_iterator_class = native_class(
271 name => 'PathIterator',
272 );
273 481 my $stdin_class = native_class(
274 name => 'STDINHandle',
275 );
276 481 my $stdout_class = native_class(
277 name => 'STDOUTHandle',
278 );
279 481 my $stderr_class = native_class(
280 name => 'STDERRHandle',
281 );
282  
283 $path_class->native_constructor( sub {
284 1299 ▶ my ( $rt, $klass, $positional, $named ) = @_;
Subroutine __ANON__: called CC=5 SCAR=16.7
285 1299 ▶ my $raw = @{ $positional // [] }
Branch: 1 branch
BranchTrueFalseTotal
exists $named->{'path'} ? : 2 0 2
Condition50%1/2
$positional // []
l!l
12990
MC/DC0%0/1
$positional // []
$positional
Truth table50%1/2
A
A= $positional
Aresult
11
00
286 ? $positional->[0]
287 1299 ▶ : exists $named->{path} ? $named->{path} : '';
Branch: 1 branch
BranchTrueFalseTotal
@{$positional // [];} ? : 1297 2 1299
288 1299 ▶ my $p = path( defined $raw ? "$raw" : '' );
Branch: 1 branch
BranchTrueFalseTotal
defined $raw ? : 1299 0 1299
289  
290 1299 return _new_path_object( $klass, $p );
291 481 } );
292  
293 my $simple_path_methods = native_functions(
294 names => [
295 qw(
296 basename
297 canonpath
298 is_absolute
299 is_relative
300 is_rootdir
301 realpath
302 subsumes
303 volume
304 exists
305 is_file
306 is_dir
307 size
308 size_human
309 touch
310 touchpath
311 )
312 ],
313 builder => sub {
314 7215 ▶ my ( $name ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.9
315 return sub {
316 3 ▶ my ( $self, @args ) = @_;
Subroutine __ANON__: called CC=8 SCAR=27.2
317 3 my $p = _to_path_tiny( $self );
318 3 ▶ if ( $name eq 'subsumes' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "subsumes") 0 3 3
319 0 ▶ my $other = @args ? _to_path_tiny( $args[0] ) : path('');
Branch: 1 branch
BranchTrueFalseTotal
@args ? : 0 0 0
320 0 return _bool( $p->subsumes( $other ) );
321 }
322 3 ▶ if ( $name eq 'touch' or $name eq 'touchpath' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "touch" or $name eq "touchpath") 0 3 3
Condition33%1/3
$name eq "touch" or $name eq "touchpath"
l!l&&r!l&&!r
003
MC/DC0%0/2
$name eq "touch" or $name eq "touchpath"
$name eq "touch" $name eq "touchpath"
Truth table33%1/3
A or B
A= $name eq "touch"B= $name eq "touchpath"
ABresult
1X1
011
000
323 0 my $out = $p->$name();
324 0 return _new_path_object( $path_class, $out );
325 }
326 3 my $value = $p->$name();
327 3 ▶ if ( $name =~ /\A(?:is_absolute|is_relative|is_rootdir|exists|is_file|is_dir)\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /\A(?:is_absolute|is_relative|is_rootdir|exists|is_file|is_dir)\z/) 2 1 3
328 2 return _bool( $value );
329 }
330 1 ▶ if ( $name eq 'realpath' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "realpath") 0 1 1
331 0 ▶ return defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value ? : 0 0 0
332 ? _new_path_object( $path_class, $value )
333 : undef;
334 }
335  
336 1 return $value;
337 7215 };
338 },
339 481 );
340  
341 $path_class->methods->{$_} = $simple_path_methods->{$_}
342 481 for CORE::keys %{ $simple_path_methods };
343  
344 481 for my $name ( qw( absolute child parent sibling ) ) {
345 $path_class->methods->{$name} = native_function(
346 name => $name,
347 native => sub {
348 0 ▶ my ( $self, @args ) = @_;
Subroutine __ANON__: not called CC=5 SCAR=34.0
349 0 my $p = _to_path_tiny( $self );
350 my @mapped = map {
351 0 ▶ if ( blessed($_) and $_->isa('Zuzu::Value::Object') and exists $_->slots->{_path_tiny} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($_) and $_->isa('Zuzu::Value::Object') and exists $_->slots->{'_path_tiny'}) { } 0 0 0
Condition0%0/6
builtin::blessed($_) and $_->isa("Zuzu::Value::Object") and exists $_->slots->{"_path_tiny"}
!ll&&!rl&&r
000
builtin::blessed($_) and $_->isa("Zuzu::Value::Object")
!ll&&!rl&&r
000
MC/DC0%0/3
builtin::blessed($_) and $_->isa("Zuzu::Value::Object") and exists $_->slots->{"_path_tiny"}
builtin::blessed($_) $_->isa("Zuzu::Value::Object") exists $_->slots->{"_path_tiny"}
Truth table0%0/4
A and B and C
A= builtin::blessed($_)B= $_->isa("Zuzu::Value::Object")C= exists $_->slots->{"_path_tiny"}
ABCresult
0XX0
10X0
1100
1111
352 0 $_->slots->{_path_tiny};
353 }
354 else {
355 0 ▶ defined $_ ? "$_" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
356 }
357 } @args;
358 0 my $new = $p->$name( @mapped );
359 0 return _new_path_object( $path_class, $new );
360 },
361 1924 );
362 }
363  
364 $path_class->methods->{to_String} = native_function(
365 name => 'to_String',
366 native => sub {
367 2 ▶ my ( $self ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
368 2 my $p = _to_path_tiny( $self );
369 2 return $p->stringify;
370 },
371 481 );
372  
373 $path_class->methods->{copy} = native_function(
374 name => 'copy',
375 native => sub {
376 0 ▶ my ( $self, $to, @rest ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
377 0 my $p = _to_path_tiny( $self );
378 0 my $target = _to_path_tiny( $to );
379 0 my $out = $p->copy( $target, @rest );
380 0 return _new_path_object( $path_class, $out );
381 },
382 481 );
383  
384 481 for my $name ( qw( move remove mkdir remove_tree ) ) {
385 $path_class->methods->{$name} = native_function(
386 name => $name,
387 native => sub {
388 0 ▶ my ( $self, @args ) = @_;
Subroutine __ANON__: not called CC=4 SCAR=30.0
389 0 my $p = _to_path_tiny( $self );
390 my @mapped = map {
391 0 ▶ if ( blessed($_) and $_->isa('Zuzu::Value::Object') and exists $_->slots->{_path_tiny} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($_) and $_->isa('Zuzu::Value::Object') and exists $_->slots->{'_path_tiny'}) { } 0 0 0
Condition0%0/6
builtin::blessed($_) and $_->isa("Zuzu::Value::Object") and exists $_->slots->{"_path_tiny"}
!ll&&!rl&&r
000
builtin::blessed($_) and $_->isa("Zuzu::Value::Object")
!ll&&!rl&&r
000
MC/DC0%0/3
builtin::blessed($_) and $_->isa("Zuzu::Value::Object") and exists $_->slots->{"_path_tiny"}
builtin::blessed($_) $_->isa("Zuzu::Value::Object") exists $_->slots->{"_path_tiny"}
Truth table0%0/4
A and B and C
A= builtin::blessed($_)B= $_->isa("Zuzu::Value::Object")C= exists $_->slots->{"_path_tiny"}
ABCresult
0XX0
10X0
1100
1111
392 0 $_->slots->{_path_tiny};
393 }
394 else {
395 0 $_;
396 }
397 } @args;
398 0 return $p->$name( @mapped );
399 },
400 1924 );
401 }
402  
403 $path_class->methods->{mkdir_exclusive} = native_function(
404 name => 'mkdir_exclusive',
405 native => sub {
406 0 ▶ my ( $self ) = @_;
Subroutine __ANON__: not called CC=3 SCAR=24.8
407 0 my $p = _to_path_tiny( $self );
408 0 ▶ if ( mkdir $p->stringify ) {
Branch: 1 branch
BranchTrueFalseTotal
if (mkdir $p->stringify) 0 0 0
409 0 return 1;
410 }
411 0 ▶ return 0 if $! == EEXIST;
Branch: 1 branch
BranchTrueFalseTotal
if $! == 17 0 0 0
412 0 die "IOError: mkdir_exclusive failed for $p: $!";
413 },
414 481 );
415  
416 $path_class->methods->{chmod} = native_function(
417 name => 'chmod',
418 native => sub {
419 0 ▶ my ( $self, $mode ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
420 0 my $p = _to_path_tiny( $self );
421 0 return $p->chmod( $mode );
422 },
423 481 );
424  
425 481 for my $name ( qw( spew append ) ) {
426 $path_class->methods->{$name} = native_function(
427 name => $name,
428 native => sub {
429 3 ▶ my ( $self, @args ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
430 3 _warn_blocking_operation( $runtime, "std/io Path.$name" );
431 3 my $p = _to_path_tiny( $self );
432 3 my $label = "Path.$name";
433 3 _assert_binary_string( $args[0], $label );
434 2 my $bytes = $args[0]->bytes;
435 2 return $p->$name( $bytes );
436 },
437 962 );
438 }
439  
440 481 for my $name ( qw( spew_utf8 append_utf8 ) ) {
441 $path_class->methods->{$name} = native_function(
442 name => $name,
443 native => sub {
444 6 ▶ my ( $self, @args ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
445 6 _warn_blocking_operation( $runtime, "std/io Path.$name" );
446 6 my $p = _to_path_tiny( $self );
447 6 my $label = "Path.$name";
448 6 _assert_text_string( $args[0], $label );
449 5 return $p->$name( @args );
450 },
451 962 );
452 }
453  
454 $path_class->methods->{slurp} = native_function(
455 name => 'slurp',
456 native => sub {
457 2 ▶ my ( $self ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
458 2 _warn_blocking_operation( $runtime, 'std/io Path.slurp' );
459 2 my $p = _to_path_tiny( $self );
460 2 my $bytes = $p->slurp();
461 2 return Zuzu::Value::BinaryString->new( bytes => $bytes );
462 },
463 481 );
464  
465 $path_class->methods->{slurp_utf8} = native_function(
466 name => 'slurp_utf8',
467 native => sub {
468 3 ▶ my ( $self ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
469 3 _warn_blocking_operation( $runtime, 'std/io Path.slurp_utf8' );
470 3 my $p = _to_path_tiny( $self );
471 # Lax decode (like readline_utf8): valid UTF-8 sequences for
472 # noncharacters such as U+10FFFE must round-trip, matching
473 # zuzu-rust and zuzu-js; strict :encoding(UTF-8) refuses them.
474 3 return decode_utf8( $p->slurp_raw(), 1 );
475 },
476 481 );
477  
478 $path_class->methods->{slurp_async} = native_function(
479 name => 'slurp_async',
480 native => sub {
481 0 ▶ my ( $self ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
482 0 my $p = _to_path_tiny( $self );
483 return _async_task(
484 $runtime,
485 'path.slurp_async',
486 sub {
487 0 ▶ return $p->slurp();
Subroutine __ANON__: not called CC=1 SCAR=6.9
488 },
489 sub {
490 0 ▶ my ( $bytes ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
491 0 return Zuzu::Value::BinaryString->new( bytes => $bytes );
492 },
493 0 );
494 },
495 481 );
496  
497 $path_class->methods->{slurp_utf8_async} = native_function(
498 name => 'slurp_utf8_async',
499 native => sub {
500 2 ▶ my ( $self ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.2
501 2 my $p = _to_path_tiny( $self );
502 return _async_task(
503 $runtime,
504 'path.slurp_utf8_async',
505 sub {
506 0 ▶ return decode_utf8( $p->slurp_raw(), 1 );
Subroutine __ANON__: not called CC=1 SCAR=6.9
507 },
508 2 );
509 },
510 481 );
511  
512 $path_class->methods->{lines} = native_function(
513 name => 'lines',
514 native => sub {
515 0 ▶ my ( $self ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
516 0 _warn_blocking_operation( $runtime, 'std/io Path.lines' );
517 0 my $p = _to_path_tiny( $self );
518 0 my @lines = $p->lines();
519 my @wrapped = map {
520 0 Zuzu::Value::BinaryString->new( bytes => $_ );
521 } @lines;
522 0 return perl_to_zuzu( \@wrapped );
523 },
524 481 );
525  
526 $path_class->methods->{lines_utf8} = native_function(
527 name => 'lines_utf8',
528 native => sub {
529 0 ▶ my ( $self ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
530 0 _warn_blocking_operation( $runtime, 'std/io Path.lines_utf8' );
531 0 my $p = _to_path_tiny( $self );
532 0 my @lines = map { decode_utf8( $_, 1 ) } $p->lines( { binmode => ':raw' } );
533 0 return perl_to_zuzu( \@lines );
534 },
535 481 );
536  
537 $path_class->methods->{lines_async} = native_function(
538 name => 'lines_async',
539 native => sub {
540 0 ▶ my ( $self ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
541 0 my $p = _to_path_tiny( $self );
542 return _async_task(
543 $runtime,
544 'path.lines_async',
545 sub {
546 0 ▶ return [ $p->lines() ];
Subroutine __ANON__: not called CC=1 SCAR=6.9
547 },
548 sub {
549 0 ▶ my ( $lines ) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
550 my @wrapped = map {
551 0 Zuzu::Value::BinaryString->new( bytes => $_ );
552 0 ▶ } @{ $lines // [] };
Condition0%0/2
$lines // []
l!l
00
MC/DC0%0/1
$lines // []
$lines
Truth table0%0/2
A
A= $lines
Aresult
11
00
553 0 return perl_to_zuzu( \@wrapped );
554 },
555 0 );
556 },
557 481 );
558  
559 $path_class->methods->{lines_utf8_async} = native_function(
560 name => 'lines_utf8_async',
561 native => sub {
562 0 ▶ my ( $self ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
563 0 my $p = _to_path_tiny( $self );
564 return _async_task(
565 $runtime,
566 'path.lines_utf8_async',
567 sub {
568 0 ▶ return [ $p->lines_utf8() ];
Subroutine __ANON__: not called CC=1 SCAR=6.9
569 },
570 sub {
571 0 ▶ my ( $lines ) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
572 0 ▶ return perl_to_zuzu( $lines // [] );
Condition0%0/2
$lines // []
l!l
00
MC/DC0%0/1
$lines // []
$lines
Truth table0%0/2
A
A= $lines
Aresult
11
00
573 },
574 0 );
575 },
576 481 );
577  
578 481 for my $name ( qw( spew append ) ) {
579 $path_class->methods->{ $name . '_async' } = native_function(
580 name => $name . '_async',
581 native => sub {
582 0 ▶ my ( $self, @args ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
583 0 my $p = _to_path_tiny( $self );
584 0 my $label = 'Path.' . $name . '_async';
585 0 _assert_binary_string( $args[0], $label );
586 0 my $bytes = $args[0]->bytes;
587 return _async_task(
588 $runtime,
589 'path.' . $name . '_async',
590 sub {
591 0 ▶ $p->$name($bytes);
Subroutine __ANON__: not called CC=1 SCAR=6.9
592 0 return $p->stringify;
593 },
594 sub {
595 0 ▶ my ( $out ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
596 0 return _new_path_object( $path_class, path($out) );
597 },
598 0 );
599 },
600 962 );
601 }
602  
603 481 for my $name ( qw( spew_utf8 append_utf8 ) ) {
604 $path_class->methods->{ $name . '_async' } = native_function(
605 name => $name . '_async',
606 native => sub {
607 0 ▶ my ( $self, @args ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
608 0 my $p = _to_path_tiny( $self );
609 0 my $label = 'Path.' . $name . '_async';
610 0 _assert_text_string( $args[0], $label );
611 0 my @text_args = @args;
612 return _async_task(
613 $runtime,
614 'path.' . $name . '_async',
615 sub {
616 0 ▶ $p->$name(@text_args);
Subroutine __ANON__: not called CC=1 SCAR=6.9
617 0 return $p->stringify;
618 },
619 sub {
620 0 ▶ my ( $out ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
621 0 return _new_path_object( $path_class, path($out) );
622 },
623 0 );
624 },
625 962 );
626 }
627  
628 $path_class->methods->{stat} = native_function(
629 name => 'stat',
630 native => sub {
631 0 ▶ my ( $self ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
632 0 my $p = _to_path_tiny( $self );
633 0 return _stat_to_dict( $p->stat );
634 },
635 481 );
636  
637 $path_class->methods->{lstat} = native_function(
638 name => 'lstat',
639 native => sub {
640 0 ▶ my ( $self ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
641 0 my $p = _to_path_tiny( $self );
642 0 return _stat_to_dict( $p->lstat );
643 },
644 481 );
645  
646 481 for my $name ( qw( edit_lines edit_lines_utf8 ) ) {
647 $path_class->methods->{$name} = native_function(
648 name => $name,
649 native => sub {
650 0 ▶ my ( $self, $callback ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
651 0 _warn_blocking_operation( $runtime, "std/io Path.$name" );
652 0 my $p = _to_path_tiny( $self );
653 $p->$name( sub {
654 0 ▶ my ( $line ) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
655 0 my $out = $runtime->_call_function( $callback, [ $line ], '<std/io>', 0 );
656 0 ▶ return defined $out ? "$out" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $out ? : 0 0 0
657 0 } );
658 0 return $self;
659 },
660 962 );
661 }
662  
663 $path_class->methods->{each_line} = native_function(
664 name => 'each_line',
665 native => sub {
666 1 ▶ my ( $self, $callback, $raw_opt ) = @_;
Subroutine __ANON__: called CC=4 SCAR=13.9
667 1 _warn_blocking_operation( $runtime, 'std/io Path.each_line' );
668 1 my $raw = _raw_mode( $raw_opt );
669 1 my $p = _to_path_tiny( $self );
670 1 ▶ my $fh = $raw ? $p->openr_raw : $p->openr_utf8;
Branch: 1 branch
BranchTrueFalseTotal
$raw ? : 0 1 1
671 1 ▶ while ( my $line = <$fh> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 2 1 3
672 2 ▶ my $value = $raw
Branch: 1 branch
BranchTrueFalseTotal
$raw ? : 0 2 2
673 ? Zuzu::Value::BinaryString->new( bytes => $line )
674 : $line;
675 2 _call_callback( $runtime, $callback, [ $value ] );
676 }
677 1 close $fh;
678 1 return $self;
679 },
680 481 );
681  
682 $path_class->methods->{next_line} = native_function(
683 name => 'next_line',
684 native => sub {
685 4 ▶ my ( $self, $raw_opt ) = @_;
Subroutine __ANON__: called CC=10 SCAR=23.8
686 4 _warn_blocking_operation( $runtime, 'std/io Path.next_line' );
687 4 my $raw = _raw_mode( $raw_opt );
688 4 my $cursor = $self->slots->{_line_cursor};
689 4 my $mode = $self->slots->{_line_mode};
690 4 ▶ if ( defined $cursor and defined $mode and $mode != $raw ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cursor and defined $mode and $mode != $raw) 0 4 4
Condition66%4/6
defined $cursor and defined $mode and $mode != $raw
!ll&&!rl&&r
220
defined $cursor and defined $mode
!ll&&!rl&&r
202
MC/DC0%0/3
defined $cursor and defined $mode and $mode != $raw
defined $cursor defined $mode $mode != $raw
Truth table50%2/4
A and B and C
A= defined $cursorB= defined $modeC= $mode != $raw
ABCresult
0XX0
10X0
1100
1111
691 0 close $cursor;
692 0 $self->slots->{_line_cursor} = undef;
693 0 $self->slots->{_line_done} = 0;
694 0 $cursor = undef;
695 }
696 4 ▶ return undef if not defined $cursor and $self->slots->{_line_done};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $cursor and $self->slots->{"_line_done"} 1 3 4
Condition100%3/3
not defined $cursor and $self->slots->{"_line_done"}
!ll&&!rl&&r
211
MC/DC100%2/2
not defined $cursor and $self->slots->{"_line_done"}
not defined $cursor $self->slots->{"_line_done"}
Truth table100%3/3
not(A) and B
A= not defined $cursorB= $self->slots->{"_line_done"}
ABresult
0X0
100
111
697 3 ▶ if ( not defined $cursor ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $cursor) 1 2 3
698 1 my $p = _to_path_tiny( $self );
699 1 ▶ $cursor = $raw ? $p->openr_raw : $p->openr_utf8;
Branch: 1 branch
BranchTrueFalseTotal
$raw ? : 0 1 1
700 1 $self->slots->{_line_cursor} = $cursor;
701 1 $self->slots->{_line_done} = 0;
702 1 $self->slots->{_line_mode} = $raw;
703 }
704 3 my $line = <$cursor>;
705 3 ▶ if ( defined $line ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $line) 2 1 3
706 2 ▶ return $raw
Branch: 1 branch
BranchTrueFalseTotal
$raw ? : 0 2 2
707 ? Zuzu::Value::BinaryString->new( bytes => $line )
708 : $line;
709 }
710 1 close $cursor;
711 1 $self->slots->{_line_cursor} = undef;
712 1 $self->slots->{_line_done} = 1;
713 1 return undef;
714 },
715 481 );
716  
717 $path_class->methods->{children} = native_function(
718 name => 'children',
719 native => sub {
720 0 ▶ my ( $self, @args ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
721 0 my $p = _to_path_tiny( $self );
722 0 my @kids = $p->children( @args );
723 0 return _new_path_array( $path_class, \@kids );
724 },
725 481 );
726  
727 $path_iterator_class->methods->{next} = native_function(
728 name => 'next',
729 native => sub {
730 0 ▶ my ( $self ) = @_;
Subroutine __ANON__: not called CC=3 SCAR=24.8
731 0 my $iter = $self->slots->{_iter};
732 0 ▶ return undef if not defined $iter;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $iter 0 0 0
733 0 my $next = $iter->();
734 0 ▶ return undef if not defined $next;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $next 0 0 0
735 0 return _new_path_object( $path_class, $next );
736 },
737 481 );
738  
739 $path_class->methods->{iterator} = native_function(
740 name => 'iterator',
741 native => sub {
742 0 ▶ my ( $self, @args ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
743 0 my $p = _to_path_tiny( $self );
744 0 my $iter = $p->iterator( @args );
745 0 return native_object(
746 class => $path_iterator_class,
747 slots => {
748 _iter => $iter,
749 },
750 const => {
751 _iter => 1,
752 },
753 );
754 },
755 481 );
756  
757 $path_class->methods->{visit} = native_function(
758 name => 'visit',
759 native => sub {
760 0 ▶ my ( $self, $callback, @args ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
761 0 my $p = _to_path_tiny( $self );
762 $p->visit( sub {
763 0 ▶ my ( $entry ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
764 0 my $wrapped = _new_path_object( $path_class, $entry );
765 0 _call_callback( $runtime, $callback, [ $wrapped ] );
766 0 }, @args );
767 0 return $self;
768 },
769 481 );
770  
771 $path_class->static_methods->{cwd} = native_function(
772 name => 'cwd',
773 native => sub {
774 1 ▶ return _new_path_object( $path_class, cwd() );
Subroutine __ANON__: called CC=1 SCAR=0.0
775 },
776 481 );
777 $path_class->static_methods->{rootdir} = native_function(
778 name => 'rootdir',
779 native => sub {
780 1 ▶ return _new_path_object( $path_class, rootdir() );
Subroutine __ANON__: called CC=1 SCAR=0.0
781 },
782 481 );
783 $path_class->static_methods->{tempfile} = native_function(
784 name => 'tempfile',
785 native => sub {
786 9 ▶ my ( $self, @args ) = @_;
Subroutine __ANON__: called CC=2 SCAR=7.0
787 9 ▶ push @args, UNLINK => 0
Branch: 1 branch
BranchTrueFalseTotal
unless _has_named_temp_option(\@args, "UNLINK") 9 0 9
788 if not _has_named_temp_option( \@args, 'UNLINK' );
789 9 my $path = tempfile( @args );
790 9 return _new_path_object(
791 $path_class,
792 $path,
793 _temp_path_cleanup( $path, 0 ),
794 );
795 },
796 481 );
797 $path_class->static_methods->{tempdir} = native_function(
798 name => 'tempdir',
799 native => sub {
800 0 ▶ my ( $self, @args ) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
801 0 ▶ push @args, CLEANUP => 0
Branch: 1 branch
BranchTrueFalseTotal
unless _has_named_temp_option(\@args, "CLEANUP") 0 0 0
802 if not _has_named_temp_option( \@args, 'CLEANUP' );
803 0 my $path = tempdir( @args );
804 0 return _new_path_object(
805 $path_class,
806 $path,
807 _temp_path_cleanup( $path, 1 ),
808 );
809 },
810 481 );
811 $path_class->static_methods->{glob} = native_function(
812 name => 'glob',
813 native => sub {
814 0 ▶ my ( $self, $pattern, $options ) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
815 0 my $pattern_perl = zuzu_to_perl($pattern);
816 0 ▶ my $p = defined $pattern_perl ? "$pattern_perl" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $pattern_perl ? : 0 0 0
817 0 my $flags = _glob_flags_from_options( zuzu_to_perl($options) );
818 0 my @hits = bsd_glob( $p, $flags );
819 0 my @paths = map { path($_) } @hits;
820 0 return _new_path_array( $path_class, \@paths );
821 },
822 481 );
823 $path_class->static_methods->{join} = native_function(
824 name => 'join',
825 native => sub {
826 0 ▶ my ( $self, $parts ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
827 0 my @parts = _normalize_join_parts( zuzu_to_perl($parts) );
828 0 my $joined = path( @parts );
829 0 return _new_path_object( $path_class, $joined );
830 },
831 481 );
832 $path_class->static_methods->{split} = native_function(
833 name => 'split',
834 native => sub {
835 0 ▶ my ( $self, $raw_path ) = @_;
Subroutine __ANON__: not called CC=6 SCAR=37.4
836 0 my $path_perl = zuzu_to_perl($raw_path);
837 0 ▶ my $input = defined $path_perl ? "$path_perl" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $path_perl ? : 0 0 0
838 0 my ( $vol, $dir, $base ) = File::Spec->splitpath($input);
839 0 my @parts = File::Spec->splitdir($dir);
840 0 ▶ push @parts, $base if $base ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $base ne "" 0 0 0
841 0 ▶ @parts = grep { defined $_ and $_ ne '' } @parts;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ and $_ ne "" 0 0 0
842 0 ▶ unshift @parts, $vol if defined $vol and $vol ne '';
Branch: 1 branch
BranchTrueFalseTotal
if defined $vol and $vol ne "" 0 0 0
Condition0%0/3
defined $vol and $vol ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $vol and $vol ne ""
defined $vol $vol ne ""
Truth table0%0/3
A and B
A= defined $volB= $vol ne ""
ABresult
0X0
100
111
843 0 return perl_to_zuzu( \@parts );
844 },
845 481 );
846 $path_class->static_methods->{normalize} = native_function(
847 name => 'normalize',
848 native => sub {
849 0 ▶ my ( $self, $raw_path ) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
850 0 my $path_perl = zuzu_to_perl($raw_path);
851 0 ▶ my $p = path( defined $path_perl ? "$path_perl" : '' );
Branch: 1 branch
BranchTrueFalseTotal
defined $path_perl ? : 0 0 0
852 0 my $canon = $p->canonpath;
853 0 return _new_path_object( $path_class, path($canon) );
854 },
855 481 );
856  
857 $stdin_class->methods->{next_line} = native_function(
858 name => 'next_line',
859 native => sub {
860 0 ▶ my ( $self, $raw_opt ) = @_;
Subroutine __ANON__: not called CC=3 SCAR=24.8
861 0 my $raw = _raw_mode( $raw_opt );
862 0 my $line = <STDIN>;
863 0 ▶ return undef if not defined $line;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $line 0 0 0
864 0 ▶ return $raw
Branch: 1 branch
BranchTrueFalseTotal
$raw ? : 0 0 0
865 ? Zuzu::Value::BinaryString->new( bytes => $line )
866 : _decode_if_utf8( $line, $raw );
867 },
868 481 );
869  
870 $stdin_class->methods->{each_line} = native_function(
871 name => 'each_line',
872 native => sub {
873 0 ▶ my ( $self, $callback, $raw_opt ) = @_;
Subroutine __ANON__: not called CC=3 SCAR=24.8
874 0 my $raw = _raw_mode( $raw_opt );
875 0 ▶ while ( my $line = <STDIN> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline STDIN)) 0 0 0
876 0 ▶ my $value = $raw
Branch: 1 branch
BranchTrueFalseTotal
$raw ? : 0 0 0
877 ? Zuzu::Value::BinaryString->new( bytes => $line )
878 : _decode_if_utf8( $line, $raw );
879 0 _call_callback( $runtime, $callback, [ $value ] );
880 }
881 0 return undef;
882 },
883 481 );
884  
885 $stdout_class->methods->{print} = native_function(
886 name => 'print',
887 native => sub {
888 0 ▶ my ( $self, @args ) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
889 0 ▶ print STDOUT join '', map { defined $_ ? "$_" : '' } @args;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
890 0 return undef;
891 },
892 481 );
893 $stdout_class->methods->{say} = native_function(
894 name => 'say',
895 native => sub {
896 0 ▶ my ( $self, @args ) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
897 0 ▶ print STDOUT join( '', map { defined $_ ? "$_" : '' } @args ), "\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
898 0 return undef;
899 },
900 481 );
901  
902 $stderr_class->methods->{print} = native_function(
903 name => 'print',
904 native => sub {
905 0 ▶ my ( $self, @args ) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
906 0 ▶ print STDERR join '', map { defined $_ ? "$_" : '' } @args;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
907 0 return undef;
908 },
909 481 );
910 $stderr_class->methods->{say} = native_function(
911 name => 'say',
912 native => sub {
913 0 ▶ my ( $self, @args ) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
914 0 ▶ print STDERR join( '', map { defined $_ ? "$_" : '' } @args ), "\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
915 0 return undef;
916 },
917 481 );
918  
919 481 my $stdin_obj = native_object(
920 class => $stdin_class,
921 slots => {},
922 const => {},
923 );
924 481 my $stdout_obj = native_object(
925 class => $stdout_class,
926 slots => {},
927 const => {},
928 );
929 481 my $stderr_obj = native_object(
930 class => $stderr_class,
931 slots => {},
932 const => {},
933 );
934  
935 return {
936 481 Path => $path_class,
937 PathIterator => $path_iterator_class,
938 STDIN => $stdin_obj,
939 STDOUT => $stdout_obj,
940 STDERR => $stderr_obj,
941 };
942 }
943  
944 61 1;
945  
946 =pod
947  
948 =head1 NAME
949  
950 Zuzu::Module::IO - std/io bindings for ZuzuScript.
951  
952 =head1 DESCRIPTION
953  
954 Implements the C<std/io> module, exporting path and stream helpers.
955  
956 =head1 EXPORTS
957  
958 =head2 Path
959  
960 Filesystem path object backed by C<Path::Tiny>. Supports path
961 manipulation, metadata checks, file I/O, and traversal helpers.
962  
963 Notable methods include:
964  
965 =over
966  
967 =item * path transforms: C<absolute>, C<child>, C<parent>, C<sibling>
968  
969 =item * queries: C<exists>, C<is_file>, C<is_dir>, C<subsumes>
970  
971 =item * binary I/O: C<slurp>, C<spew>, C<append>, C<lines>
972  
973 =item * UTF-8 I/O: C<slurp_utf8>, C<spew_utf8>, C<append_utf8>, C<lines_utf8>
974  
975 =item * streaming: C<each_line>, C<next_line>
976  
977 =item * traversal: C<children>, C<iterator>, C<visit>
978  
979 =item * metadata: C<size>, C<size_human>, C<stat>, C<lstat>
980  
981 =item * directories: C<mkdir>, C<mkdir_exclusive>, C<remove_tree>
982  
983 =back
984  
985 Static helpers include C<cwd>, C<rootdir>, C<tempfile>, and C<tempdir>.
986  
987 =head2 PathIterator
988  
989 Iterator object returned by C<Path-E<gt>iterator>.
990  
991 Methods:
992  
993 =over
994  
995 =item * C<next()>
996  
997 =back
998  
999 =head2 STDIN
1000  
1001 Methods:
1002  
1003 =over
1004  
1005 =item * C<next_line(raw?)>
1006  
1007 =item * C<each_line(callback, raw?)>
1008  
1009 =back
1010  
1011 =head2 STDOUT and STDERR
1012  
1013 Methods:
1014  
1015 =over
1016  
1017 =item * C<print(...)>
1018  
1019 =item * C<say(...)>
1020  
1021 =back
1022  
1023 =head1 COPYRIGHT AND LICENCE
1024  
1025 B<< Zuzu::Module::IO >> is copyright Toby Inkster.
1026  
1027 It is free software; you may redistribute it and/or modify it under
1028 the terms of either the Artistic License 1.0 or the GNU General Public
1029 License version 2.
1030  
1031 =cut
« blib/lib/Zuzu/Module/Eval.pm ↑ Summary lib/Zuzu/Tidy/CLI.pm »