blib/lib/Venus.pm

filter: Statementstmt 16.8% 83 / 492 Branchbran 7.4% 19 / 254 Conditioncond 28.3% 21 / 74 MC/DCmcdc 12.5% 5 / 40 Subroutinesub 17.2% 16 / 93 Podpod 100% 81 / 81 totaltotal 21.7% 225 / 1034 SCAR 96.7
CC
160
Cov
15%
throw
272.0
call
179.0
syscall
132.0
CRAP 15881.6
↑ Summary blib/lib/Venus/Process.pm »
1 package Venus;
2  
3 96 ▶use 5.018;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 96 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 96 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # VERSION
9  
10 96 our $VERSION = '4.11';
11  
12 # AUTHORITY
13  
14 96 our $AUTHORITY = 'cpan:AWNCORP';
15  
16 # IMPORTS
17  
18 sub import {
19 123 ▶ my ($self, @args) = @_;
Subroutine import: called CC=6 SCAR=18.9
20  
21 123 my $target = caller;
22  
23 96 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 123 my %exports = (
26 args => 1,
27 array => 1,
28 arrayref => 1,
29 assert => 1,
30 async => 1,
31 atom => 1,
32 await => 1,
33 bool => 1,
34 box => 1,
35 call => 1,
36 cast => 1,
37 catch => 1,
38 caught => 1,
39 chain => 1,
40 check => 1,
41 clargs => 1,
42 cli => 1,
43 clone => 1,
44 code => 1,
45 config => 1,
46 container => 1,
47 cop => 1,
48 data => 1,
49 date => 1,
50 docs => 1,
51 enum => 1,
52 error => 1,
53 false => 1,
54 fault => 1,
55 float => 1,
56 future => 1,
57 gather => 1,
58 hash => 1,
59 hashref => 1,
60 is_bool => 1,
61 is_false => 1,
62 is_true => 1,
63 json => 1,
64 list => 1,
65 load => 1,
66 log => 1,
67 make => 1,
68 match => 1,
69 merge => 1,
70 meta => 1,
71 name => 1,
72 number => 1,
73 opts => 1,
74 pairs => 1,
75 path => 1,
76 perl => 1,
77 process => 1,
78 proto => 1,
79 puts => 1,
80 raise => 1,
81 random => 1,
82 range => 1,
83 regexp => 1,
84 replace => 1,
85 render => 1,
86 resolve => 1,
87 roll => 1,
88 search => 1,
89 space => 1,
90 schema => 1,
91 string => 1,
92 syscall => 1,
93 template => 1,
94 test => 1,
95 text => 1,
96 then => 1,
97 throw => 1,
98 true => 1,
99 try => 1,
100 type => 1,
101 unpack => 1,
102 vars => 1,
103 venus => 1,
104 work => 1,
105 wrap => 1,
106 yaml => 1,
107 );
108  
109 123 ▶ @args = grep defined && !ref && /^[A-Za-z]/ && $exports{$_}, @args;
Condition33%3/9
defined $_ && !ref($_) && /^[A-Za-z]/u && $exports{$_}
!ll&&!rl&&r
0012
defined $_ and not ref $_ and /^[A-Za-z]/u
!ll&&!rl&&r
0012
defined $_ and not ref $_
!ll&&!rl&&r
0012
MC/DC0%0/4
defined $_ && !ref($_) && /^[A-Za-z]/u && $exports{$_}
defined $_ not ref $_ /^[A-Za-z]/u $exports{$_}
Truth table20%1/5
A and not(B) and C && D
A= defined $_B= not ref $_C= /^[A-Za-z]/uD= $exports{$_}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
110  
111 123 my %seen;
112 123 for my $name (grep !$seen{$_}++, @args, 'true', 'false') {
113 258 ▶ *{"${target}::${name}"} = $self->can($name) if !$target->can($name);
Branch: 1 branch
BranchTrueFalseTotal
unless $target->can($name) 236 22 258
114 }
115  
116 123 return $self;
117 }
118  
119 # HOOKS
120  
121 sub _qx {
122 0 ▶ my (@args) = @_;
Subroutine _qx: not called CC=2 SCAR=17.9
123 0 local $| = 1;
124 0 ▶ local $SIG{__WARN__} = sub {};
Subroutine __ANON__: not called CC=1 SCAR=6.9
125 0 ▶ (do{local $_ = qx(@{[@args]}); chomp if $_; $_}, $?, ($? >> 8))
Branch: 1 branch
BranchTrueFalseTotal
if $_ 0 0 0
126 }
127  
128 # FUNCTIONS
129  
130 sub args ($;$@) {
131 0 ▶ my ($data, $code, @args) = @_;
Subroutine args: not called CC=2 SCAR=17.9
Pod documented
132  
133 0 require Venus::Args;
134  
135 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
136 0 return Venus::Args->new($data);
137 }
138  
139 0 return Venus::Args->new($data)->$code(@args);
140 }
141  
142 sub array ($;$@) {
143 0 ▶ my ($data, $code, @args) = @_;
Subroutine array: not called CC=2 SCAR=17.9
Pod documented
144  
145 0 require Venus::Array;
146  
147 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
148 0 return Venus::Array->new($data);
149 }
150  
151 0 return Venus::Array->new($data)->$code(@args);
152 }
153  
154 sub arrayref (@) {
155 0 ▶ my (@args) = @_;
Subroutine arrayref: not called CC=3 SCAR=24.8
Pod documented
156  
157 0 ▶ return @args > 1
Branch: 2 branches
BranchTrueFalseTotal
@args > 1 ? : 0 0 0
ref $args[0] eq 'ARRAY' ? : 0 0 0
158 ? ([@args])
159 : ((ref $args[0] eq 'ARRAY') ? ($args[0]) : ([@args]));
160 }
161  
162 sub assert ($$) {
163 0 ▶ my ($data, $expr) = @_;
Subroutine assert: not called CC=1 SCAR=6.9
Pod documented
164  
165 0 require Venus::Assert;
166  
167 0 my $assert = Venus::Assert->new->expression($expr);
168  
169 0 return $assert->validate($data);
170 }
171  
172 sub async ($) {
173 0 ▶ my ($code) = @_;
Subroutine async: not called CC=1 SCAR=6.9
Pod documented
174  
175 0 require Venus::Process;
176  
177 0 return Venus::Process->new->future($code);
178 }
179  
180 sub atom (;$) {
181 0 ▶ my ($data) = @_;
Subroutine atom: not called CC=1 SCAR=6.9
Pod documented
182  
183 0 require Venus::Atom;
184  
185 0 return Venus::Atom->new($data);
186 }
187  
188 sub await ($;$) {
189 0 ▶ my ($future, $timeout) = @_;
Subroutine await: not called CC=1 SCAR=6.9
Pod documented
190  
191 0 require Venus::Future;
192  
193 0 return $future->wait($timeout);
194 }
195  
196 sub bool (;$) {
197 0 ▶ my ($data) = @_;
Subroutine bool: not called CC=1 SCAR=6.9
Pod documented
198  
199 0 require Venus::Boolean;
200  
201 0 return Venus::Boolean->new($data);
202 }
203  
204 sub box ($) {
205 0 ▶ my ($data) = @_;
Subroutine box: not called CC=1 SCAR=6.9
Pod documented
206  
207 0 require Venus::Box;
208  
209 0 my $box = Venus::Box->new($data);
210  
211 0 return $box;
212 }
213  
214 sub call (@) {
215 0 ▶ my ($data, @args) = @_;
Subroutine call: not called CC=15 SCAR=51.9
Pod documented
216 0 my $next = @args;
217 0 ▶ if ($next && UNIVERSAL::isa($data, 'CODE')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($next and UNIVERSAL::isa($data, "CODE")) 0 0 0
Condition0%0/3
$next and UNIVERSAL::isa($data, "CODE")
!ll&&!rl&&r
000
MC/DC0%0/2
$next and UNIVERSAL::isa($data, "CODE")
$next UNIVERSAL::isa($data, "CODE")
Truth table0%0/3
A and B
A= $nextB= UNIVERSAL::isa($data, "CODE")
ABresult
0X0
100
111
218 0 return $data->(@args);
219 }
220 0 my $code = shift(@args);
221 0 ▶ if ($next && Scalar::Util::blessed($data)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($next and builtin::blessed($data)) 0 0 0
Condition0%0/3
$next and builtin::blessed($data)
!ll&&!rl&&r
000
MC/DC0%0/2
$next and builtin::blessed($data)
$next builtin::blessed($data)
Truth table0%0/3
A and B
A= $nextB= builtin::blessed($data)
ABresult
0X0
100
111
222 0 ▶ return $data->$code(@args) if UNIVERSAL::can($data, $code)
Branch: 1 branch
BranchTrueFalseTotal
if UNIVERSAL::can($data, $code) or UNIVERSAL::can($data, "AUTOLOAD") 0 0 0
Condition0%0/3
UNIVERSAL::can($data, $code) or UNIVERSAL::can($data, "AUTOLOAD")
l!l&&r!l&&!r
000
MC/DC0%0/2
UNIVERSAL::can($data, $code) or UNIVERSAL::can($data, "AUTOLOAD")
UNIVERSAL::can($data, $code) UNIVERSAL::can($data, "AUTOLOAD")
Truth table0%0/3
A or B
A= UNIVERSAL::can($data, $code)B= UNIVERSAL::can($data, "AUTOLOAD")
ABresult
1X1
011
000
223 || UNIVERSAL::can($data, 'AUTOLOAD');
224 0 $next = 0;
225 }
226 0 ▶ if ($next && ref($data) eq 'SCALAR') {
Branch: 1 branch
BranchTrueFalseTotal
if ($next and ref $data eq "SCALAR") 0 0 0
Condition0%0/3
$next and ref $data eq "SCALAR"
!ll&&!rl&&r
000
MC/DC0%0/2
$next and ref $data eq "SCALAR"
$next ref $data eq "SCALAR"
Truth table0%0/3
A and B
A= $nextB= ref $data eq "SCALAR"
ABresult
0X0
100
111
227 0 ▶ return $$data->$code(@args) if UNIVERSAL::can(load($$data)->package, $code);
Branch: 1 branch
BranchTrueFalseTotal
if UNIVERSAL::can(&load($$data)->package, $code) 0 0 0
228 0 $next = 0;
229 }
230 0 ▶ if ($next && UNIVERSAL::can(load($data)->package, $code)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($next and UNIVERSAL::can(&load($data)->package, $code)) 0 0 0
Condition0%0/3
$next and UNIVERSAL::can(&load($data)->package, $code)
!ll&&!rl&&r
000
MC/DC0%0/2
$next and UNIVERSAL::can(&load($data)->package, $code)
$next UNIVERSAL::can(&load($data)->package, $code)
Truth table0%0/3
A and B
A= $nextB= UNIVERSAL::can(&load($data)->package, $code)
ABresult
0X0
100
111
231 96 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
232 0 return *{"${data}::${code}"}{"CODE"} ?
233 0 ▶ &{"${data}::${code}"}(@args) : $data->$code(@args[1..$#args]);
Branch: 1 branch
BranchTrueFalseTotal
*{"${data}::$code";}{'CODE'} ? : 0 0 0
234 }
235 0 ▶ if ($next && UNIVERSAL::can($data, 'AUTOLOAD')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($next and UNIVERSAL::can($data, "AUTOLOAD")) 0 0 0
Condition0%0/3
$next and UNIVERSAL::can($data, "AUTOLOAD")
!ll&&!rl&&r
000
MC/DC0%0/2
$next and UNIVERSAL::can($data, "AUTOLOAD")
$next UNIVERSAL::can($data, "AUTOLOAD")
Truth table0%0/3
A and B
A= $nextB= UNIVERSAL::can($data, "AUTOLOAD")
ABresult
0X0
100
111
236 96 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
237 0 return &{"${data}::${code}"}(@args);
238 }
239 0 fault("Exception! call(@{[join(', ', map qq('$_'), @_)]}) failed.");
240 }
241  
242 sub cast (;$$) {
243 0 ▶ my ($data, $into) = (@_ ? (@_) : ($_));
Subroutine cast: not called CC=3 SCAR=24.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
244  
245 0 require Venus::Type;
246  
247 0 my $type = Venus::Type->new($data);
248  
249 0 ▶ return $into ? $type->cast($into) : $type->deduce;
Branch: 1 branch
BranchTrueFalseTotal
$into ? : 0 0 0
250 }
251  
252 sub catch (&) {
253 26 ▶ my ($data) = @_;
Subroutine catch: called CC=3 SCAR=12.0
Pod documented
254  
255 26 my $error;
256  
257 26 require Venus::Try;
258  
259 26 my @result = Venus::Try->new($data)->error(\$error)->result;
260  
261 26 ▶ return wantarray ? ($error ? ($error, undef) : ($error, @result)) : $error;
Branch: 2 branches
BranchTrueFalseTotal
wantarray ? : 0 26 26
$error ? : 0 0 0
262 }
263  
264 sub caught ($$;&) {
265 0 ▶ my ($data, $type, $code) = @_;
Subroutine caught: not called CC=10 SCAR=47.0
Pod documented
266  
267 0 ▶ ($type, my($name)) = @$type if ref $type eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $type eq "ARRAY" 0 0 0
268  
269 0 ▶ my $is_true = $data
Branch: 3 branches
BranchTrueFalseTotal
$data->name ? : 0 0 0
$name ? : 0 0 0
!$name ? : 0 0 0
Condition0%0/9
$data && UNIVERSAL::isa($data, $type) && UNIVERSAL::isa($data, 'Venus::Error') && ($data->name ? $name ? $data->of($name) : &true() : (!$name ? &true() : &false()))
!ll&&!rl&&r
000
$data and UNIVERSAL::isa($data, $type) and UNIVERSAL::isa($data, "Venus::Error")
!ll&&!rl&&r
000
$data and UNIVERSAL::isa($data, $type)
!ll&&!rl&&r
000
MC/DC0%0/4
$data && UNIVERSAL::isa($data, $type) && UNIVERSAL::isa($data, 'Venus::Error') && ($data->name ? $name ? $data->of($name) : &true() : (!$name ? &true() : &false()))
$data UNIVERSAL::isa($data, $type) UNIVERSAL::isa($data, "Venus::Error") ($data->name ? $name ? $data->of($name) : &true() : (!$name ? &true() : &false()))
Truth table0%0/5
A and B and C && D
A= $dataB= UNIVERSAL::isa($data, $type)C= UNIVERSAL::isa($data, "Venus::Error")D= ($data->name ? $name ? $data->of($name) : &true() : (!$name ? &true() : &false()))
ABCDresult
0XXX0
10XX0
110X0
11100
11111
270 && UNIVERSAL::isa($data, $type)
271 && UNIVERSAL::isa($data, 'Venus::Error')
272 && (
273 $data->name
274 ? ($name ? $data->of($name) : true())
275 : (!$name ? true() : false())
276 );
277  
278 0 ▶ if ($is_true) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_true) { } 0 0 0
279 0 local $_ = $data;
280  
281 0 ▶ return $code ? $code->($data) : $data;
Branch: 1 branch
BranchTrueFalseTotal
$code ? : 0 0 0
282 }
283 else {
284 0 return undef;
285 }
286 }
287  
288 sub chain {
289 0 ▶ my ($data, @args) = @_;
Subroutine chain: not called CC=4 SCAR=30.0
Pod documented
290  
291 0 ▶ return if !$data;
Branch: 1 branch
BranchTrueFalseTotal
unless $data 0 0 0
292  
293 0 ▶ for my $next (map +(ref($_) eq 'ARRAY' ? $_ : [$_]), @args) {
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 0 0
294 0 $data = call($data, @$next);
295 }
296  
297 0 return $data;
298 }
299  
300 sub check ($$) {
301 0 ▶ my ($data, $expr) = @_;
Subroutine check: not called CC=1 SCAR=6.9
Pod documented
302  
303 0 require Venus::Assert;
304  
305 0 return Venus::Assert->new->expression($expr)->valid($data);
306 }
307  
308 sub clargs (@) {
309 0 ▶ my (@args) = @_;
Subroutine clargs: not called CC=2 SCAR=17.9
Pod documented
310  
311 0 ▶ my ($argv, $specs) = (@args > 1)
Branch: 1 branch
BranchTrueFalseTotal
@args > 1 ? : 0 0 0
312 ? (map arrayref($_), @args)
313 : ([@ARGV], arrayref(@args));
314  
315 return (
316 0 args($argv), opts($argv, 'reparse', $specs), vars({}),
317 );
318 }
319  
320 sub cli (;$) {
321 0 ▶ my ($data) = @_;
Subroutine cli: not called CC=2 SCAR=17.9
Pod documented
322  
323 0 require Venus::Cli;
324  
325 0 ▶ my $cli = Venus::Cli->new($data || [@ARGV]);
Condition0%0/2
$data || [@ARGV]
l!l
00
MC/DC0%0/1
$data || [@ARGV]
$data
Truth table0%0/2
A
A= $data
Aresult
11
00
326  
327 0 return $cli;
328 }
329  
330 sub clone ($) {
331 0 ▶ my ($data) = @_;
Subroutine clone: not called CC=1 SCAR=6.9
Pod documented
332  
333 0 require Storable;
334  
335 0 return Storable::dclone($data);
336 }
337  
338 sub code ($;$@) {
339 0 ▶ my ($data, $code, @args) = @_;
Subroutine code: not called CC=2 SCAR=17.9
Pod documented
340  
341 0 require Venus::Code;
342  
343 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
344 0 return Venus::Code->new($data);
345 }
346  
347 0 return Venus::Code->new($data)->$code(@args);
348 }
349  
350 sub config ($;$@) {
351 0 ▶ my ($data, $code, @args) = @_;
Subroutine config: not called CC=2 SCAR=17.9
Pod documented
352  
353 0 require Venus::Config;
354  
355 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
356 0 return Venus::Config->new($data);
357 }
358  
359 0 return Venus::Config->new($data)->$code(@args);
360 }
361  
362 sub container ($;$@) {
363 0 ▶ my ($data, $code, @args) = @_;
Subroutine container: not called CC=2 SCAR=17.9
Pod documented
364  
365 0 require Venus::Container;
366  
367 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
368 0 return Venus::Container->new($data);
369 }
370  
371 0 return Venus::Container->new($data)->$code(@args);
372 }
373  
374 sub cop (@) {
375 0 ▶ my ($data, @args) = @_;
Subroutine cop: not called CC=3 SCAR=24.8
Pod documented
376  
377 0 require Scalar::Util;
378  
379 ($data, $args[0]) = map {
380 0 ▶ ref eq 'SCALAR' ? $$_ : Scalar::Util::blessed($_) ? ref($_) : $_
Branch: 2 branches
BranchTrueFalseTotal
ref $_ eq 'SCALAR' ? : 0 0 0
builtin::blessed($_) ? : 0 0 0
381 } ($data, $args[0]);
382  
383 0 return space("$data")->cop(@args);
384 }
385  
386 sub data ($;$@) {
387 0 ▶ my ($data, $code, @args) = @_;
Subroutine data: not called CC=2 SCAR=17.9
Pod documented
388  
389 0 require Venus::Data;
390  
391 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
392 0 return Venus::Data->new($data);
393 }
394  
395 0 return Venus::Data->new($data)->$code(@args);
396 }
397  
398 sub date ($;$@) {
399 0 ▶ my ($data, $code, @args) = @_;
Subroutine date: not called CC=2 SCAR=17.9
Pod documented
400  
401 0 require Venus::Date;
402  
403 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
404 0 return Venus::Date->new($data);
405 }
406  
407 0 return Venus::Date->new($data)->$code(@args);
408 }
409  
410 sub docs {
411 0 ▶ my (@args) = @_;
Subroutine docs: not called CC=2 SCAR=17.9
Pod documented
412  
413 0 my $file = (grep -f, (caller(0))[1], $0)[0];
414  
415 0 my $data = data($file);
416  
417 0 ▶ return $data->docs->string(@args > 1 ? @args : (undef, @args));
Branch: 1 branch
BranchTrueFalseTotal
@args > 1 ? : 0 0 0
418 }
419  
420 sub enum {
421 0 ▶ my (@data) = @_;
Subroutine enum: not called CC=1 SCAR=6.9
Pod documented
422  
423 0 require Venus::Enum;
424  
425 0 return Venus::Enum->new(@data);
426 }
427  
428 sub error (;$) {
429 7 ▶ my ($data) = @_;
Subroutine error: called CC=3 SCAR=11.2
Pod documented
430  
431 7 ▶ $data //= {};
Condition100%2/2
$data //= {}
l!l
16
MC/DC100%1/1
$data //= {}
$data
Truth table100%2/2
A
A= $data
Aresult
11
00
432 7 ▶ $data->{context} //= (caller(1))[3];
Condition33%1/3
$data->{"context"} //= (caller 1)[3]
l!l&&r!l&&!r
070
MC/DC0%0/2
$data->{"context"} //= (caller 1)[3]
$data->{"context"} (caller 1)[3]
Truth table33%1/3
A //= B
A= $data->{"context"}B= (caller 1)[3]
ABresult
1X1
011
000
433  
434 7 require Venus::Throw;
435  
436 7 return Venus::Throw->new->error($data);
437 }
438  
439 sub false () {
440  
441 17580 ▶ require Venus::False;
Subroutine false: called CC=1 SCAR=0.0
Pod documented
442  
443 17580 return Venus::False->value;
444 }
445  
446 sub fault (;$) {
447 1 ▶ my ($data) = @_;
Subroutine fault: called CC=1 SCAR=0.0
Pod documented
448  
449 1 require Venus::Fault;
450  
451 1 return Venus::Fault->new($data)->throw;
452 }
453  
454 sub float ($;$@) {
455 0 ▶ my ($data, $code, @args) = @_;
Subroutine float: not called CC=2 SCAR=17.9
Pod documented
456  
457 0 require Venus::Float;
458  
459 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
460 0 return Venus::Float->new($data);
461 }
462  
463 0 return Venus::Float->new($data)->$code(@args);
464 }
465  
466 sub future {
467 0 ▶ my (@data) = @_;
Subroutine future: not called CC=1 SCAR=6.9
Pod documented
468  
469 0 require Venus::Future;
470  
471 0 return Venus::Future->new(@data);
472 }
473  
474 sub gather ($;&) {
475 0 ▶ my ($data, $code) = @_;
Subroutine gather: not called CC=3 SCAR=24.8
Pod documented
476  
477 0 require Venus::Gather;
478  
479 0 my $match = Venus::Gather->new($data);
480  
481 0 ▶ return $match if !$code;
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 0 0
482  
483 0 local $_ = $match;
484  
485 0 my $returned = $code->($match, $data);
486  
487 0 ▶ $match->data($returned) if ref $returned eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $returned eq "HASH" 0 0 0
488  
489 0 return $match->result;
490 }
491  
492 sub hash ($;$@) {
493 0 ▶ my ($data, $code, @args) = @_;
Subroutine hash: not called CC=2 SCAR=17.9
Pod documented
494  
495 0 require Venus::Hash;
496  
497 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
498 0 return Venus::Hash->new($data);
499 }
500  
501 0 return Venus::Hash->new($data)->$code(@args);
502 }
503  
504 sub hashref (@) {
505 0 ▶ my (@args) = @_;
Subroutine hashref: not called CC=5 SCAR=34.0
Pod documented
506  
507 0 ▶ return @args > 1
Branch: 4 branches
BranchTrueFalseTotal
@args > 1 ? : 0 0 0
scalar(@args) % 2 ? : 0 0 0
ref $args[0] eq 'HASH' ? : 0 0 0
scalar(@args) % 2 ? : 0 0 0
508 ? ({(scalar(@args) % 2) ? (@args, undef) : @args})
509 : ((ref $args[0] eq 'HASH')
510 ? ($args[0])
511 : ({(scalar(@args) % 2) ? (@args, undef) : @args}));
512 }
513  
514 sub is_bool ($) {
515 0 ▶ my ($data) = @_;
Subroutine is_bool: not called CC=2 SCAR=17.9
Pod documented
516  
517 0 ▶ return type($data, 'coded', 'BOOLEAN') ? true() : false();
Branch: 1 branch
BranchTrueFalseTotal
&type($data, 'coded', 'BOOLEAN') ? : 0 0 0
518 }
519  
520 sub is_false ($) {
521 0 ▶ my ($data) = @_;
Subroutine is_false: not called CC=1 SCAR=6.9
Pod documented
522  
523 0 require Venus::Boolean;
524  
525 0 return Venus::Boolean->new($data)->is_false;
526 }
527  
528 sub is_true ($) {
529 0 ▶ my ($data) = @_;
Subroutine is_true: not called CC=1 SCAR=6.9
Pod documented
530  
531 0 require Venus::Boolean;
532  
533 0 return Venus::Boolean->new($data)->is_true;
534 }
535  
536 sub json (;$$) {
537 0 ▶ my ($code, $data) = @_;
Subroutine json: not called CC=4 SCAR=30.0
Pod documented
538  
539 0 require Venus::Json;
540  
541 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
542 0 return Venus::Json->new;
543 }
544  
545 0 ▶ if (lc($code) eq 'decode') {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $code eq "decode") 0 0 0
546 0 return Venus::Json->new->decode($data);
547 }
548  
549 0 ▶ if (lc($code) eq 'encode') {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $code eq "encode") 0 0 0
550 0 return Venus::Json->new(value => $data)->encode;
551 }
552  
553 0 return fault(qq(Invalid "json" action "$code"));
554 }
555  
556 sub list (@) {
557 0 ▶ my (@args) = @_;
Subroutine list: not called CC=3 SCAR=24.8
Pod documented
558  
559 0 ▶ return map {defined $_ ? (ref eq 'ARRAY' ? (@{$_}) : ($_)) : ($_)} @args;
Branch: 2 branches
BranchTrueFalseTotal
defined $_ ? : 0 0 0
ref $_ eq 'ARRAY' ? : 0 0 0
560 }
561  
562 sub load ($) {
563 0 ▶ my ($data) = @_;
Subroutine load: not called CC=1 SCAR=6.9
Pod documented
564  
565 0 return space($data)->do('load');
566 }
567  
568 sub log (@) {
569 0 ▶ my (@args) = @_;
Subroutine log: not called CC=4 SCAR=30.0
Pod documented
570  
571 0 state $codes = {
572 debug => 'debug',
573 error => 'error',
574 fatal => 'fatal',
575 info => 'info',
576 trace => 'trace',
577 warn => 'warn',
578 };
579  
580 0 ▶ unshift @args, 'debug' if @args && !$codes->{$args[0]};
Branch: 1 branch
BranchTrueFalseTotal
if @args and not $$codes{$args[0]} 0 0 0
Condition0%0/3
@args and not $$codes{$args[0]}
!ll&&!rl&&r
000
MC/DC0%0/2
@args and not $$codes{$args[0]}
@args not $$codes{$args[0]}
Truth table0%0/3
A and not(B)
A= @argsB= not $$codes{$args[0]}
ABresult
0X0
100
111
581  
582 0 require Venus::Log;
583  
584 0 my $log = Venus::Log->new($ENV{VENUS_LOG_LEVEL});
585  
586 0 ▶ return $log if !@args;
Branch: 1 branch
BranchTrueFalseTotal
unless @args 0 0 0
587  
588 0 my $code = shift @args;
589  
590 0 return $log->$code(@args);
591 }
592  
593 sub make (@) {
594  
595 0 ▶ return if !@_;
Subroutine make: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
596  
597 0 return call($_[0], 'new', @_);
598 }
599  
600 sub match ($;&) {
601 0 ▶ my ($data, $code) = @_;
Subroutine match: not called CC=3 SCAR=24.8
Pod documented
602  
603 0 require Venus::Match;
604  
605 0 my $match = Venus::Match->new($data);
606  
607 0 ▶ return $match if !$code;
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 0 0
608  
609 0 local $_ = $match;
610  
611 0 my $returned = $code->($match, $data);
612  
613 0 ▶ $match->data($returned) if ref $returned eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $returned eq "HASH" 0 0 0
614  
615 0 return $match->result;
616 }
617  
618 sub merge {
619 78 ▶ my ($lvalue, @rvalues) = @_;
Subroutine merge: called CC=19 SCAR=31.3
Pod documented
620  
621 78 ▶ if (!$lvalue) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($lvalue) 0 78 78
622 0 return {};
623 }
624  
625 78 my $rvalue;
626  
627 78 ▶ if (@rvalues > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@rvalues > 1) { } 1 77 78
628 1 my $result = $lvalue;
629 1 $result = merge($result, $_) for @rvalues;
630 1 return $result;
631 }
632 else {
633 77 $rvalue = $rvalues[0];
634 }
635  
636 77 ▶ if (!$rvalue) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rvalue) 0 77 77
637 0 return $lvalue;
638 }
639  
640 77 ▶ if (ref $lvalue eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $lvalue eq "HASH") 70 7 77
641 70 ▶ if (ref $rvalue eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $rvalue eq 'HASH') { } 70 0 70
642 70 for my $index (keys %{$rvalue}) {
643 166 my $lprop = $lvalue->{$index};
644 166 my $rprop = $rvalue->{$index};
645 166 ▶ $lvalue->{$index} = (
Branch: 1 branch
BranchTrueFalseTotal
ref $lprop eq 'HASH' && ref $rprop eq 'HASH' || ref $lprop eq 'ARRAY' && ref $rprop eq 'ARRAY' ? : 35 131 166
Condition77%7/9
ref $lprop eq "HASH" and ref $rprop eq "HASH" or ref $lprop eq "ARRAY" and ref $rprop eq "ARRAY"
l!l&&r!l&&!r
305131
ref $lprop eq "HASH" and ref $rprop eq "HASH"
!ll&&!rl&&r
136030
ref $lprop eq "ARRAY" and ref $rprop eq "ARRAY"
!ll&&!rl&&r
13105
MC/DC50%2/4
ref $lprop eq "HASH" and ref $rprop eq "HASH" or ref $lprop eq "ARRAY" and ref $rprop eq "ARRAY"
ref $lprop eq "HASH" ref $rprop eq "HASH" ref $lprop eq "ARRAY" ref $rprop eq "ARRAY"
Truth table42%3/7
A and B or C and D
A= ref $lprop eq "HASH"B= ref $rprop eq "HASH"C= ref $lprop eq "ARRAY"D= ref $rprop eq "ARRAY"
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
646 ((ref($lprop) eq 'HASH') && (ref($rprop) eq 'HASH'))
647 || ((ref($lprop) eq 'ARRAY') && (ref($rprop) eq 'ARRAY'))
648 )
649 ? merge($lprop, $rprop)
650 : $rprop;
651 }
652 }
653 else {
654 0 $lvalue = $rvalue;
655 }
656 }
657  
658 77 ▶ if (ref $lvalue eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $lvalue eq "ARRAY") 7 70 77
659 7 ▶ if (ref $rvalue eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $rvalue eq 'ARRAY') { } 7 0 7
660 7 for my $index (0..$#{$rvalue}) {
661 30 my $lprop = $lvalue->[$index];
662 30 my $rprop = $rvalue->[$index];
663 30 ▶ $lvalue->[$index] = (
Branch: 1 branch
BranchTrueFalseTotal
ref $lprop eq 'HASH' && ref $rprop eq 'HASH' || ref $lprop eq 'ARRAY' && ref $rprop eq 'ARRAY' ? : 15 15 30
Condition55%5/9
ref $lprop eq "HASH" and ref $rprop eq "HASH" or ref $lprop eq "ARRAY" and ref $rprop eq "ARRAY"
l!l&&r!l&&!r
15015
ref $lprop eq "HASH" and ref $rprop eq "HASH"
!ll&&!rl&&r
15015
ref $lprop eq "ARRAY" and ref $rprop eq "ARRAY"
!ll&&!rl&&r
1500
MC/DC25%1/4
ref $lprop eq "HASH" and ref $rprop eq "HASH" or ref $lprop eq "ARRAY" and ref $rprop eq "ARRAY"
ref $lprop eq "HASH" ref $rprop eq "HASH" ref $lprop eq "ARRAY" ref $rprop eq "ARRAY"
Truth table28%2/7
A and B or C and D
A= ref $lprop eq "HASH"B= ref $rprop eq "HASH"C= ref $lprop eq "ARRAY"D= ref $rprop eq "ARRAY"
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
664 ((ref($lprop) eq 'HASH') && (ref($rprop) eq 'HASH'))
665 || ((ref($lprop) eq 'ARRAY') && (ref($rprop) eq 'ARRAY'))
666 )
667 ? merge($lprop, $rprop)
668 : $rprop;
669 }
670 }
671 else {
672 0 $lvalue = $rvalue;
673 }
674 }
675  
676 77 return $lvalue;
677 }
678  
679 sub meta ($;$@) {
680 0 ▶ my ($data, $code, @args) = @_;
Subroutine meta: not called CC=2 SCAR=17.9
Pod documented
681  
682 0 require Venus::Meta;
683  
684 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
685 0 return Venus::Meta->new(name => $data);
686 }
687  
688 0 return Venus::Meta->new(name => $data)->$code(@args);
689 }
690  
691 sub name ($;$@) {
692 0 ▶ my ($data, $code, @args) = @_;
Subroutine name: not called CC=2 SCAR=17.9
Pod documented
693  
694 0 require Venus::Name;
695  
696 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
697 0 return Venus::Name->new($data);
698 }
699  
700 0 return Venus::Name->new($data)->$code(@args);
701 }
702  
703 sub number ($;$@) {
704 0 ▶ my ($data, $code, @args) = @_;
Subroutine number: not called CC=2 SCAR=17.9
Pod documented
705  
706 0 require Venus::Number;
707  
708 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
709 0 return Venus::Number->new($data);
710 }
711  
712 0 return Venus::Number->new($data)->$code(@args);
713 }
714  
715 sub opts ($;$@) {
716 0 ▶ my ($data, $code, @args) = @_;
Subroutine opts: not called CC=2 SCAR=17.9
Pod documented
717  
718 0 require Venus::Opts;
719  
720 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
721 0 return Venus::Opts->new($data);
722 }
723  
724 0 return Venus::Opts->new($data)->$code(@args);
725 }
726  
727 sub pairs (@) {
728 0 ▶ my ($args) = @_;
Subroutine pairs: not called CC=5 SCAR=34.0
Pod documented
729  
730 my $result = defined $args
731 ? (
732 ref $args eq 'ARRAY'
733 0 ▶ ? ([map {[$_, $args->[$_]]} 0..$#{$args}])
Branch: 1 branch
BranchTrueFalseTotal
ref $args eq 'HASH' ? : 0 0 0
734 0 ▶ : (ref $args eq 'HASH' ? ([map {[$_, $args->{$_}]} sort keys %{$args}]) : ([])))
Branch: 2 branches
BranchTrueFalseTotal
defined $args ? : 0 0 0
ref $args eq 'ARRAY' ? : 0 0 0
735 : [];
736  
737 0 ▶ return wantarray ? @{$result} : $result;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
738 }
739  
740 sub path ($;$@) {
741 0 ▶ my ($data, $code, @args) = @_;
Subroutine path: not called CC=2 SCAR=17.9
Pod documented
742  
743 0 require Venus::Path;
744  
745 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
746 0 return Venus::Path->new($data);
747 }
748  
749 0 return Venus::Path->new($data)->$code(@args);
750 }
751  
752 sub perl (;$$) {
753 0 ▶ my ($code, $data) = @_;
Subroutine perl: not called CC=4 SCAR=30.0
Pod documented
754  
755 0 require Venus::Dump;
756  
757 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
758 0 return Venus::Dump->new;
759 }
760  
761 0 ▶ if (lc($code) eq 'decode') {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $code eq "decode") 0 0 0
762 0 return Venus::Dump->new->decode($data);
763 }
764  
765 0 ▶ if (lc($code) eq 'encode') {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $code eq "encode") 0 0 0
766 0 return Venus::Dump->new(value => $data)->encode;
767 }
768  
769 0 return fault(qq(Invalid "perl" action "$code"));
770 }
771  
772 sub process (;$@) {
773 0 ▶ my ($code, @args) = @_;
Subroutine process: not called CC=2 SCAR=17.9
Pod documented
774  
775 0 require Venus::Process;
776  
777 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
778 0 return Venus::Process->new;
779 }
780  
781 0 return Venus::Process->new->$code(@args);
782 }
783  
784 sub proto ($;$@) {
785 0 ▶ my ($data, $code, @args) = @_;
Subroutine proto: not called CC=2 SCAR=17.9
Pod documented
786  
787 0 require Venus::Prototype;
788  
789 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
790 0 return Venus::Prototype->new($data);
791 }
792  
793 0 return Venus::Prototype->new($data)->$code(@args);
794 }
795  
796 sub puts ($;@) {
797 0 ▶ my ($data, @args) = @_;
Subroutine puts: not called CC=4 SCAR=30.0
Pod documented
798  
799 0 $data = cast($data);
800  
801 0 my $result = [];
802  
803 0 ▶ if ($data->isa('Venus::Hash')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($data->isa('Venus::Hash')) { } 0 0 0
elsif ($data->isa('Venus::Array')) { } 0 0 0
804 0 $result = $data->puts(@args);
805 }
806 elsif ($data->isa('Venus::Array')) {
807 0 $result = $data->puts(@args);
808 }
809  
810 0 ▶ return wantarray ? (@{$result}) : $result;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
811 }
812  
813 sub raise ($;$) {
814 6 ▶ my ($self, $data) = @_;
Subroutine raise: called CC=5 SCAR=16.8
Pod documented
815  
816 6 ▶ ($self, my $parent) = (@$self) if (ref($self) eq 'ARRAY');
Branch: 1 branch
BranchTrueFalseTotal
if ref $self eq "ARRAY" 0 6 6
817  
818 6 ▶ $data //= {};
Condition100%2/2
$data //= {}
l!l
15
MC/DC100%1/1
$data //= {}
$data
Truth table100%2/2
A
A= $data
Aresult
11
00
819 6 ▶ $data->{context} //= (caller(1))[3];
Condition33%1/3
$data->{"context"} //= (caller 1)[3]
l!l&&r!l&&!r
060
MC/DC0%0/2
$data->{"context"} //= (caller 1)[3]
$data->{"context"} (caller 1)[3]
Truth table33%1/3
A //= B
A= $data->{"context"}B= (caller 1)[3]
ABresult
1X1
011
000
820  
821 6 ▶ $parent = 'Venus::Error' if !$parent;
Branch: 1 branch
BranchTrueFalseTotal
unless $parent 6 0 6
822  
823 6 require Venus::Throw;
824  
825 6 return Venus::Throw->new(package => $self, parent => $parent)->error($data);
826 }
827  
828 sub random (;$@) {
829 0 ▶ my ($code, @args) = @_;
Subroutine random: not called CC=2 SCAR=17.9
Pod documented
830  
831 0 require Venus::Random;
832  
833 0 state $random = Venus::Random->new;
834  
835 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
836 0 return $random;
837 }
838  
839 0 return $random->$code(@args);
840 }
841  
842 sub range ($;@) {
843 0 ▶ my ($data, @args) = @_;
Subroutine range: not called CC=1 SCAR=6.9
Pod documented
844  
845 0 return array($data, 'range', @args);
846 }
847  
848 sub regexp ($;$@) {
849 0 ▶ my ($data, $code, @args) = @_;
Subroutine regexp: not called CC=2 SCAR=17.9
Pod documented
850  
851 0 require Venus::Regexp;
852  
853 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
854 0 return Venus::Regexp->new($data);
855 }
856  
857 0 return Venus::Regexp->new($data)->$code(@args);
858 }
859  
860 sub render ($;$) {
861 0 ▶ my ($data, $args) = @_;
Subroutine render: not called CC=2 SCAR=17.9
Pod documented
862  
863 0 ▶ return template($data, 'render', undef, $args || {});
Condition0%0/2
$args || {}
l!l
00
MC/DC0%0/1
$args || {}
$args
Truth table0%0/2
A
A= $args
Aresult
11
00
864 }
865  
866 sub replace ($;$@) {
867 0 ▶ my ($data, $code, @args) = @_;
Subroutine replace: not called CC=3 SCAR=24.8
Pod documented
868  
869 0 my @keys = qw(
870 string
871 regexp
872 substr
873 );
874  
875 0 ▶ my @data = (ref $data eq 'ARRAY' ? (map +(shift(@keys), $_), @{$data}) : $data);
Branch: 1 branch
BranchTrueFalseTotal
ref $data eq 'ARRAY' ? : 0 0 0
876  
877 0 require Venus::Replace;
878  
879 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
880 0 return Venus::Replace->new(@data);
881 }
882  
883 0 return Venus::Replace->new(@data)->$code(@args);
884 }
885  
886 sub resolve ($;@) {
887 0 ▶ my ($data, @args) = @_;
Subroutine resolve: not called CC=1 SCAR=6.9
Pod documented
888  
889 0 return container($data, 'resolve', @args);
890 }
891  
892 sub roll (@) {
893  
894 0 ▶ return (@_[1,0,2..$#_]);
Subroutine roll: not called CC=1 SCAR=6.9
Pod documented
895 }
896  
897 sub schema ($;$@) {
898 0 ▶ my ($data, $code, @args) = @_;
Subroutine schema: not called CC=2 SCAR=17.9
Pod documented
899  
900 0 require Venus::Schema;
901  
902 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
903 0 return Venus::Schema->new($data);
904 }
905  
906 0 return Venus::Schema->new($data)->$code(@args);
907 }
908  
909 sub search ($;$@) {
910 0 ▶ my ($data, $code, @args) = @_;
Subroutine search: not called CC=3 SCAR=24.8
Pod documented
911  
912 0 my @keys = qw(
913 string
914 regexp
915 );
916  
917 0 ▶ my @data = (ref $data eq 'ARRAY' ? (map +(shift(@keys), $_), @{$data}) : $data);
Branch: 1 branch
BranchTrueFalseTotal
ref $data eq 'ARRAY' ? : 0 0 0
918  
919 0 require Venus::Search;
920  
921 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
922 0 return Venus::Search->new(@data);
923 }
924  
925 0 return Venus::Search->new(@data)->$code(@args);
926 }
927  
928 sub space ($;$@) {
929 0 ▶ my ($data, $code, @args) = @_;
Subroutine space: not called CC=2 SCAR=17.9
Pod documented
930  
931 0 require Venus::Space;
932  
933 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
934 0 return Venus::Space->new($data);
935 }
936  
937 0 return Venus::Space->new($data)->$code(@args);
938 }
939  
940 sub string ($;$@) {
941 0 ▶ my ($data, $code, @args) = @_;
Subroutine string: not called CC=2 SCAR=17.9
Pod documented
942  
943 0 require Venus::String;
944  
945 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
946 0 return Venus::String->new($data);
947 }
948  
949 0 return Venus::String->new($data)->$code(@args);
950 }
951  
952 sub syscall ($;@) {
953 0 ▶ my (@args) = @_;
Subroutine syscall: not called CC=11 SCAR=48.8
Pod documented
954  
955 0 require Venus::Os;
956  
957 0 ▶ for (my $i = 0; $i < @args; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @args) 0 0 0
958 0 ▶ if ($args[$i] =~ /^\|+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args[$i] =~ /^\|+$/u) 0 0 0
959 0 next;
960 }
961 0 ▶ if ($args[$i] =~ /^\&+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args[$i] =~ /^\&+$/u) 0 0 0
962 0 next;
963 }
964 0 ▶ if ($args[$i] =~ /^\w+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args[$i] =~ /^\w+$/u) 0 0 0
965 0 next;
966 }
967 0 ▶ if ($args[$i] =~ /^[<>]+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args[$i] =~ /^[<>]+$/u) 0 0 0
968 0 next;
969 }
970 0 ▶ if ($args[$i] =~ /^\d[<>&]+\d?$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args[$i] =~ /^\d[<>&]+\d?$/u) 0 0 0
971 0 next;
972 }
973 0 ▶ if ($args[$i] =~ /\$[A-Z]\w+/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args[$i] =~ /\$[A-Z]\w+/u) 0 0 0
974 0 next;
975 }
976 0 ▶ if ($args[$i] =~ /^\$\((.*)\)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args[$i] =~ /^\$\((.*)\)$/u) 0 0 0
977 0 next;
978 }
979 0 $args[$i] = Venus::Os->quote($args[$i]);
980 }
981  
982 0 my ($data, $exit, $code) = (_qx(@args));
983  
984 0 ▶ return wantarray ? ($data, $code) : (($exit == 0) ? true() : false());
Branch: 2 branches
BranchTrueFalseTotal
wantarray ? : 0 0 0
$exit == 0 ? : 0 0 0
985 }
986  
987 sub template ($;$@) {
988 0 ▶ my ($data, $code, @args) = @_;
Subroutine template: not called CC=2 SCAR=17.9
Pod documented
989  
990 0 require Venus::Template;
991  
992 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
993 0 return Venus::Template->new($data);
994 }
995  
996 0 return Venus::Template->new($data)->$code(@args);
997 }
998  
999 sub test ($;$@) {
1000 0 ▶ my ($data, $code, @args) = @_;
Subroutine test: not called CC=2 SCAR=17.9
Pod documented
1001  
1002 0 require Venus::Test;
1003  
1004 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
1005 0 return Venus::Test->new($data);
1006 }
1007  
1008 0 return Venus::Test->new($data)->$code(@args);
1009 }
1010  
1011 sub text {
1012 0 ▶ my (@args) = @_;
Subroutine text: not called CC=2 SCAR=17.9
Pod documented
1013  
1014 0 my $file = (grep -f, (caller(0))[1], $0)[0];
1015  
1016 0 my $data = data($file);
1017  
1018 0 ▶ return $data->text->string(@args > 1 ? @args : (undef, @args));
Branch: 1 branch
BranchTrueFalseTotal
@args > 1 ? : 0 0 0
1019 }
1020  
1021 sub then (@) {
1022  
1023 0 ▶ return ($_[0], call(@_));
Subroutine then: not called CC=1 SCAR=6.9
Pod documented
1024 }
1025  
1026 sub throw ($;$@) {
1027 0 ▶ my ($data, $code, @args) = @_;
Subroutine throw: not called CC=16 SCAR=56.1
Pod documented
1028  
1029 0 require Venus::Throw;
1030  
1031 0 my $throw = Venus::Throw->new(context => (caller(1))[3])->do(
1032 frame => 1,
1033 );
1034  
1035 0 ▶ if (ref $data ne 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data ne 'HASH') { } 0 0 0
1036 0 ▶ $throw->package($data) if $data;
Branch: 1 branch
BranchTrueFalseTotal
if $data 0 0 0
1037 }
1038 else {
1039 0 ▶ if (exists $data->{as}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $data->{"as"}) 0 0 0
1040 0 $throw->as($data->{as});
1041 }
1042 0 ▶ if (exists $data->{capture}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $data->{"capture"}) 0 0 0
1043 0 $throw->capture(@{$data->{capture}});
1044 }
1045 0 ▶ if (exists $data->{context}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $data->{"context"}) 0 0 0
1046 0 $throw->context($data->{context});
1047 }
1048 0 ▶ if (exists $data->{error}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $data->{"error"}) 0 0 0
1049 0 $throw->error($data->{error});
1050 }
1051 0 ▶ if (exists $data->{frame}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $data->{"frame"}) 0 0 0
1052 0 $throw->frame($data->{frame});
1053 }
1054 0 ▶ if (exists $data->{message}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $data->{"message"}) 0 0 0
1055 0 $throw->message($data->{message});
1056 }
1057 0 ▶ if (exists $data->{name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $data->{"name"}) 0 0 0
1058 0 $throw->name($data->{name});
1059 }
1060 0 ▶ if (exists $data->{package}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $data->{"package"}) 0 0 0
1061 0 $throw->package($data->{package});
1062 }
1063 0 ▶ if (exists $data->{parent}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $data->{"parent"}) 0 0 0
1064 0 $throw->parent($data->{parent});
1065 }
1066 0 ▶ if (exists $data->{stash}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $data->{"stash"}) 0 0 0
1067 0 $throw->stash($_, $data->{stash}->{$_}) for keys %{$data->{stash}};
1068 }
1069 0 ▶ if (exists $data->{on}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $data->{"on"}) 0 0 0
1070 0 $throw->on($data->{on});
1071 }
1072 }
1073  
1074 0 ▶ return $throw if !$code;
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 0 0
1075  
1076 0 return $throw->$code(@args);
1077 }
1078  
1079 sub true () {
1080  
1081 24004 ▶ require Venus::True;
Subroutine true: called CC=1 SCAR=0.0
Pod documented
1082  
1083 24004 return Venus::True->value;
1084 }
1085  
1086 sub try ($;$@) {
1087 0 ▶ my ($data, $code, @args) = @_;
Subroutine try: not called CC=2 SCAR=17.9
Pod documented
1088  
1089 0 require Venus::Try;
1090  
1091 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
1092 0 return Venus::Try->new($data);
1093 }
1094  
1095 0 return Venus::Try->new($data)->$code(@args);
1096 }
1097  
1098 sub type ($;$@) {
1099 0 ▶ my ($data, $code, @args) = @_;
Subroutine type: not called CC=2 SCAR=17.9
Pod documented
1100  
1101 0 require Venus::Type;
1102  
1103 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
1104 0 return Venus::Type->new($data);
1105 }
1106  
1107 0 return Venus::Type->new($data)->$code(@args);
1108 }
1109  
1110 sub unpack (@) {
1111 0 ▶ my (@args) = @_;
Subroutine unpack: not called CC=1 SCAR=6.9
Pod documented
1112  
1113 0 require Venus::Unpack;
1114  
1115 0 return Venus::Unpack->new->do('args', @args)->all;
1116 }
1117  
1118 sub vars ($;$@) {
1119 0 ▶ my ($data, $code, @args) = @_;
Subroutine vars: not called CC=2 SCAR=17.9
Pod documented
1120  
1121 0 require Venus::Vars;
1122  
1123 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
1124 0 return Venus::Vars->new($data);
1125 }
1126  
1127 0 return Venus::Vars->new($data)->$code(@args);
1128 }
1129  
1130 sub venus ($;@) {
1131 0 ▶ my ($name, @args) = @_;
Subroutine venus: not called CC=2 SCAR=17.9
Pod documented
1132  
1133 0 ▶ @args = ('new') if !@args;
Branch: 1 branch
BranchTrueFalseTotal
unless @args 0 0 0
1134  
1135 0 return chain(\space(join('/', 'Venus', $name))->package, @args);
1136 }
1137  
1138 sub work ($) {
1139 0 ▶ my ($data) = @_;
Subroutine work: not called CC=1 SCAR=6.9
Pod documented
1140  
1141 0 require Venus::Process;
1142  
1143 0 return Venus::Process->new->do('work', $data);
1144 }
1145  
1146 sub wrap ($;$) {
1147 0 ▶ my ($data, $name) = @_;
Subroutine wrap: not called CC=3 SCAR=18.1
Pod documented
1148  
1149 0 ▶ return if !@_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
1150  
1151 0 ▶ my $moniker = $name // $data =~ s/\W//gr;
Condition0%0/3
$name // $data =~ s/\W//gru
l!l&&r!l&&!r
000
MC/DC0%0/2
$name // $data =~ s/\W//gru
$name $data =~ s/\W//gru
Truth table0%0/3
A // B
A= $nameB= $data =~ s/\W//gru
ABresult
1X1
011
000
1152 0 my $caller = caller(0);
1153  
1154 96 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
1155 96 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
1156  
1157 0 ▶ return *{"${caller}::${moniker}"} = sub {@_ ? make($data, @_) : $data};
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
1158 }
1159  
1160 sub yaml (;$$) {
1161 0 ▶ my ($code, $data) = @_;
Subroutine yaml: not called CC=4 SCAR=30.0
Pod documented
1162  
1163 0 require Venus::Yaml;
1164  
1165 0 ▶ if (!$code) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code) 0 0 0
1166 0 return Venus::Yaml->new;
1167 }
1168  
1169 0 ▶ if (lc($code) eq 'decode') {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $code eq "decode") 0 0 0
1170 0 return Venus::Yaml->new->decode($data);
1171 }
1172  
1173 0 ▶ if (lc($code) eq 'encode') {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $code eq "encode") 0 0 0
1174 0 return Venus::Yaml->new(value => $data)->encode;
1175 }
1176  
1177 0 return fault(qq(Invalid "yaml" action "$code"));
1178 }
1179  
1180 96 1;
1181  
1182  
1183 =head1 NAME
1184  
1185 Venus - OO Library
1186  
1187 =cut
1188  
1189 =head1 ABSTRACT
1190  
1191 OO Standard Library for Perl 5
1192  
1193 =cut
1194  
1195 =head1 VERSION
1196  
1197 4.11
1198  
1199 =cut
1200  
1201 =head1 SYNOPSIS
1202  
1203 package main;
1204  
1205 use Venus 'catch', 'error', 'raise';
1206  
1207 # error handling
1208 my ($error, $result) = catch {
1209 error;
1210 };
1211  
1212 # boolean keywords
1213 if ($result) {
1214 error;
1215 }
1216  
1217 # raise exceptions
1218 if ($result) {
1219 raise 'MyApp::Error';
1220 }
1221  
1222 # boolean keywords, and more!
1223 true ne false;
1224  
1225 =cut
1226  
1227 =head1 DESCRIPTION
1228  
1229 This library provides an object-orientation framework and extendible standard
1230 library for Perl 5 with classes which wrap most native Perl data types. Venus
1231 has a simple modular architecture, robust library of classes, methods, and
1232 roles, supports pure-Perl autoboxing, advanced exception handling, "true" and
1233 "false" functions, package introspection, command-line options parsing, and
1234 more. This package will always automatically exports C<true> and C<false>
1235 keyword functions (unless existing routines of the same name already exist in
1236 the calling package or its parents), otherwise exports keyword functions as
1237 requested at import. This library requires Perl C<5.18+>.
1238  
1239 =head1 CAPABILITIES
1240  
1241 The following is a short list of capabilities:
1242  
1243 =over 4
1244  
1245 =item *
1246  
1247 Perl 5.18.0+
1248  
1249 =item *
1250  
1251 Zero Dependencies
1252  
1253 =item *
1254  
1255 Fast Object-Orientation
1256  
1257 =item *
1258  
1259 Robust Standard Library
1260  
1261 =item *
1262  
1263 Intuitive Value Classes
1264  
1265 =item *
1266  
1267 Pure Perl Autoboxing
1268  
1269 =item *
1270  
1271 Convenient Utility Classes
1272  
1273 =item *
1274  
1275 Simple Package Reflection
1276  
1277 =item *
1278  
1279 Flexible Exception Handling
1280  
1281 =item *
1282  
1283 Composable Standards
1284  
1285 =item *
1286  
1287 Pluggable (no monkeypatching)
1288  
1289 =item *
1290  
1291 Proxyable Methods
1292  
1293 =item *
1294  
1295 Type Assertions
1296  
1297 =item *
1298  
1299 Type Coercions
1300  
1301 =item *
1302  
1303 Value Casting
1304  
1305 =item *
1306  
1307 Boolean Values
1308  
1309 =item *
1310  
1311 Complete Documentation
1312  
1313 =item *
1314  
1315 Complete Test Coverage
1316  
1317 =back
1318  
1319 =cut
1320  
1321 =head1 FUNCTIONS
1322  
1323 This package provides the following functions:
1324  
1325 =cut
1326  
1327 =head2 args
1328  
1329 args(arrayref $value, string | coderef $code, any @args) (any)
1330  
1331 The args function builds and returns a L<Venus::Args> object, or dispatches to
1332 the coderef or method provided.
1333  
1334 I<Since C<3.10>>
1335  
1336 =over 4
1337  
1338 =item args example 1
1339  
1340 package main;
1341  
1342 use Venus 'args';
1343  
1344 my $args = args ['--resource', 'users'];
1345  
1346 # bless({...}, 'Venus::Args')
1347  
1348 =back
1349  
1350 =over 4
1351  
1352 =item args example 2
1353  
1354 package main;
1355  
1356 use Venus 'args';
1357  
1358 my $args = args ['--resource', 'users'], 'indexed';
1359  
1360 # {0 => '--resource', 1 => 'users'}
1361  
1362 =back
1363  
1364 =cut
1365  
1366 =head2 array
1367  
1368 array(arrayref | hashref $value, string | coderef $code, any @args) (any)
1369  
1370 The array function builds and returns a L<Venus::Array> object, or dispatches
1371 to the coderef or method provided.
1372  
1373 I<Since C<2.55>>
1374  
1375 =over 4
1376  
1377 =item array example 1
1378  
1379 package main;
1380  
1381 use Venus 'array';
1382  
1383 my $array = array [];
1384  
1385 # bless({...}, 'Venus::Array')
1386  
1387 =back
1388  
1389 =over 4
1390  
1391 =item array example 2
1392  
1393 package main;
1394  
1395 use Venus 'array';
1396  
1397 my $array = array [1..4], 'push', 5..9;
1398  
1399 # [1..9]
1400  
1401 =back
1402  
1403 =cut
1404  
1405 =head2 arrayref
1406  
1407 arrayref(any @args) (arrayref)
1408  
1409 The arrayref function takes a list of arguments and returns a arrayref.
1410  
1411 I<Since C<3.10>>
1412  
1413 =over 4
1414  
1415 =item arrayref example 1
1416  
1417 package main;
1418  
1419 use Venus 'arrayref';
1420  
1421 my $arrayref = arrayref(content => 'example');
1422  
1423 # [content => "example"]
1424  
1425 =back
1426  
1427 =over 4
1428  
1429 =item arrayref example 2
1430  
1431 package main;
1432  
1433 use Venus 'arrayref';
1434  
1435 my $arrayref = arrayref([content => 'example']);
1436  
1437 # [content => "example"]
1438  
1439 =back
1440  
1441 =over 4
1442  
1443 =item arrayref example 3
1444  
1445 package main;
1446  
1447 use Venus 'arrayref';
1448  
1449 my $arrayref = arrayref('content');
1450  
1451 # ['content']
1452  
1453 =back
1454  
1455 =cut
1456  
1457 =head2 assert
1458  
1459 assert(any $data, string $expr) (any)
1460  
1461 The assert function builds a L<Venus::Assert> object and returns the result of
1462 a L<Venus::Assert/validate> operation.
1463  
1464 I<Since C<2.40>>
1465  
1466 =over 4
1467  
1468 =item assert example 1
1469  
1470 package main;
1471  
1472 use Venus 'assert';
1473  
1474 my $assert = assert(1234567890, 'number');
1475  
1476 # 1234567890
1477  
1478 =back
1479  
1480 =over 4
1481  
1482 =item assert example 2
1483  
1484 package main;
1485  
1486 use Venus 'assert';
1487  
1488 my $assert = assert(1234567890, 'float');
1489  
1490 # Exception! (isa Venus::Check::Error)
1491  
1492 =back
1493  
1494 =over 4
1495  
1496 =item assert example 3
1497  
1498 package main;
1499  
1500 use Venus 'assert';
1501  
1502 my $assert = assert(1234567890, 'number | float');
1503  
1504 # 1234567890
1505  
1506 =back
1507  
1508 =cut
1509  
1510 =head2 async
1511  
1512 async(coderef $code, any @args) (Venus::Future)
1513  
1514 The async function accepts a callback and executes it asynchronously via
1515 L<Venus::Process/future>. This function returns a L<Venus::Future> object which
1516 can be fulfilled via L<Venus::Future/wait>.
1517  
1518 I<Since C<3.40>>
1519  
1520 =over 4
1521  
1522 =item async example 1
1523  
1524 package main;
1525  
1526 use Venus 'async';
1527  
1528 my $async = async sub{
1529 'done'
1530 };
1531  
1532 # bless({...}, 'Venus::Future')
1533  
1534 =back
1535  
1536 =cut
1537  
1538 =head2 atom
1539  
1540 atom(any $value) (Venus::Atom)
1541  
1542 The atom function builds and returns a L<Venus::Atom> object.
1543  
1544 I<Since C<3.55>>
1545  
1546 =over 4
1547  
1548 =item atom example 1
1549  
1550 package main;
1551  
1552 use Venus 'atom';
1553  
1554 my $atom = atom 'super-admin';
1555  
1556 # bless({scope => sub{...}}, "Venus::Atom")
1557  
1558 # "$atom"
1559  
1560 # "super-admin"
1561  
1562 =back
1563  
1564 =cut
1565  
1566 =head2 await
1567  
1568 await(Venus::Future $future, number $timeout) (any)
1569  
1570 The await function accepts a L<Venus::Future> object and eventually returns a
1571 value (or values) for it. The value(s) returned are the return values or
1572 emissions from the asychronous callback executed with L</async> which produced
1573 the process object.
1574  
1575 I<Since C<3.40>>
1576  
1577 =over 4
1578  
1579 =item await example 1
1580  
1581 package main;
1582  
1583 use Venus 'async', 'await';
1584  
1585 my $process;
1586  
1587 my $async = async sub{
1588 return 'done';
1589 };
1590  
1591 my $await = await $async;
1592  
1593 # bless(..., "Venus::Future")
1594  
1595 =back
1596  
1597 =cut
1598  
1599 =head2 bool
1600  
1601 bool(any $value) (Venus::Boolean)
1602  
1603 The bool function builds and returns a L<Venus::Boolean> object.
1604  
1605 I<Since C<2.55>>
1606  
1607 =over 4
1608  
1609 =item bool example 1
1610  
1611 package main;
1612  
1613 use Venus 'bool';
1614  
1615 my $bool = bool;
1616  
1617 # bless({value => 0}, 'Venus::Boolean')
1618  
1619 =back
1620  
1621 =over 4
1622  
1623 =item bool example 2
1624  
1625 package main;
1626  
1627 use Venus 'bool';
1628  
1629 my $bool = bool 1_000;
1630  
1631 # bless({value => 1}, 'Venus::Boolean')
1632  
1633 =back
1634  
1635 =cut
1636  
1637 =head2 box
1638  
1639 box(any $data) (Venus::Box)
1640  
1641 The box function returns a L<Venus::Box> object for the argument provided.
1642  
1643 I<Since C<2.32>>
1644  
1645 =over 4
1646  
1647 =item box example 1
1648  
1649 package main;
1650  
1651 use Venus 'box';
1652  
1653 my $box = box({});
1654  
1655 # bless({value => bless({value => {}}, 'Venus::Hash')}, 'Venus::Box')
1656  
1657 =back
1658  
1659 =over 4
1660  
1661 =item box example 2
1662  
1663 package main;
1664  
1665 use Venus 'box';
1666  
1667 my $box = box([]);
1668  
1669 # bless({value => bless({value => []}, 'Venus::Array')}, 'Venus::Box')
1670  
1671 =back
1672  
1673 =cut
1674  
1675 =head2 call
1676  
1677 call(string | object | coderef $data, any @args) (any)
1678  
1679 The call function dispatches function and method calls to a package and returns
1680 the result.
1681  
1682 I<Since C<2.32>>
1683  
1684 =over 4
1685  
1686 =item call example 1
1687  
1688 package main;
1689  
1690 use Venus 'call';
1691  
1692 require Digest::SHA;
1693  
1694 my $result = call(\'Digest::SHA', 'new');
1695  
1696 # bless(do{\(my $o = '...')}, 'digest::sha')
1697  
1698 =back
1699  
1700 =over 4
1701  
1702 =item call example 2
1703  
1704 package main;
1705  
1706 use Venus 'call';
1707  
1708 require Digest::SHA;
1709  
1710 my $result = call('Digest::SHA', 'sha1_hex');
1711  
1712 # "da39a3ee5e6b4b0d3255bfef95601890afd80709"
1713  
1714 =back
1715  
1716 =over 4
1717  
1718 =item call example 3
1719  
1720 package main;
1721  
1722 use Venus 'call';
1723  
1724 require Venus::Hash;
1725  
1726 my $result = call(sub{'Venus::Hash'->new(@_)}, {1..4});
1727  
1728 # bless({value => {1..4}}, 'Venus::Hash')
1729  
1730 =back
1731  
1732 =over 4
1733  
1734 =item call example 4
1735  
1736 package main;
1737  
1738 use Venus 'call';
1739  
1740 require Venus::Box;
1741  
1742 my $result = call(Venus::Box->new(value => {}), 'merge', {1..4});
1743  
1744 # bless({value => bless({value => {1..4}}, 'Venus::Hash')}, 'Venus::Box')
1745  
1746 =back
1747  
1748 =cut
1749  
1750 =head2 cast
1751  
1752 cast(any $data, string $type) (object)
1753  
1754 The cast function returns the argument provided as an object, promoting native
1755 Perl data types to data type objects. The optional second argument can be the
1756 name of the type for the object to cast to explicitly.
1757  
1758 I<Since C<1.40>>
1759  
1760 =over 4
1761  
1762 =item cast example 1
1763  
1764 package main;
1765  
1766 use Venus 'cast';
1767  
1768 my $undef = cast;
1769  
1770 # bless({value => undef}, "Venus::Undef")
1771  
1772 =back
1773  
1774 =over 4
1775  
1776 =item cast example 2
1777  
1778 package main;
1779  
1780 use Venus 'cast';
1781  
1782 my @booleans = map cast, true, false;
1783  
1784 # (bless({value => 1}, "Venus::Boolean"), bless({value => 0}, "Venus::Boolean"))
1785  
1786 =back
1787  
1788 =over 4
1789  
1790 =item cast example 3
1791  
1792 package main;
1793  
1794 use Venus 'cast';
1795  
1796 my $example = cast bless({}, "Example");
1797  
1798 # bless({value => 1}, "Example")
1799  
1800 =back
1801  
1802 =over 4
1803  
1804 =item cast example 4
1805  
1806 package main;
1807  
1808 use Venus 'cast';
1809  
1810 my $float = cast 1.23;
1811  
1812 # bless({value => "1.23"}, "Venus::Float")
1813  
1814 =back
1815  
1816 =cut
1817  
1818 =head2 catch
1819  
1820 catch(coderef $block) (Venus::Error, any)
1821  
1822 The catch function executes the code block trapping errors and returning the
1823 caught exception in scalar context, and also returning the result as a second
1824 argument in list context.
1825  
1826 I<Since C<0.01>>
1827  
1828 =over 4
1829  
1830 =item catch example 1
1831  
1832 package main;
1833  
1834 use Venus 'catch';
1835  
1836 my $error = catch {die};
1837  
1838 $error;
1839  
1840 # "Died at ..."
1841  
1842 =back
1843  
1844 =over 4
1845  
1846 =item catch example 2
1847  
1848 package main;
1849  
1850 use Venus 'catch';
1851  
1852 my ($error, $result) = catch {error};
1853  
1854 $error;
1855  
1856 # bless({...}, 'Venus::Error')
1857  
1858 =back
1859  
1860 =over 4
1861  
1862 =item catch example 3
1863  
1864 package main;
1865  
1866 use Venus 'catch';
1867  
1868 my ($error, $result) = catch {true};
1869  
1870 $result;
1871  
1872 # 1
1873  
1874 =back
1875  
1876 =cut
1877  
1878 =head2 caught
1879  
1880 caught(object $error, string | tuple[string, string] $identity, coderef $block) (any)
1881  
1882 The caught function evaluates the exception object provided and validates its
1883 identity and name (if provided) then executes the code block provided returning
1884 the result of the callback. If no callback is provided this function returns
1885 the exception object on success and C<undef> on failure.
1886  
1887 I<Since C<1.95>>
1888  
1889 =over 4
1890  
1891 =item caught example 1
1892  
1893 package main;
1894  
1895 use Venus 'catch', 'caught', 'error';
1896  
1897 my $error = catch { error };
1898  
1899 my $result = caught $error, 'Venus::Error';
1900  
1901 # bless(..., 'Venus::Error')
1902  
1903 =back
1904  
1905 =over 4
1906  
1907 =item caught example 2
1908  
1909 package main;
1910  
1911 use Venus 'catch', 'caught', 'raise';
1912  
1913 my $error = catch { raise 'Example::Error' };
1914  
1915 my $result = caught $error, 'Venus::Error';
1916  
1917 # bless(..., 'Venus::Error')
1918  
1919 =back
1920  
1921 =over 4
1922  
1923 =item caught example 3
1924  
1925 package main;
1926  
1927 use Venus 'catch', 'caught', 'raise';
1928  
1929 my $error = catch { raise 'Example::Error' };
1930  
1931 my $result = caught $error, 'Example::Error';
1932  
1933 # bless(..., 'Venus::Error')
1934  
1935 =back
1936  
1937 =over 4
1938  
1939 =item caught example 4
1940  
1941 package main;
1942  
1943 use Venus 'catch', 'caught', 'raise';
1944  
1945 my $error = catch { raise 'Example::Error', { name => 'on.test' } };
1946  
1947 my $result = caught $error, ['Example::Error', 'on.test'];
1948  
1949 # bless(..., 'Venus::Error')
1950  
1951 =back
1952  
1953 =over 4
1954  
1955 =item caught example 5
1956  
1957 package main;
1958  
1959 use Venus 'catch', 'caught', 'raise';
1960  
1961 my $error = catch { raise 'Example::Error', { name => 'on.recv' } };
1962  
1963 my $result = caught $error, ['Example::Error', 'on.send'];
1964  
1965 # undef
1966  
1967 =back
1968  
1969 =over 4
1970  
1971 =item caught example 6
1972  
1973 package main;
1974  
1975 use Venus 'catch', 'caught', 'error';
1976  
1977 my $error = catch { error };
1978  
1979 my $result = caught $error, ['Example::Error', 'on.send'];
1980  
1981 # undef
1982  
1983 =back
1984  
1985 =over 4
1986  
1987 =item caught example 7
1988  
1989 package main;
1990  
1991 use Venus 'catch', 'caught', 'error';
1992  
1993 my $error = catch { error };
1994  
1995 my $result = caught $error, ['Example::Error'];
1996  
1997 # undef
1998  
1999 =back
2000  
2001 =over 4
2002  
2003 =item caught example 8
2004  
2005 package main;
2006  
2007 use Venus 'catch', 'caught', 'error';
2008  
2009 my $error = catch { error };
2010  
2011 my $result = caught $error, 'Example::Error';
2012  
2013 # undef
2014  
2015 =back
2016  
2017 =over 4
2018  
2019 =item caught example 9
2020  
2021 package main;
2022  
2023 use Venus 'catch', 'caught', 'error';
2024  
2025 my $error = catch { error { name => 'on.send' } };
2026  
2027 my $result = caught $error, ['Venus::Error', 'on.send'];
2028  
2029 # bless(..., 'Venus::Error')
2030  
2031 =back
2032  
2033 =over 4
2034  
2035 =item caught example 10
2036  
2037 package main;
2038  
2039 use Venus 'catch', 'caught', 'error';
2040  
2041 my $error = catch { error { name => 'on.send.open' } };
2042  
2043 my $result = caught $error, ['Venus::Error', 'on.send'], sub {
2044 $error->stash('caught', true) if $error->is('on.send.open');
2045 return $error;
2046 };
2047  
2048 # bless(..., 'Venus::Error')
2049  
2050 =back
2051  
2052 =cut
2053  
2054 =head2 chain
2055  
2056 chain(string | object | coderef $self, string | within[arrayref, string] @args) (any)
2057  
2058 The chain function chains function and method calls to a package (and return
2059 values) and returns the result.
2060  
2061 I<Since C<2.32>>
2062  
2063 =over 4
2064  
2065 =item chain example 1
2066  
2067 package main;
2068  
2069 use Venus 'chain';
2070  
2071 my $result = chain('Venus::Path', ['new', 't'], 'exists');
2072  
2073 # 1
2074  
2075 =back
2076  
2077 =over 4
2078  
2079 =item chain example 2
2080  
2081 package main;
2082  
2083 use Venus 'chain';
2084  
2085 my $result = chain('Venus::Path', ['new', 't'], ['test', 'd']);
2086  
2087 # 1
2088  
2089 =back
2090  
2091 =cut
2092  
2093 =head2 check
2094  
2095 check(any $data, string $expr) (boolean)
2096  
2097 The check function builds a L<Venus::Assert> object and returns the result of
2098 a L<Venus::Assert/check> operation.
2099  
2100 I<Since C<2.40>>
2101  
2102 =over 4
2103  
2104 =item check example 1
2105  
2106 package main;
2107  
2108 use Venus 'check';
2109  
2110 my $check = check(rand, 'float');
2111  
2112 # true
2113  
2114 =back
2115  
2116 =over 4
2117  
2118 =item check example 2
2119  
2120 package main;
2121  
2122 use Venus 'check';
2123  
2124 my $check = check(rand, 'string');
2125  
2126 # false
2127  
2128 =back
2129  
2130 =cut
2131  
2132 =head2 clargs
2133  
2134 clargs(arrayref $args, arrayref $spec) (Venus::Args, Venus::Opts, Venus::Vars)
2135  
2136 The clargs function accepts a single arrayref of L<Getopt::Long> specs, or an
2137 arrayref of arguments followed by an arrayref of L<Getopt::Long> specs, and
2138 returns a three element list of L<Venus::Args>, L<Venus::Opts>, and
2139 L<Venus::Vars> objects. If only a single arrayref is provided, the arguments
2140 will be taken from C<@ARGV>.
2141  
2142 I<Since C<3.10>>
2143  
2144 =over 4
2145  
2146 =item clargs example 1
2147  
2148 package main;
2149  
2150 use Venus 'clargs';
2151  
2152 my ($args, $opts, $vars) = clargs;
2153  
2154 # (
2155 # bless(..., 'Venus::Args'),
2156 # bless(..., 'Venus::Opts'),
2157 # bless(..., 'Venus::Vars')
2158 # )
2159  
2160 =back
2161  
2162 =over 4
2163  
2164 =item clargs example 2
2165  
2166 package main;
2167  
2168 use Venus 'clargs';
2169  
2170 my ($args, $opts, $vars) = clargs ['resource|r=s', 'help|h'];
2171  
2172 # (
2173 # bless(..., 'Venus::Args'),
2174 # bless(..., 'Venus::Opts'),
2175 # bless(..., 'Venus::Vars')
2176 # )
2177  
2178 =back
2179  
2180 =over 4
2181  
2182 =item clargs example 3
2183  
2184 package main;
2185  
2186 use Venus 'clargs';
2187  
2188 my ($args, $opts, $vars) = clargs ['--resource', 'help'],
2189 ['resource|r=s', 'help|h'];
2190  
2191 # (
2192 # bless(..., 'Venus::Args'),
2193 # bless(..., 'Venus::Opts'),
2194 # bless(..., 'Venus::Vars')
2195 # )
2196  
2197 =back
2198  
2199 =cut
2200  
2201 =head2 cli
2202  
2203 cli(arrayref $args) (Venus::Cli)
2204  
2205 The cli function builds and returns a L<Venus::Cli> object.
2206  
2207 I<Since C<2.55>>
2208  
2209 =over 4
2210  
2211 =item cli example 1
2212  
2213 package main;
2214  
2215 use Venus 'cli';
2216  
2217 my $cli = cli;
2218  
2219 # bless({...}, 'Venus::Cli')
2220  
2221 =back
2222  
2223 =over 4
2224  
2225 =item cli example 2
2226  
2227 package main;
2228  
2229 use Venus 'cli';
2230  
2231 my $cli = cli ['--help'];
2232  
2233 # bless({...}, 'Venus::Cli')
2234  
2235 # $cli->set('opt', 'help', {})->opt('help');
2236  
2237 # 1
2238  
2239 =back
2240  
2241 =cut
2242  
2243 =head2 clone
2244  
2245 clone(ref $value) (ref)
2246  
2247 The clone function uses L<Storable/dclone> to perform a deep clone of the
2248 reference provided and returns a copy.
2249  
2250 I<Since C<3.55>>
2251  
2252 =over 4
2253  
2254 =item clone example 1
2255  
2256 package main;
2257  
2258 use Venus 'clone';
2259  
2260 my $orig = {1..4};
2261  
2262 my $clone = clone $orig;
2263  
2264 $orig->{3} = 5;
2265  
2266 my $result = $clone;
2267  
2268 # {1..4}
2269  
2270 =back
2271  
2272 =over 4
2273  
2274 =item clone example 2
2275  
2276 package main;
2277  
2278 use Venus 'clone';
2279  
2280 my $orig = {1,2,3,{1..4}};
2281  
2282 my $clone = clone $orig;
2283  
2284 $orig->{3}->{3} = 5;
2285  
2286 my $result = $clone;
2287  
2288 # {1,2,3,{1..4}}
2289  
2290 =back
2291  
2292 =cut
2293  
2294 =head2 code
2295  
2296 code(coderef $value, string | coderef $code, any @args) (any)
2297  
2298 The code function builds and returns a L<Venus::Code> object, or dispatches
2299 to the coderef or method provided.
2300  
2301 I<Since C<2.55>>
2302  
2303 =over 4
2304  
2305 =item code example 1
2306  
2307 package main;
2308  
2309 use Venus 'code';
2310  
2311 my $code = code sub {};
2312  
2313 # bless({...}, 'Venus::Code')
2314  
2315 =back
2316  
2317 =over 4
2318  
2319 =item code example 2
2320  
2321 package main;
2322  
2323 use Venus 'code';
2324  
2325 my $code = code sub {[1, @_]}, 'curry', 2,3,4;
2326  
2327 # sub {...}
2328  
2329 =back
2330  
2331 =cut
2332  
2333 =head2 config
2334  
2335 config(hashref $value, string | coderef $code, any @args) (any)
2336  
2337 The config function builds and returns a L<Venus::Config> object, or dispatches
2338 to the coderef or method provided.
2339  
2340 I<Since C<2.55>>
2341  
2342 =over 4
2343  
2344 =item config example 1
2345  
2346 package main;
2347  
2348 use Venus 'config';
2349  
2350 my $config = config {};
2351  
2352 # bless({...}, 'Venus::Config')
2353  
2354 =back
2355  
2356 =over 4
2357  
2358 =item config example 2
2359  
2360 package main;
2361  
2362 use Venus 'config';
2363  
2364 my $config = config {}, 'read_perl', '{"data"=>1}';
2365  
2366 # bless({...}, 'Venus::Config')
2367  
2368 =back
2369  
2370 =cut
2371  
2372 =head2 container
2373  
2374 container(hashref $value, string | coderef $code, any @args) (any)
2375  
2376 The container function builds and returns a L<Venus::Container> object, or
2377 dispatches to the coderef or method provided.
2378  
2379 I<Since C<3.20>>
2380  
2381 =over 4
2382  
2383 =item container example 1
2384  
2385 package main;
2386  
2387 use Venus 'container';
2388  
2389 my $container = container {};
2390  
2391 # bless({...}, 'Venus::Config')
2392  
2393 =back
2394  
2395 =over 4
2396  
2397 =item container example 2
2398  
2399 package main;
2400  
2401 use Venus 'container';
2402  
2403 my $data = {
2404 '$metadata' => {
2405 tmplog => "/tmp/log"
2406 },
2407 '$services' => {
2408 log => {
2409 package => "Venus/Path",
2410 argument => {
2411 '$metadata' => "tmplog"
2412 }
2413 }
2414 }
2415 };
2416  
2417 my $log = container $data, 'resolve', 'log';
2418  
2419 # bless({value => '/tmp/log'}, 'Venus::Path')
2420  
2421 =back
2422  
2423 =cut
2424  
2425 =head2 cop
2426  
2427 cop(string | object | coderef $self, string $name) (coderef)
2428  
2429 The cop function attempts to curry the given subroutine on the object or class
2430 and if successful returns a closure.
2431  
2432 I<Since C<2.32>>
2433  
2434 =over 4
2435  
2436 =item cop example 1
2437  
2438 package main;
2439  
2440 use Venus 'cop';
2441  
2442 my $coderef = cop('Digest::SHA', 'sha1_hex');
2443  
2444 # sub { ... }
2445  
2446 =back
2447  
2448 =over 4
2449  
2450 =item cop example 2
2451  
2452 package main;
2453  
2454 use Venus 'cop';
2455  
2456 require Digest::SHA;
2457  
2458 my $coderef = cop(Digest::SHA->new, 'digest');
2459  
2460 # sub { ... }
2461  
2462 =back
2463  
2464 =cut
2465  
2466 =head2 data
2467  
2468 data(string $value, string | coderef $code, any @args) (any)
2469  
2470 The data function builds and returns a L<Venus::Data> object, or dispatches
2471 to the coderef or method provided.
2472  
2473 I<Since C<2.55>>
2474  
2475 =over 4
2476  
2477 =item data example 1
2478  
2479 package main;
2480  
2481 use Venus 'data';
2482  
2483 my $data = data 't/data/sections';
2484  
2485 # bless({...}, 'Venus::Data')
2486  
2487 =back
2488  
2489 =over 4
2490  
2491 =item data example 2
2492  
2493 package main;
2494  
2495 use Venus 'data';
2496  
2497 my $data = data 't/data/sections', 'string', undef, 'name';
2498  
2499 # "Example #1\nExample #2"
2500  
2501 =back
2502  
2503 =cut
2504  
2505 =head2 date
2506  
2507 date(number $value, string | coderef $code, any @args) (any)
2508  
2509 The date function builds and returns a L<Venus::Date> object, or dispatches to
2510 the coderef or method provided.
2511  
2512 I<Since C<2.40>>
2513  
2514 =over 4
2515  
2516 =item date example 1
2517  
2518 package main;
2519  
2520 use Venus 'date';
2521  
2522 my $date = date time, 'string';
2523  
2524 # '0000-00-00T00:00:00Z'
2525  
2526 =back
2527  
2528 =over 4
2529  
2530 =item date example 2
2531  
2532 package main;
2533  
2534 use Venus 'date';
2535  
2536 my $date = date time, 'reset', 570672000;
2537  
2538 # bless({...}, 'Venus::Date')
2539  
2540 # $date->string;
2541  
2542 # '1988-02-01T00:00:00Z'
2543  
2544 =back
2545  
2546 =over 4
2547  
2548 =item date example 3
2549  
2550 package main;
2551  
2552 use Venus 'date';
2553  
2554 my $date = date time;
2555  
2556 # bless({...}, 'Venus::Date')
2557  
2558 =back
2559  
2560 =cut
2561  
2562 =head2 docs
2563  
2564 docs(any @args) (any)
2565  
2566 The docs function builds a L<Venus::Data> object using L<Venus::Data/docs> for
2567 the current file, i.e. L<perlfunc/__FILE__> or script, i.e. C<$0>, and returns
2568 the result of a L<Venus::Data/string> operation using the arguments provided.
2569  
2570 I<Since C<3.30>>
2571  
2572 =over 4
2573  
2574 =item docs example 1
2575  
2576 package main;
2577  
2578 use Venus 'docs';
2579  
2580 # =head1 ABSTRACT
2581 #
2582 # Example Abstract
2583 #
2584 # =cut
2585  
2586 my $docs = docs 'head1', 'ABSTRACT';
2587  
2588 # "Example Abstract"
2589  
2590 =back
2591  
2592 =over 4
2593  
2594 =item docs example 2
2595  
2596 package main;
2597  
2598 use Venus 'docs';
2599  
2600 # =head1 NAME
2601 #
2602 # Example #1
2603 #
2604 # =cut
2605 #
2606 # =head1 NAME
2607 #
2608 # Example #2
2609 #
2610 # =cut
2611  
2612 my $docs = docs 'head1', 'NAME';
2613  
2614 # "Example #1\nExample #2"
2615  
2616 =back
2617  
2618 =cut
2619  
2620 =head2 enum
2621  
2622 enum(arrayref | hashref $value) (Venus::Enum)
2623  
2624 The enum function builds and returns a L<Venus::Enum> object.
2625  
2626 I<Since C<3.55>>
2627  
2628 =over 4
2629  
2630 =item enum example 1
2631  
2632 package main;
2633  
2634 use Venus 'enum';
2635  
2636 my $themes = enum ['light', 'dark'];
2637  
2638 # bless({scope => sub{...}}, "Venus::Enum")
2639  
2640 # my $result = $themes->get('dark');
2641  
2642 # bless({scope => sub{...}}, "Venus::Enum")
2643  
2644 # "$result"
2645  
2646 # "dark"
2647  
2648 =back
2649  
2650 =over 4
2651  
2652 =item enum example 2
2653  
2654 package main;
2655  
2656 use Venus 'enum';
2657  
2658 my $themes = enum {
2659 light => 'light_theme',
2660 dark => 'dark_theme',
2661 };
2662  
2663 # bless({scope => sub{...}}, "Venus::Enum")
2664  
2665 # my $result = $themes->get('dark');
2666  
2667 # bless({scope => sub{...}}, "Venus::Enum")
2668  
2669 # "$result"
2670  
2671 # "dark_theme"
2672  
2673 =back
2674  
2675 =cut
2676  
2677 =head2 error
2678  
2679 error(maybe[hashref] $args) (Venus::Error)
2680  
2681 The error function throws a L<Venus::Error> exception object using the
2682 exception object arguments provided.
2683  
2684 I<Since C<0.01>>
2685  
2686 =over 4
2687  
2688 =item error example 1
2689  
2690 package main;
2691  
2692 use Venus 'error';
2693  
2694 my $error = error;
2695  
2696 # bless({...}, 'Venus::Error')
2697  
2698 =back
2699  
2700 =over 4
2701  
2702 =item error example 2
2703  
2704 package main;
2705  
2706 use Venus 'error';
2707  
2708 my $error = error {
2709 message => 'Something failed!',
2710 };
2711  
2712 # bless({message => 'Something failed!', ...}, 'Venus::Error')
2713  
2714 =back
2715  
2716 =cut
2717  
2718 =head2 false
2719  
2720 false() (boolean)
2721  
2722 The false function returns a falsy boolean value which is designed to be
2723 practically indistinguishable from the conventional numerical C<0> value.
2724  
2725 I<Since C<0.01>>
2726  
2727 =over 4
2728  
2729 =item false example 1
2730  
2731 package main;
2732  
2733 use Venus;
2734  
2735 my $false = false;
2736  
2737 # 0
2738  
2739 =back
2740  
2741 =over 4
2742  
2743 =item false example 2
2744  
2745 package main;
2746  
2747 use Venus;
2748  
2749 my $true = !false;
2750  
2751 # 1
2752  
2753 =back
2754  
2755 =cut
2756  
2757 =head2 fault
2758  
2759 fault(string $args) (Venus::Fault)
2760  
2761 The fault function throws a L<Venus::Fault> exception object and represents a
2762 system failure, and isn't meant to be caught.
2763  
2764 I<Since C<1.80>>
2765  
2766 =over 4
2767  
2768 =item fault example 1
2769  
2770 package main;
2771  
2772 use Venus 'fault';
2773  
2774 my $fault = fault;
2775  
2776 # bless({message => 'Exception!'}, 'Venus::Fault')
2777  
2778 =back
2779  
2780 =over 4
2781  
2782 =item fault example 2
2783  
2784 package main;
2785  
2786 use Venus 'fault';
2787  
2788 my $fault = fault 'Something failed!';
2789  
2790 # bless({message => 'Something failed!'}, 'Venus::Fault')
2791  
2792 =back
2793  
2794 =cut
2795  
2796 =head2 float
2797  
2798 float(string $value, string | coderef $code, any @args) (any)
2799  
2800 The float function builds and returns a L<Venus::Float> object, or dispatches
2801 to the coderef or method provided.
2802  
2803 I<Since C<2.55>>
2804  
2805 =over 4
2806  
2807 =item float example 1
2808  
2809 package main;
2810  
2811 use Venus 'float';
2812  
2813 my $float = float 1.23;
2814  
2815 # bless({...}, 'Venus::Float')
2816  
2817 =back
2818  
2819 =over 4
2820  
2821 =item float example 2
2822  
2823 package main;
2824  
2825 use Venus 'float';
2826  
2827 my $float = float 1.23, 'int';
2828  
2829 # 1
2830  
2831 =back
2832  
2833 =cut
2834  
2835 =head2 future
2836  
2837 future(coderef $code) (Venus::Future)
2838  
2839 The future function builds and returns a L<Venus::Future> object.
2840  
2841 I<Since C<3.55>>
2842  
2843 =over 4
2844  
2845 =item future example 1
2846  
2847 package main;
2848  
2849 use Venus 'future';
2850  
2851 my $future = future(sub{
2852 my ($resolve, $reject) = @_;
2853  
2854 return int(rand(2)) ? $resolve->result('pass') : $reject->result('fail');
2855 });
2856  
2857 # bless(..., "Venus::Future")
2858  
2859 # $future->is_pending;
2860  
2861 # false
2862  
2863 =back
2864  
2865 =cut
2866  
2867 =head2 gather
2868  
2869 gather(any $value, coderef $callback) (any)
2870  
2871 The gather function builds a L<Venus::Gather> object, passing it and the value
2872 provided to the callback provided, and returns the return value from
2873 L<Venus::Gather/result>.
2874  
2875 I<Since C<2.50>>
2876  
2877 =over 4
2878  
2879 =item gather example 1
2880  
2881 package main;
2882  
2883 use Venus 'gather';
2884  
2885 my $gather = gather ['a'..'d'];
2886  
2887 # bless({...}, 'Venus::Gather')
2888  
2889 # $gather->result;
2890  
2891 # undef
2892  
2893 =back
2894  
2895 =over 4
2896  
2897 =item gather example 2
2898  
2899 package main;
2900  
2901 use Venus 'gather';
2902  
2903 my $gather = gather ['a'..'d'], sub {{
2904 a => 1,
2905 b => 2,
2906 c => 3,
2907 }};
2908  
2909 # [1..3]
2910  
2911 =back
2912  
2913 =over 4
2914  
2915 =item gather example 3
2916  
2917 package main;
2918  
2919 use Venus 'gather';
2920  
2921 my $gather = gather ['e'..'h'], sub {{
2922 a => 1,
2923 b => 2,
2924 c => 3,
2925 }};
2926  
2927 # []
2928  
2929 =back
2930  
2931 =over 4
2932  
2933 =item gather example 4
2934  
2935 package main;
2936  
2937 use Venus 'gather';
2938  
2939 my $gather = gather ['a'..'d'], sub {
2940 my ($case) = @_;
2941  
2942 $case->when(sub{lc($_) eq 'a'})->then('a -> A');
2943 $case->when(sub{lc($_) eq 'b'})->then('b -> B');
2944 };
2945  
2946 # ['a -> A', 'b -> B']
2947  
2948 =back
2949  
2950 =over 4
2951  
2952 =item gather example 5
2953  
2954 package main;
2955  
2956 use Venus 'gather';
2957  
2958 my $gather = gather ['a'..'d'], sub {
2959  
2960 $_->when(sub{lc($_) eq 'a'})->then('a -> A');
2961 $_->when(sub{lc($_) eq 'b'})->then('b -> B');
2962 };
2963  
2964 # ['a -> A', 'b -> B']
2965  
2966 =back
2967  
2968 =cut
2969  
2970 =head2 hash
2971  
2972 hash(hashref $value, string | coderef $code, any @args) (any)
2973  
2974 The hash function builds and returns a L<Venus::Hash> object, or dispatches
2975 to the coderef or method provided.
2976  
2977 I<Since C<2.55>>
2978  
2979 =over 4
2980  
2981 =item hash example 1
2982  
2983 package main;
2984  
2985 use Venus 'hash';
2986  
2987 my $hash = hash {1..4};
2988  
2989 # bless({...}, 'Venus::Hash')
2990  
2991 =back
2992  
2993 =over 4
2994  
2995 =item hash example 2
2996  
2997 package main;
2998  
2999 use Venus 'hash';
3000  
3001 my $hash = hash {1..8}, 'pairs';
3002  
3003 # [[1, 2], [3, 4], [5, 6], [7, 8]]
3004  
3005 =back
3006  
3007 =cut
3008  
3009 =head2 hashref
3010  
3011 hashref(any @args) (hashref)
3012  
3013 The hashref function takes a list of arguments and returns a hashref.
3014  
3015 I<Since C<3.10>>
3016  
3017 =over 4
3018  
3019 =item hashref example 1
3020  
3021 package main;
3022  
3023 use Venus 'hashref';
3024  
3025 my $hashref = hashref(content => 'example');
3026  
3027 # {content => "example"}
3028  
3029 =back
3030  
3031 =over 4
3032  
3033 =item hashref example 2
3034  
3035 package main;
3036  
3037 use Venus 'hashref';
3038  
3039 my $hashref = hashref({content => 'example'});
3040  
3041 # {content => "example"}
3042  
3043 =back
3044  
3045 =over 4
3046  
3047 =item hashref example 3
3048  
3049 package main;
3050  
3051 use Venus 'hashref';
3052  
3053 my $hashref = hashref('content');
3054  
3055 # {content => undef}
3056  
3057 =back
3058  
3059 =over 4
3060  
3061 =item hashref example 4
3062  
3063 package main;
3064  
3065 use Venus 'hashref';
3066  
3067 my $hashref = hashref('content', 'example', 'algorithm');
3068  
3069 # {content => "example", algorithm => undef}
3070  
3071 =back
3072  
3073 =cut
3074  
3075 =head2 is_bool
3076  
3077 is_bool(any $arg) (boolean)
3078  
3079 The is_bool function returns L</true> if the value provided is a boolean value,
3080 not merely truthy, and L</false> otherwise.
3081  
3082 I<Since C<3.18>>
3083  
3084 =over 4
3085  
3086 =item is_bool example 1
3087  
3088 package main;
3089  
3090 use Venus 'is_bool';
3091  
3092 my $is_bool = is_bool true;
3093  
3094 # true
3095  
3096 =back
3097  
3098 =over 4
3099  
3100 =item is_bool example 2
3101  
3102 package main;
3103  
3104 use Venus 'is_bool';
3105  
3106 my $is_bool = is_bool false;
3107  
3108 # true
3109  
3110 =back
3111  
3112 =over 4
3113  
3114 =item is_bool example 3
3115  
3116 package main;
3117  
3118 use Venus 'is_bool';
3119  
3120 my $is_bool = is_bool 1;
3121  
3122 # false
3123  
3124 =back
3125  
3126 =over 4
3127  
3128 =item is_bool example 4
3129  
3130 package main;
3131  
3132 use Venus 'is_bool';
3133  
3134 my $is_bool = is_bool 0;
3135  
3136 # false
3137  
3138 =back
3139  
3140 =cut
3141  
3142 =head2 is_false
3143  
3144 is_false(any $data) (boolean)
3145  
3146 The is_false function accepts a scalar value and returns true if the value is
3147 falsy.
3148  
3149 I<Since C<3.04>>
3150  
3151 =over 4
3152  
3153 =item is_false example 1
3154  
3155 package main;
3156  
3157 use Venus 'is_false';
3158  
3159 my $is_false = is_false 0;
3160  
3161 # true
3162  
3163 =back
3164  
3165 =over 4
3166  
3167 =item is_false example 2
3168  
3169 package main;
3170  
3171 use Venus 'is_false';
3172  
3173 my $is_false = is_false 1;
3174  
3175 # false
3176  
3177 =back
3178  
3179 =cut
3180  
3181 =head2 is_true
3182  
3183 is_true(any $data) (boolean)
3184  
3185 The is_true function accepts a scalar value and returns true if the value is
3186 truthy.
3187  
3188 I<Since C<3.04>>
3189  
3190 =over 4
3191  
3192 =item is_true example 1
3193  
3194 package main;
3195  
3196 use Venus 'is_true';
3197  
3198 my $is_true = is_true 1;
3199  
3200 # true
3201  
3202 =back
3203  
3204 =over 4
3205  
3206 =item is_true example 2
3207  
3208 package main;
3209  
3210 use Venus 'is_true';
3211  
3212 my $is_true = is_true 0;
3213  
3214 # false
3215  
3216 =back
3217  
3218 =cut
3219  
3220 =head2 json
3221  
3222 json(string $call, any $data) (any)
3223  
3224 The json function builds a L<Venus::Json> object and will either
3225 L<Venus::Json/decode> or L<Venus::Json/encode> based on the argument provided
3226 and returns the result.
3227  
3228 I<Since C<2.40>>
3229  
3230 =over 4
3231  
3232 =item json example 1
3233  
3234 package main;
3235  
3236 use Venus 'json';
3237  
3238 my $decode = json 'decode', '{"codename":["Ready","Robot"],"stable":true}';
3239  
3240 # { codename => ["Ready", "Robot"], stable => 1 }
3241  
3242 =back
3243  
3244 =over 4
3245  
3246 =item json example 2
3247  
3248 package main;
3249  
3250 use Venus 'json';
3251  
3252 my $encode = json 'encode', { codename => ["Ready", "Robot"], stable => true };
3253  
3254 # '{"codename":["Ready","Robot"],"stable":true}'
3255  
3256 =back
3257  
3258 =over 4
3259  
3260 =item json example 3
3261  
3262 package main;
3263  
3264 use Venus 'json';
3265  
3266 my $json = json;
3267  
3268 # bless({...}, 'Venus::Json')
3269  
3270 =back
3271  
3272 =over 4
3273  
3274 =item json example 4
3275  
3276 package main;
3277  
3278 use Venus 'json';
3279  
3280 my $json = json 'class', {data => "..."};
3281  
3282 # Exception! (isa Venus::Fault)
3283  
3284 =back
3285  
3286 =cut
3287  
3288 =head2 list
3289  
3290 list(any @args) (any)
3291  
3292 The list function accepts a list of values and flattens any arrayrefs,
3293 returning a list of scalars.
3294  
3295 I<Since C<3.04>>
3296  
3297 =over 4
3298  
3299 =item list example 1
3300  
3301 package main;
3302  
3303 use Venus 'list';
3304  
3305 my @list = list 1..4;
3306  
3307 # (1..4)
3308  
3309 =back
3310  
3311 =over 4
3312  
3313 =item list example 2
3314  
3315 package main;
3316  
3317 use Venus 'list';
3318  
3319 my @list = list [1..4];
3320  
3321 # (1..4)
3322  
3323 =back
3324  
3325 =over 4
3326  
3327 =item list example 3
3328  
3329 package main;
3330  
3331 use Venus 'list';
3332  
3333 my @list = list [1..4], 5, [6..10];
3334  
3335 # (1..10)
3336  
3337 =back
3338  
3339 =cut
3340  
3341 =head2 load
3342  
3343 load(any $name) (Venus::Space)
3344  
3345 The load function loads the package provided and returns a L<Venus::Space> object.
3346  
3347 I<Since C<2.32>>
3348  
3349 =over 4
3350  
3351 =item load example 1
3352  
3353 package main;
3354  
3355 use Venus 'load';
3356  
3357 my $space = load 'Venus::Scalar';
3358  
3359 # bless({value => 'Venus::Scalar'}, 'Venus::Space')
3360  
3361 =back
3362  
3363 =cut
3364  
3365 =head2 log
3366  
3367 log(any @args) (Venus::Log)
3368  
3369 The log function prints the arguments provided to STDOUT, stringifying complex
3370 values, and returns a L<Venus::Log> object. If the first argument is a log
3371 level name, e.g. C<debug>, C<error>, C<fatal>, C<info>, C<trace>, or C<warn>,
3372 it will be used when emitting the event. The desired log level is specified by
3373 the C<VENUS_LOG_LEVEL> environment variable and defaults to C<trace>.
3374  
3375 I<Since C<2.40>>
3376  
3377 =over 4
3378  
3379 =item log example 1
3380  
3381 package main;
3382  
3383 use Venus 'log';
3384  
3385 my $log = log;
3386  
3387 # bless({...}, 'Venus::Log')
3388  
3389 # log time, rand, 1..9;
3390  
3391 # 00000000 0.000000, 1..9
3392  
3393 =back
3394  
3395 =cut
3396  
3397 =head2 make
3398  
3399 make(string $package, any @args) (any)
3400  
3401 The make function L<"calls"|Venus/call> the C<new> routine on the invocant and
3402 returns the result which should be a package string or an object.
3403  
3404 I<Since C<2.32>>
3405  
3406 =over 4
3407  
3408 =item make example 1
3409  
3410 package main;
3411  
3412 use Venus 'make';
3413  
3414 my $made = make('Digest::SHA');
3415  
3416 # bless(do{\(my $o = '...')}, 'Digest::SHA')
3417  
3418 =back
3419  
3420 =over 4
3421  
3422 =item make example 2
3423  
3424 package main;
3425  
3426 use Venus 'make';
3427  
3428 my $made = make('Digest', 'SHA');
3429  
3430 # bless(do{\(my $o = '...')}, 'Digest::SHA')
3431  
3432 =back
3433  
3434 =cut
3435  
3436 =head2 match
3437  
3438 match(any $value, coderef $callback) (any)
3439  
3440 The match function builds a L<Venus::Match> object, passing it and the value
3441 provided to the callback provided, and returns the return value from
3442 L<Venus::Match/result>.
3443  
3444 I<Since C<2.50>>
3445  
3446 =over 4
3447  
3448 =item match example 1
3449  
3450 package main;
3451  
3452 use Venus 'match';
3453  
3454 my $match = match 5;
3455  
3456 # bless({...}, 'Venus::Match')
3457  
3458 # $match->result;
3459  
3460 # undef
3461  
3462 =back
3463  
3464 =over 4
3465  
3466 =item match example 2
3467  
3468 package main;
3469  
3470 use Venus 'match';
3471  
3472 my $match = match 5, sub {{
3473 1 => 'one',
3474 2 => 'two',
3475 5 => 'five',
3476 }};
3477  
3478 # 'five'
3479  
3480 =back
3481  
3482 =over 4
3483  
3484 =item match example 3
3485  
3486 package main;
3487  
3488 use Venus 'match';
3489  
3490 my $match = match 5, sub {{
3491 1 => 'one',
3492 2 => 'two',
3493 3 => 'three',
3494 }};
3495  
3496 # undef
3497  
3498 =back
3499  
3500 =over 4
3501  
3502 =item match example 4
3503  
3504 package main;
3505  
3506 use Venus 'match';
3507  
3508 my $match = match 5, sub {
3509 my ($case) = @_;
3510  
3511 $case->when(sub{$_ < 5})->then('< 5');
3512 $case->when(sub{$_ > 5})->then('> 5');
3513 };
3514  
3515 # undef
3516  
3517 =back
3518  
3519 =over 4
3520  
3521 =item match example 5
3522  
3523 package main;
3524  
3525 use Venus 'match';
3526  
3527 my $match = match 6, sub {
3528 my ($case, $data) = @_;
3529  
3530 $case->when(sub{$_ < 5})->then("$data < 5");
3531 $case->when(sub{$_ > 5})->then("$data > 5");
3532 };
3533  
3534 # '6 > 5'
3535  
3536 =back
3537  
3538 =over 4
3539  
3540 =item match example 6
3541  
3542 package main;
3543  
3544 use Venus 'match';
3545  
3546 my $match = match 4, sub {
3547  
3548 $_->when(sub{$_ < 5})->then("$_[1] < 5");
3549 $_->when(sub{$_ > 5})->then("$_[1] > 5");
3550 };
3551  
3552 # '4 < 5'
3553  
3554 =back
3555  
3556 =cut
3557  
3558 =head2 merge
3559  
3560 merge(any @args) (any)
3561  
3562 The merge function returns a value which is a merger of all of the arguments
3563 provided.
3564  
3565 I<Since C<2.32>>
3566  
3567 =over 4
3568  
3569 =item merge example 1
3570  
3571 package main;
3572  
3573 use Venus 'merge';
3574  
3575 my $merged = merge({1..4}, {5, 6});
3576  
3577 # {1..6}
3578  
3579 =back
3580  
3581 =over 4
3582  
3583 =item merge example 2
3584  
3585 package main;
3586  
3587 use Venus 'merge';
3588  
3589 my $merged = merge({1..4}, {5, 6}, {7, 8, 9, 0});
3590  
3591 # {1..9, 0}
3592  
3593 =back
3594  
3595 =cut
3596  
3597 =head2 meta
3598  
3599 meta(string $value, string | coderef $code, any @args) (any)
3600  
3601 The meta function builds and returns a L<Venus::Meta> object, or dispatches to
3602 the coderef or method provided.
3603  
3604 I<Since C<2.55>>
3605  
3606 =over 4
3607  
3608 =item meta example 1
3609  
3610 package main;
3611  
3612 use Venus 'meta';
3613  
3614 my $meta = meta 'Venus';
3615  
3616 # bless({...}, 'Venus::Meta')
3617  
3618 =back
3619  
3620 =over 4
3621  
3622 =item meta example 2
3623  
3624 package main;
3625  
3626 use Venus 'meta';
3627  
3628 my $result = meta 'Venus', 'sub', 'meta';
3629  
3630 # 1
3631  
3632 =back
3633  
3634 =cut
3635  
3636 =head2 name
3637  
3638 name(string $value, string | coderef $code, any @args) (any)
3639  
3640 The name function builds and returns a L<Venus::Name> object, or dispatches to
3641 the coderef or method provided.
3642  
3643 I<Since C<2.55>>
3644  
3645 =over 4
3646  
3647 =item name example 1
3648  
3649 package main;
3650  
3651 use Venus 'name';
3652  
3653 my $name = name 'Foo/Bar';
3654  
3655 # bless({...}, 'Venus::Name')
3656  
3657 =back
3658  
3659 =over 4
3660  
3661 =item name example 2
3662  
3663 package main;
3664  
3665 use Venus 'name';
3666  
3667 my $name = name 'Foo/Bar', 'package';
3668  
3669 # "Foo::Bar"
3670  
3671 =back
3672  
3673 =cut
3674  
3675 =head2 number
3676  
3677 number(Num $value, string | coderef $code, any @args) (any)
3678  
3679 The number function builds and returns a L<Venus::Number> object, or dispatches
3680 to the coderef or method provided.
3681  
3682 I<Since C<2.55>>
3683  
3684 =over 4
3685  
3686 =item number example 1
3687  
3688 package main;
3689  
3690 use Venus 'number';
3691  
3692 my $number = number 1_000;
3693  
3694 # bless({...}, 'Venus::Number')
3695  
3696 =back
3697  
3698 =over 4
3699  
3700 =item number example 2
3701  
3702 package main;
3703  
3704 use Venus 'number';
3705  
3706 my $number = number 1_000, 'prepend', 1;
3707  
3708 # 11_000
3709  
3710 =back
3711  
3712 =cut
3713  
3714 =head2 opts
3715  
3716 opts(arrayref $value, string | coderef $code, any @args) (any)
3717  
3718 The opts function builds and returns a L<Venus::Opts> object, or dispatches to
3719 the coderef or method provided.
3720  
3721 I<Since C<2.55>>
3722  
3723 =over 4
3724  
3725 =item opts example 1
3726  
3727 package main;
3728  
3729 use Venus 'opts';
3730  
3731 my $opts = opts ['--resource', 'users'];
3732  
3733 # bless({...}, 'Venus::Opts')
3734  
3735 =back
3736  
3737 =over 4
3738  
3739 =item opts example 2
3740  
3741 package main;
3742  
3743 use Venus 'opts';
3744  
3745 my $opts = opts ['--resource', 'users'], 'reparse', ['resource|r=s', 'help|h'];
3746  
3747 # bless({...}, 'Venus::Opts')
3748  
3749 # my $resource = $opts->get('resource');
3750  
3751 # "users"
3752  
3753 =back
3754  
3755 =cut
3756  
3757 =head2 pairs
3758  
3759 pairs(any $data) (arrayref)
3760  
3761 The pairs function accepts an arrayref or hashref and returns an arrayref of
3762 arrayrefs holding keys (or indices) and values. The function returns an empty
3763 arrayref for all other values provided. Returns a list in list context.
3764  
3765 I<Since C<3.04>>
3766  
3767 =over 4
3768  
3769 =item pairs example 1
3770  
3771 package main;
3772  
3773 use Venus 'pairs';
3774  
3775 my $pairs = pairs [1..4];
3776  
3777 # [[0,1], [1,2], [2,3], [3,4]]
3778  
3779 =back
3780  
3781 =over 4
3782  
3783 =item pairs example 2
3784  
3785 package main;
3786  
3787 use Venus 'pairs';
3788  
3789 my $pairs = pairs {'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4};
3790  
3791 # [['a',1], ['b',2], ['c',3], ['d',4]]
3792  
3793 =back
3794  
3795 =over 4
3796  
3797 =item pairs example 3
3798  
3799 package main;
3800  
3801 use Venus 'pairs';
3802  
3803 my @pairs = pairs [1..4];
3804  
3805 # ([0,1], [1,2], [2,3], [3,4])
3806  
3807 =back
3808  
3809 =over 4
3810  
3811 =item pairs example 4
3812  
3813 package main;
3814  
3815 use Venus 'pairs';
3816  
3817 my @pairs = pairs {'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4};
3818  
3819 # (['a',1], ['b',2], ['c',3], ['d',4])
3820  
3821 =back
3822  
3823 =cut
3824  
3825 =head2 path
3826  
3827 path(string $value, string | coderef $code, any @args) (any)
3828  
3829 The path function builds and returns a L<Venus::Path> object, or dispatches
3830 to the coderef or method provided.
3831  
3832 I<Since C<2.55>>
3833  
3834 =over 4
3835  
3836 =item path example 1
3837  
3838 package main;
3839  
3840 use Venus 'path';
3841  
3842 my $path = path 't/data/planets';
3843  
3844 # bless({...}, 'Venus::Path')
3845  
3846 =back
3847  
3848 =over 4
3849  
3850 =item path example 2
3851  
3852 package main;
3853  
3854 use Venus 'path';
3855  
3856 my $path = path 't/data/planets', 'absolute';
3857  
3858 # bless({...}, 'Venus::Path')
3859  
3860 =back
3861  
3862 =cut
3863  
3864 =head2 perl
3865  
3866 perl(string $call, any $data) (any)
3867  
3868 The perl function builds a L<Venus::Dump> object and will either
3869 L<Venus::Dump/decode> or L<Venus::Dump/encode> based on the argument provided
3870 and returns the result.
3871  
3872 I<Since C<2.40>>
3873  
3874 =over 4
3875  
3876 =item perl example 1
3877  
3878 package main;
3879  
3880 use Venus 'perl';
3881  
3882 my $decode = perl 'decode', '{stable=>bless({},\'Venus::True\')}';
3883  
3884 # { stable => 1 }
3885  
3886 =back
3887  
3888 =over 4
3889  
3890 =item perl example 2
3891  
3892 package main;
3893  
3894 use Venus 'perl';
3895  
3896 my $encode = perl 'encode', { stable => true };
3897  
3898 # '{stable=>bless({},\'Venus::True\')}'
3899  
3900 =back
3901  
3902 =over 4
3903  
3904 =item perl example 3
3905  
3906 package main;
3907  
3908 use Venus 'perl';
3909  
3910 my $perl = perl;
3911  
3912 # bless({...}, 'Venus::Dump')
3913  
3914 =back
3915  
3916 =over 4
3917  
3918 =item perl example 4
3919  
3920 package main;
3921  
3922 use Venus 'perl';
3923  
3924 my $perl = perl 'class', {data => "..."};
3925  
3926 # Exception! (isa Venus::Fault)
3927  
3928 =back
3929  
3930 =cut
3931  
3932 =head2 process
3933  
3934 process(string | coderef $code, any @args) (any)
3935  
3936 The process function builds and returns a L<Venus::Process> object, or
3937 dispatches to the coderef or method provided.
3938  
3939 I<Since C<2.55>>
3940  
3941 =over 4
3942  
3943 =item process example 1
3944  
3945 package main;
3946  
3947 use Venus 'process';
3948  
3949 my $process = process;
3950  
3951 # bless({...}, 'Venus::Process')
3952  
3953 =back
3954  
3955 =over 4
3956  
3957 =item process example 2
3958  
3959 package main;
3960  
3961 use Venus 'process';
3962  
3963 my $process = process 'do', 'alarm', 10;
3964  
3965 # bless({...}, 'Venus::Process')
3966  
3967 =back
3968  
3969 =cut
3970  
3971 =head2 proto
3972  
3973 proto(hashref $value, string | coderef $code, any @args) (any)
3974  
3975 The proto function builds and returns a L<Venus::Prototype> object, or
3976 dispatches to the coderef or method provided.
3977  
3978 I<Since C<2.55>>
3979  
3980 =over 4
3981  
3982 =item proto example 1
3983  
3984 package main;
3985  
3986 use Venus 'proto';
3987  
3988 my $proto = proto {
3989 '$counter' => 0,
3990 };
3991  
3992 # bless({...}, 'Venus::Prototype')
3993  
3994 =back
3995  
3996 =over 4
3997  
3998 =item proto example 2
3999  
4000 package main;
4001  
4002 use Venus 'proto';
4003  
4004 my $proto = proto { '$counter' => 0 }, 'apply', {
4005 '&decrement' => sub { $_[0]->counter($_[0]->counter - 1) },
4006 '&increment' => sub { $_[0]->counter($_[0]->counter + 1) },
4007 };
4008  
4009 # bless({...}, 'Venus::Prototype')
4010  
4011 =back
4012  
4013 =cut
4014  
4015 =head2 puts
4016  
4017 puts(any @args) (arrayref)
4018  
4019 The puts function select values from within the underlying data structure using
4020 L<Venus::Array/path> or L<Venus::Hash/path>, optionally assigning the value to
4021 the preceeding scalar reference and returns all the values selected.
4022  
4023 I<Since C<3.20>>
4024  
4025 =over 4
4026  
4027 =item puts example 1
4028  
4029 package main;
4030  
4031 use Venus 'puts';
4032  
4033 my $data = {
4034 size => "small",
4035 fruit => "apple",
4036 meta => {
4037 expiry => '5d',
4038 },
4039 color => "red",
4040 };
4041  
4042 puts $data, (
4043 \my $fruit, 'fruit',
4044 \my $expiry, 'meta.expiry'
4045 );
4046  
4047 my $puts = [$fruit, $expiry];
4048  
4049 # ["apple", "5d"]
4050  
4051 =back
4052  
4053 =cut
4054  
4055 =head2 raise
4056  
4057 raise(string $class | tuple[string, string] $class, maybe[hashref] $args) (Venus::Error)
4058  
4059 The raise function generates and throws a named exception object derived from
4060 L<Venus::Error>, or provided base class, using the exception object arguments
4061 provided.
4062  
4063 I<Since C<0.01>>
4064  
4065 =over 4
4066  
4067 =item raise example 1
4068  
4069 package main;
4070  
4071 use Venus 'raise';
4072  
4073 my $error = raise 'MyApp::Error';
4074  
4075 # bless({...}, 'MyApp::Error')
4076  
4077 =back
4078  
4079 =over 4
4080  
4081 =item raise example 2
4082  
4083 package main;
4084  
4085 use Venus 'raise';
4086  
4087 my $error = raise ['MyApp::Error', 'Venus::Error'];
4088  
4089 # bless({...}, 'MyApp::Error')
4090  
4091 =back
4092  
4093 =over 4
4094  
4095 =item raise example 3
4096  
4097 package main;
4098  
4099 use Venus 'raise';
4100  
4101 my $error = raise ['MyApp::Error', 'Venus::Error'], {
4102 message => 'Something failed!',
4103 };
4104  
4105 # bless({message => 'Something failed!', ...}, 'MyApp::Error')
4106  
4107 =back
4108  
4109 =cut
4110  
4111 =head2 random
4112  
4113 random(string | coderef $code, any @args) (any)
4114  
4115 The random function builds and returns a L<Venus::Random> object, or dispatches
4116 to the coderef or method provided.
4117  
4118 I<Since C<2.55>>
4119  
4120 =over 4
4121  
4122 =item random example 1
4123  
4124 package main;
4125  
4126 use Venus 'random';
4127  
4128 my $random = random;
4129  
4130 # bless({...}, 'Venus::Random')
4131  
4132 =back
4133  
4134 =over 4
4135  
4136 =item random example 2
4137  
4138 package main;
4139  
4140 use Venus 'random';
4141  
4142 my $random = random 'collect', 10, 'letter';
4143  
4144 # "ryKUPbJHYT"
4145  
4146 =back
4147  
4148 =cut
4149  
4150 =head2 range
4151  
4152 range(number | string @args) (arrayref)
4153  
4154 The range function returns the result of a L<Venus::Array/range> operation.
4155  
4156 I<Since C<3.20>>
4157  
4158 =over 4
4159  
4160 =item range example 1
4161  
4162 package main;
4163  
4164 use Venus 'range';
4165  
4166 my $range = range [1..9], ':4';
4167  
4168 # [1..5]
4169  
4170 =back
4171  
4172 =over 4
4173  
4174 =item range example 2
4175  
4176 package main;
4177  
4178 use Venus 'range';
4179  
4180 my $range = range [1..9], '-4:-1';
4181  
4182 # [6..9]
4183  
4184 =back
4185  
4186 =cut
4187  
4188 =head2 regexp
4189  
4190 regexp(string $value, string | coderef $code, any @args) (any)
4191  
4192 The regexp function builds and returns a L<Venus::Regexp> object, or dispatches
4193 to the coderef or method provided.
4194  
4195 I<Since C<2.55>>
4196  
4197 =over 4
4198  
4199 =item regexp example 1
4200  
4201 package main;
4202  
4203 use Venus 'regexp';
4204  
4205 my $regexp = regexp '[0-9]';
4206  
4207 # bless({...}, 'Venus::Regexp')
4208  
4209 =back
4210  
4211 =over 4
4212  
4213 =item regexp example 2
4214  
4215 package main;
4216  
4217 use Venus 'regexp';
4218  
4219 my $replace = regexp '[0-9]', 'replace', 'ID 12345', '0', 'g';
4220  
4221 # bless({...}, 'Venus::Replace')
4222  
4223 # $replace->get;
4224  
4225 # "ID 00000"
4226  
4227 =back
4228  
4229 =cut
4230  
4231 =head2 render
4232  
4233 render(string $data, hashref $args) (string)
4234  
4235 The render function accepts a string as a template and renders it using
4236 L<Venus::Template>, and returns the result.
4237  
4238 I<Since C<3.04>>
4239  
4240 =over 4
4241  
4242 =item render example 1
4243  
4244 package main;
4245  
4246 use Venus 'render';
4247  
4248 my $render = render 'hello {{name}}', {
4249 name => 'user',
4250 };
4251  
4252 # "hello user"
4253  
4254 =back
4255  
4256 =cut
4257  
4258 =head2 replace
4259  
4260 replace(arrayref $value, string | coderef $code, any @args) (any)
4261  
4262 The replace function builds and returns a L<Venus::Replace> object, or
4263 dispatches to the coderef or method provided.
4264  
4265 I<Since C<2.55>>
4266  
4267 =over 4
4268  
4269 =item replace example 1
4270  
4271 package main;
4272  
4273 use Venus 'replace';
4274  
4275 my $replace = replace ['hello world', 'world', 'universe'];
4276  
4277 # bless({...}, 'Venus::Replace')
4278  
4279 =back
4280  
4281 =over 4
4282  
4283 =item replace example 2
4284  
4285 package main;
4286  
4287 use Venus 'replace';
4288  
4289 my $replace = replace ['hello world', 'world', 'universe'], 'get';
4290  
4291 # "hello universe"
4292  
4293 =back
4294  
4295 =cut
4296  
4297 =head2 resolve
4298  
4299 resolve(hashref $value, any @args) (any)
4300  
4301 The resolve function builds and returns an object via L<Venus::Container/resolve>.
4302  
4303 I<Since C<3.30>>
4304  
4305 =over 4
4306  
4307 =item resolve example 1
4308  
4309 package main;
4310  
4311 use Venus 'resolve';
4312  
4313 my $resolve = resolve {};
4314  
4315 # undef
4316  
4317 =back
4318  
4319 =over 4
4320  
4321 =item resolve example 2
4322  
4323 package main;
4324  
4325 use Venus 'resolve';
4326  
4327 my $data = {
4328 '$services' => {
4329 log => {
4330 package => "Venus/Path",
4331 }
4332 }
4333 };
4334  
4335 my $log = resolve $data, 'log';
4336  
4337 # bless({...}, 'Venus::Path')
4338  
4339 =back
4340  
4341 =cut
4342  
4343 =head2 roll
4344  
4345 roll(string $name, any @args) (any)
4346  
4347 The roll function takes a list of arguments, assuming the first argument is
4348 invokable, and reorders the list such that the routine name provided comes
4349 after the invocant (i.e. the 1st argument), creating a list acceptable to the
4350 L</call> function.
4351  
4352 I<Since C<2.32>>
4353  
4354 =over 4
4355  
4356 =item roll example 1
4357  
4358 package main;
4359  
4360 use Venus 'roll';
4361  
4362 my @list = roll('sha1_hex', 'Digest::SHA');
4363  
4364 # ('Digest::SHA', 'sha1_hex');
4365  
4366 =back
4367  
4368 =over 4
4369  
4370 =item roll example 2
4371  
4372 package main;
4373  
4374 use Venus 'roll';
4375  
4376 my @list = roll('sha1_hex', call(\'Digest::SHA', 'new'));
4377  
4378 # (bless(do{\(my $o = '...')}, 'Digest::SHA'), 'sha1_hex');
4379  
4380 =back
4381  
4382 =cut
4383  
4384 =head2 schema
4385  
4386 schema(string $value, string | coderef $code, any @args) (any)
4387  
4388 The schema function builds and returns a L<Venus::Schema> object, or dispatches
4389 to the coderef or method provided.
4390  
4391 I<Since C<2.55>>
4392  
4393 =over 4
4394  
4395 =item schema example 1
4396  
4397 package main;
4398  
4399 use Venus 'schema';
4400  
4401 my $schema = schema { name => 'string' };
4402  
4403 # bless({...}, "Venus::Schema")
4404  
4405 =back
4406  
4407 =over 4
4408  
4409 =item schema example 2
4410  
4411 package main;
4412  
4413 use Venus 'schema';
4414  
4415 my $result = schema { name => 'string' }, 'validate', { name => 'example' };
4416  
4417 # { name => 'example' }
4418  
4419 =back
4420  
4421 =cut
4422  
4423 =head2 search
4424  
4425 search(arrayref $value, string | coderef $code, any @args) (any)
4426  
4427 The search function builds and returns a L<Venus::Search> object, or dispatches
4428 to the coderef or method provided.
4429  
4430 I<Since C<2.55>>
4431  
4432 =over 4
4433  
4434 =item search example 1
4435  
4436 package main;
4437  
4438 use Venus 'search';
4439  
4440 my $search = search ['hello world', 'world'];
4441  
4442 # bless({...}, 'Venus::Search')
4443  
4444 =back
4445  
4446 =over 4
4447  
4448 =item search example 2
4449  
4450 package main;
4451  
4452 use Venus 'search';
4453  
4454 my $search = search ['hello world', 'world'], 'count';
4455  
4456 # 1
4457  
4458 =back
4459  
4460 =cut
4461  
4462 =head2 space
4463  
4464 space(any $name) (Venus::Space)
4465  
4466 The space function returns a L<Venus::Space> object for the package provided.
4467  
4468 I<Since C<2.32>>
4469  
4470 =over 4
4471  
4472 =item space example 1
4473  
4474 package main;
4475  
4476 use Venus 'space';
4477  
4478 my $space = space 'Venus::Scalar';
4479  
4480 # bless({value => 'Venus::Scalar'}, 'Venus::Space')
4481  
4482 =back
4483  
4484 =cut
4485  
4486 =head2 string
4487  
4488 string(string $value, string | coderef $code, any @args) (any)
4489  
4490 The string function builds and returns a L<Venus::String> object, or dispatches
4491 to the coderef or method provided.
4492  
4493 I<Since C<2.55>>
4494  
4495 =over 4
4496  
4497 =item string example 1
4498  
4499 package main;
4500  
4501 use Venus 'string';
4502  
4503 my $string = string 'hello world';
4504  
4505 # bless({...}, 'Venus::String')
4506  
4507 =back
4508  
4509 =over 4
4510  
4511 =item string example 2
4512  
4513 package main;
4514  
4515 use Venus 'string';
4516  
4517 my $string = string 'hello world', 'camelcase';
4518  
4519 # "helloWorld"
4520  
4521 =back
4522  
4523 =cut
4524  
4525 =head2 syscall
4526  
4527 syscall(number | string @args) (any)
4528  
4529 The syscall function perlforms system call, i.e. a L<perlfunc/qx> operation,
4530 and returns C<true> if the command succeeds, otherwise returns C<false>. In
4531 list context, returns the output of the operation and the exit code.
4532  
4533 I<Since C<3.04>>
4534  
4535 =over 4
4536  
4537 =item syscall example 1
4538  
4539 package main;
4540  
4541 use Venus 'syscall';
4542  
4543 my $syscall = syscall 'perl', '-v';
4544  
4545 # true
4546  
4547 =back
4548  
4549 =over 4
4550  
4551 =item syscall example 2
4552  
4553 package main;
4554  
4555 use Venus 'syscall';
4556  
4557 my $syscall = syscall 'perl', '-z';
4558  
4559 # false
4560  
4561 =back
4562  
4563 =over 4
4564  
4565 =item syscall example 3
4566  
4567 package main;
4568  
4569 use Venus 'syscall';
4570  
4571 my ($data, $code) = syscall 'sun', '--heat-death';
4572  
4573 # ('done', 0)
4574  
4575 =back
4576  
4577 =over 4
4578  
4579 =item syscall example 4
4580  
4581 package main;
4582  
4583 use Venus 'syscall';
4584  
4585 my ($data, $code) = syscall 'earth', '--melt-icecaps';
4586  
4587 # ('', 127)
4588  
4589 =back
4590  
4591 =cut
4592  
4593 =head2 template
4594  
4595 template(string $value, string | coderef $code, any @args) (any)
4596  
4597 The template function builds and returns a L<Venus::Template> object, or
4598 dispatches to the coderef or method provided.
4599  
4600 I<Since C<2.55>>
4601  
4602 =over 4
4603  
4604 =item template example 1
4605  
4606 package main;
4607  
4608 use Venus 'template';
4609  
4610 my $template = template 'Hi {{name}}';
4611  
4612 # bless({...}, 'Venus::Template')
4613  
4614 =back
4615  
4616 =over 4
4617  
4618 =item template example 2
4619  
4620 package main;
4621  
4622 use Venus 'template';
4623  
4624 my $template = template 'Hi {{name}}', 'render', undef, {
4625 name => 'stranger',
4626 };
4627  
4628 # "Hi stranger"
4629  
4630 =back
4631  
4632 =cut
4633  
4634 =head2 test
4635  
4636 test(string $value, string | coderef $code, any @args) (any)
4637  
4638 The test function builds and returns a L<Venus::Test> object, or dispatches to
4639 the coderef or method provided.
4640  
4641 I<Since C<2.55>>
4642  
4643 =over 4
4644  
4645 =item test example 1
4646  
4647 package main;
4648  
4649 use Venus 'test';
4650  
4651 my $test = test 't/Venus.t';
4652  
4653 # bless({...}, 'Venus::Test')
4654  
4655 =back
4656  
4657 =over 4
4658  
4659 =item test example 2
4660  
4661 package main;
4662  
4663 use Venus 'test';
4664  
4665 my $test = test 't/Venus.t', 'for', 'synopsis';
4666  
4667 # bless({...}, 'Venus::Test')
4668  
4669 =back
4670  
4671 =cut
4672  
4673 =head2 text
4674  
4675 text(any @args) (any)
4676  
4677 The text function builds a L<Venus::Data> object using L<Venus::Data/text> for
4678 the current file, i.e. L<perlfunc/__FILE__> or script, i.e. C<$0>, and returns
4679 the result of a L<Venus::Data/string> operation using the arguments provided.
4680  
4681 I<Since C<3.30>>
4682  
4683 =over 4
4684  
4685 =item text example 1
4686  
4687 package main;
4688  
4689 use Venus 'text';
4690  
4691 # @@ name
4692 #
4693 # Example Name
4694 #
4695 # @@ end
4696 #
4697 # @@ titles #1
4698 #
4699 # Example Title #1
4700 #
4701 # @@ end
4702 #
4703 # @@ titles #2
4704 #
4705 # Example Title #2
4706 #
4707 # @@ end
4708  
4709 my $text = text 'name';
4710  
4711 # "Example Name"
4712  
4713 =back
4714  
4715 =over 4
4716  
4717 =item text example 2
4718  
4719 package main;
4720  
4721 use Venus 'text';
4722  
4723 # @@ name
4724 #
4725 # Example Name
4726 #
4727 # @@ end
4728 #
4729 # @@ titles #1
4730 #
4731 # Example Title #1
4732 #
4733 # @@ end
4734 #
4735 # @@ titles #2
4736 #
4737 # Example Title #2
4738 #
4739 # @@ end
4740  
4741 my $text = text 'titles', '#1';
4742  
4743 # "Example Title #1"
4744  
4745 =back
4746  
4747 =over 4
4748  
4749 =item text example 3
4750  
4751 package main;
4752  
4753 use Venus 'text';
4754  
4755 # @@ name
4756 #
4757 # Example Name
4758 #
4759 # @@ end
4760 #
4761 # @@ titles #1
4762 #
4763 # Example Title #1
4764 #
4765 # @@ end
4766 #
4767 # @@ titles #2
4768 #
4769 # Example Title #2
4770 #
4771 # @@ end
4772  
4773 my $text = text undef, 'name';
4774  
4775 # "Example Name"
4776  
4777 =back
4778  
4779 =cut
4780  
4781 =head2 then
4782  
4783 then(string | object | coderef $self, any @args) (any)
4784  
4785 The then function proxies the call request to the L</call> function and returns
4786 the result as a list, prepended with the invocant.
4787  
4788 I<Since C<2.32>>
4789  
4790 =over 4
4791  
4792 =item then example 1
4793  
4794 package main;
4795  
4796 use Venus 'then';
4797  
4798 my @list = then('Digest::SHA', 'sha1_hex');
4799  
4800 # ("Digest::SHA", "da39a3ee5e6b4b0d3255bfef95601890afd80709")
4801  
4802 =back
4803  
4804 =cut
4805  
4806 =head2 throw
4807  
4808 throw(string | hashref $value, string | coderef $code, any @args) (any)
4809  
4810 The throw function builds and returns a L<Venus::Throw> object, or dispatches
4811 to the coderef or method provided.
4812  
4813 I<Since C<2.55>>
4814  
4815 =over 4
4816  
4817 =item throw example 1
4818  
4819 package main;
4820  
4821 use Venus 'throw';
4822  
4823 my $throw = throw 'Example::Error';
4824  
4825 # bless({...}, 'Venus::Throw')
4826  
4827 =back
4828  
4829 =over 4
4830  
4831 =item throw example 2
4832  
4833 package main;
4834  
4835 use Venus 'throw';
4836  
4837 my $throw = throw 'Example::Error', 'catch', 'error';
4838  
4839 # bless({...}, 'Example::Error')
4840  
4841 =back
4842  
4843 =over 4
4844  
4845 =item throw example 3
4846  
4847 package main;
4848  
4849 use Venus 'throw';
4850  
4851 my $throw = throw {
4852 name => 'on.execute',
4853 package => 'Example::Error',
4854 capture => ['...'],
4855 stash => {
4856 time => time,
4857 },
4858 };
4859  
4860 # bless({...}, 'Venus::Throw')
4861  
4862 =back
4863  
4864 =cut
4865  
4866 =head2 true
4867  
4868 true() (boolean)
4869  
4870 The true function returns a truthy boolean value which is designed to be
4871 practically indistinguishable from the conventional numerical C<1> value.
4872  
4873 I<Since C<0.01>>
4874  
4875 =over 4
4876  
4877 =item true example 1
4878  
4879 package main;
4880  
4881 use Venus;
4882  
4883 my $true = true;
4884  
4885 # 1
4886  
4887 =back
4888  
4889 =over 4
4890  
4891 =item true example 2
4892  
4893 package main;
4894  
4895 use Venus;
4896  
4897 my $false = !true;
4898  
4899 # 0
4900  
4901 =back
4902  
4903 =cut
4904  
4905 =head2 try
4906  
4907 try(any $data, string | coderef $code, any @args) (any)
4908  
4909 The try function builds and returns a L<Venus::Try> object, or dispatches to
4910 the coderef or method provided.
4911  
4912 I<Since C<2.55>>
4913  
4914 =over 4
4915  
4916 =item try example 1
4917  
4918 package main;
4919  
4920 use Venus 'try';
4921  
4922 my $try = try sub {};
4923  
4924 # bless({...}, 'Venus::Try')
4925  
4926 # my $result = $try->result;
4927  
4928 # ()
4929  
4930 =back
4931  
4932 =over 4
4933  
4934 =item try example 2
4935  
4936 package main;
4937  
4938 use Venus 'try';
4939  
4940 my $try = try sub { die };
4941  
4942 # bless({...}, 'Venus::Try')
4943  
4944 # my $result = $try->result;
4945  
4946 # Exception! (isa Venus::Error)
4947  
4948 =back
4949  
4950 =over 4
4951  
4952 =item try example 3
4953  
4954 package main;
4955  
4956 use Venus 'try';
4957  
4958 my $try = try sub { die }, 'maybe';
4959  
4960 # bless({...}, 'Venus::Try')
4961  
4962 # my $result = $try->result;
4963  
4964 # undef
4965  
4966 =back
4967  
4968 =cut
4969  
4970 =head2 type
4971  
4972 type(any $data, string | coderef $code, any @args) (any)
4973  
4974 The type function builds and returns a L<Venus::Type> object, or dispatches to
4975 the coderef or method provided.
4976  
4977 I<Since C<2.55>>
4978  
4979 =over 4
4980  
4981 =item type example 1
4982  
4983 package main;
4984  
4985 use Venus 'type';
4986  
4987 my $type = type [1..4];
4988  
4989 # bless({...}, 'Venus::Type')
4990  
4991 # $type->deduce;
4992  
4993 # bless({...}, 'Venus::Array')
4994  
4995 =back
4996  
4997 =over 4
4998  
4999 =item type example 2
5000  
5001 package main;
5002  
5003 use Venus 'type';
5004  
5005 my $type = type [1..4], 'deduce';
5006  
5007 # bless({...}, 'Venus::Array')
5008  
5009 =back
5010  
5011 =cut
5012  
5013 =head2 unpack
5014  
5015 unpack(any @args) (Venus::Unpack)
5016  
5017 The unpack function builds and returns a L<Venus::Unpack> object.
5018  
5019 I<Since C<2.40>>
5020  
5021 =over 4
5022  
5023 =item unpack example 1
5024  
5025 package main;
5026  
5027 use Venus 'unpack';
5028  
5029 my $unpack = unpack;
5030  
5031 # bless({...}, 'Venus::Unpack')
5032  
5033 # $unpack->checks('string');
5034  
5035 # false
5036  
5037 # $unpack->checks('undef');
5038  
5039 # false
5040  
5041 =back
5042  
5043 =over 4
5044  
5045 =item unpack example 2
5046  
5047 package main;
5048  
5049 use Venus 'unpack';
5050  
5051 my $unpack = unpack rand;
5052  
5053 # bless({...}, 'Venus::Unpack')
5054  
5055 # $unpack->check('number');
5056  
5057 # false
5058  
5059 # $unpack->check('float');
5060  
5061 # true
5062  
5063 =back
5064  
5065 =cut
5066  
5067 =head2 vars
5068  
5069 vars(hashref $value, string | coderef $code, any @args) (any)
5070  
5071 The vars function builds and returns a L<Venus::Vars> object, or dispatches to
5072 the coderef or method provided.
5073  
5074 I<Since C<2.55>>
5075  
5076 =over 4
5077  
5078 =item vars example 1
5079  
5080 package main;
5081  
5082 use Venus 'vars';
5083  
5084 my $vars = vars {};
5085  
5086 # bless({...}, 'Venus::Vars')
5087  
5088 =back
5089  
5090 =over 4
5091  
5092 =item vars example 2
5093  
5094 package main;
5095  
5096 use Venus 'vars';
5097  
5098 my $path = vars {}, 'exists', 'path';
5099  
5100 # "..."
5101  
5102 =back
5103  
5104 =cut
5105  
5106 =head2 venus
5107  
5108 venus(string $name, any @args) (any)
5109  
5110 The venus function build a L<Venus> package via the L</chain> function based on
5111 the name provided and returns an instance of that package.
5112  
5113 I<Since C<2.40>>
5114  
5115 =over 4
5116  
5117 =item venus example 1
5118  
5119 package main;
5120  
5121 use Venus 'venus';
5122  
5123 my $space = venus 'space';
5124  
5125 # bless({value => 'Venus'}, 'Venus::Space')
5126  
5127 =back
5128  
5129 =over 4
5130  
5131 =item venus example 2
5132  
5133 package main;
5134  
5135 use Venus 'venus';
5136  
5137 my $space = venus 'space', ['new', 'venus/string'];
5138  
5139 # bless({value => 'Venus::String'}, 'Venus::Space')
5140  
5141 =back
5142  
5143 =over 4
5144  
5145 =item venus example 3
5146  
5147 package main;
5148  
5149 use Venus 'venus';
5150  
5151 my $space = venus 'code';
5152  
5153 # bless({value => sub{...}}, 'Venus::Code')
5154  
5155 =back
5156  
5157 =cut
5158  
5159 =head2 work
5160  
5161 work(coderef $callback) (Venus::Process)
5162  
5163 The work function builds a L<Venus::Process> object, forks the current process
5164 using the callback provided via the L<Venus::Process/work> operation, and
5165 returns an instance of L<Venus::Process> representing the current process.
5166  
5167 I<Since C<2.40>>
5168  
5169 =over 4
5170  
5171 =item work example 1
5172  
5173 package main;
5174  
5175 use Venus 'work';
5176  
5177 my $parent = work sub {
5178 my ($process) = @_;
5179 # in forked process ...
5180 $process->exit;
5181 };
5182  
5183 # bless({...}, 'Venus::Process')
5184  
5185 =back
5186  
5187 =cut
5188  
5189 =head2 wrap
5190  
5191 wrap(string $data, string $name) (coderef)
5192  
5193 The wrap function installs a wrapper function in the calling package which when
5194 called either returns the package string if no arguments are provided, or calls
5195 L</make> on the package with whatever arguments are provided and returns the
5196 result. Unless an alias is provided as a second argument, special characters
5197 are stripped from the package to create the function name.
5198  
5199 I<Since C<2.32>>
5200  
5201 =over 4
5202  
5203 =item wrap example 1
5204  
5205 package main;
5206  
5207 use Venus 'wrap';
5208  
5209 my $coderef = wrap('Digest::SHA');
5210  
5211 # sub { ... }
5212  
5213 # my $digest = DigestSHA();
5214  
5215 # "Digest::SHA"
5216  
5217 # my $digest = DigestSHA(1);
5218  
5219 # bless(do{\(my $o = '...')}, 'Digest::SHA')
5220  
5221 =back
5222  
5223 =over 4
5224  
5225 =item wrap example 2
5226  
5227 package main;
5228  
5229 use Venus 'wrap';
5230  
5231 my $coderef = wrap('Digest::SHA', 'SHA');
5232  
5233 # sub { ... }
5234  
5235 # my $digest = SHA();
5236  
5237 # "Digest::SHA"
5238  
5239 # my $digest = SHA(1);
5240  
5241 # bless(do{\(my $o = '...')}, 'Digest::SHA')
5242  
5243 =back
5244  
5245 =cut
5246  
5247 =head2 yaml
5248  
5249 yaml(string $call, any $data) (any)
5250  
5251 The yaml function builds a L<Venus::Yaml> object and will either
5252 L<Venus::Yaml/decode> or L<Venus::Yaml/encode> based on the argument provided
5253 and returns the result.
5254  
5255 I<Since C<2.40>>
5256  
5257 =over 4
5258  
5259 =item yaml example 1
5260  
5261 package main;
5262  
5263 use Venus 'yaml';
5264  
5265 my $decode = yaml 'decode', "---\nname:\n- Ready\n- Robot\nstable: true\n";
5266  
5267 # { name => ["Ready", "Robot"], stable => 1 }
5268  
5269 =back
5270  
5271 =over 4
5272  
5273 =item yaml example 2
5274  
5275 package main;
5276  
5277 use Venus 'yaml';
5278  
5279 my $encode = yaml 'encode', { name => ["Ready", "Robot"], stable => true };
5280  
5281 # '---\nname:\n- Ready\n- Robot\nstable: true\n'
5282  
5283 =back
5284  
5285 =over 4
5286  
5287 =item yaml example 3
5288  
5289 package main;
5290  
5291 use Venus 'yaml';
5292  
5293 my $yaml = yaml;
5294  
5295 # bless({...}, 'Venus::Yaml')
5296  
5297 =back
5298  
5299 =over 4
5300  
5301 =item yaml example 4
5302  
5303 package main;
5304  
5305 use Venus 'yaml';
5306  
5307 my $yaml = yaml 'class', {data => "..."};
5308  
5309 # Exception! (isa Venus::Fault)
5310  
5311 =back
5312  
5313 =cut
5314  
5315 =head1 FEATURES
5316  
5317 This package provides the following features:
5318  
5319 =cut
5320  
5321 =over 4
5322  
5323 =item venus-args
5324  
5325 This library contains a L<Venus::Args> class which provides methods for
5326 accessing C<@ARGS> items.
5327  
5328 =back
5329  
5330 =over 4
5331  
5332 =item venus-array
5333  
5334 This library contains a L<Venus::Array> class which provides methods for
5335 manipulating array data.
5336  
5337 =back
5338  
5339 =over 4
5340  
5341 =item venus-assert
5342  
5343 This library contains a L<Venus::Assert> class which provides a mechanism for
5344 asserting type constraints and coercion.
5345  
5346 =back
5347  
5348 =over 4
5349  
5350 =item venus-boolean
5351  
5352 This library contains a L<Venus::Boolean> class which provides a representation
5353 for boolean values.
5354  
5355 =back
5356  
5357 =over 4
5358  
5359 =item venus-box
5360  
5361 This library contains a L<Venus::Box> class which provides a pure Perl boxing
5362 mechanism.
5363  
5364 =back
5365  
5366 =over 4
5367  
5368 =item venus-class
5369  
5370 This library contains a L<Venus::Class> class which provides a class builder.
5371  
5372 =back
5373  
5374 =over 4
5375  
5376 =item venus-cli
5377  
5378 This library contains a L<Venus::Cli> class which provides a superclass for
5379 creating CLIs.
5380  
5381 =back
5382  
5383 =over 4
5384  
5385 =item venus-code
5386  
5387 This library contains a L<Venus::Code> class which provides methods for
5388 manipulating subroutines.
5389  
5390 =back
5391  
5392 =over 4
5393  
5394 =item venus-config
5395  
5396 This library contains a L<Venus::Config> class which provides methods for
5397 loading Perl, YAML, and JSON configuration data.
5398  
5399 =back
5400  
5401 =over 4
5402  
5403 =item venus-data
5404  
5405 This library contains a L<Venus::Data> class which provides methods for
5406 extracting C<DATA> sections and POD block.
5407  
5408 =back
5409  
5410 =over 4
5411  
5412 =item venus-date
5413  
5414 This library contains a L<Venus::Date> class which provides methods for
5415 formatting, parsing, and manipulating dates.
5416  
5417 =back
5418  
5419 =over 4
5420  
5421 =item venus-dump
5422  
5423 This library contains a L<Venus::Dump> class which provides methods for reading
5424 and writing dumped Perl data.
5425  
5426 =back
5427  
5428 =over 4
5429  
5430 =item venus-error
5431  
5432 This library contains a L<Venus::Error> class which represents a context-aware
5433 error (exception object).
5434  
5435 =back
5436  
5437 =over 4
5438  
5439 =item venus-false
5440  
5441 This library contains a L<Venus::False> class which provides the global
5442 C<false> value.
5443  
5444 =back
5445  
5446 =over 4
5447  
5448 =item venus-fault
5449  
5450 This library contains a L<Venus::Fault> class which represents a generic system
5451 error (exception object).
5452  
5453 =back
5454  
5455 =over 4
5456  
5457 =item venus-float
5458  
5459 This library contains a L<Venus::Float> class which provides methods for
5460 manipulating float data.
5461  
5462 =back
5463  
5464 =over 4
5465  
5466 =item venus-gather
5467  
5468 This library contains a L<Venus::Gather> class which provides an
5469 object-oriented interface for complex pattern matching operations on
5470 collections of data, e.g. array references.
5471  
5472 =back
5473  
5474 =over 4
5475  
5476 =item venus-hash
5477  
5478 This library contains a L<Venus::Hash> class which provides methods for
5479 manipulating hash data.
5480  
5481 =back
5482  
5483 =over 4
5484  
5485 =item venus-json
5486  
5487 This library contains a L<Venus::Json> class which provides methods for reading
5488 and writing JSON data.
5489  
5490 =back
5491  
5492 =over 4
5493  
5494 =item venus-log
5495  
5496 This library contains a L<Venus::Log> class which provides methods for logging
5497 information using various log levels.
5498  
5499 =back
5500  
5501 =over 4
5502  
5503 =item venus-match
5504  
5505 This library contains a L<Venus::Match> class which provides an object-oriented
5506 interface for complex pattern matching operations on scalar values.
5507  
5508 =back
5509  
5510 =over 4
5511  
5512 =item venus-meta
5513  
5514 This library contains a L<Venus::Meta> class which provides configuration
5515 information for L<Venus> derived classes.
5516  
5517 =back
5518  
5519 =over 4
5520  
5521 =item venus-mixin
5522  
5523 This library contains a L<Venus::Mixin> class which provides a mixin builder.
5524  
5525 =back
5526  
5527 =over 4
5528  
5529 =item venus-name
5530  
5531 This library contains a L<Venus::Name> class which provides methods for parsing
5532 and formatting package namespaces.
5533  
5534 =back
5535  
5536 =over 4
5537  
5538 =item venus-number
5539  
5540 This library contains a L<Venus::Number> class which provides methods for
5541 manipulating number data.
5542  
5543 =back
5544  
5545 =over 4
5546  
5547 =item venus-opts
5548  
5549 This library contains a L<Venus::Opts> class which provides methods for
5550 handling command-line arguments.
5551  
5552 =back
5553  
5554 =over 4
5555  
5556 =item venus-path
5557  
5558 This library contains a L<Venus::Path> class which provides methods for working
5559 with file system paths.
5560  
5561 =back
5562  
5563 =over 4
5564  
5565 =item venus-process
5566  
5567 This library contains a L<Venus::Process> class which provides methods for
5568 handling and forking processes.
5569  
5570 =back
5571  
5572 =over 4
5573  
5574 =item venus-prototype
5575  
5576 This library contains a L<Venus::Prototype> class which provides a simple
5577 construct for enabling prototype-base programming.
5578  
5579 =back
5580  
5581 =over 4
5582  
5583 =item venus-random
5584  
5585 This library contains a L<Venus::Random> class which provides an
5586 object-oriented interface for Perl's pseudo-random number generator.
5587  
5588 =back
5589  
5590 =over 4
5591  
5592 =item venus-regexp
5593  
5594 This library contains a L<Venus::Regexp> class which provides methods for
5595 manipulating regexp data.
5596  
5597 =back
5598  
5599 =over 4
5600  
5601 =item venus-replace
5602  
5603 This library contains a L<Venus::Replace> class which provides methods for
5604 manipulating regexp replacement data.
5605  
5606 =back
5607  
5608 =over 4
5609  
5610 =item venus-run
5611  
5612 This library contains a L<Venus::Run> class which provides a base class for
5613 providing a command execution system for creating CLIs (command-line
5614 interfaces).
5615  
5616 =back
5617  
5618 =over 4
5619  
5620 =item venus-scalar
5621  
5622 This library contains a L<Venus::Scalar> class which provides methods for
5623 manipulating scalar data.
5624  
5625 =back
5626  
5627 =over 4
5628  
5629 =item venus-search
5630  
5631 This library contains a L<Venus::Search> class which provides methods for
5632 manipulating regexp search data.
5633  
5634 =back
5635  
5636 =over 4
5637  
5638 =item venus-space
5639  
5640 This library contains a L<Venus::Space> class which provides methods for
5641 parsing and manipulating package namespaces.
5642  
5643 =back
5644  
5645 =over 4
5646  
5647 =item venus-string
5648  
5649 This library contains a L<Venus::String> class which provides methods for
5650 manipulating string data.
5651  
5652 =back
5653  
5654 =over 4
5655  
5656 =item venus-task
5657  
5658 This library contains a L<Venus::Task> class which provides a base class for
5659 creating CLIs (command-line interfaces).
5660  
5661 =back
5662  
5663 =over 4
5664  
5665 =item venus-template
5666  
5667 This library contains a L<Venus::Template> class which provides a templating
5668 system, and methods for rendering template.
5669  
5670 =back
5671  
5672 =over 4
5673  
5674 =item venus-test
5675  
5676 This library contains a L<Venus::Test> class which aims to provide a standard
5677 for documenting L<Venus> derived software projects.
5678  
5679 =back
5680  
5681 =over 4
5682  
5683 =item venus-throw
5684  
5685 This library contains a L<Venus::Throw> class which provides a mechanism for
5686 generating and raising error objects.
5687  
5688 =back
5689  
5690 =over 4
5691  
5692 =item venus-true
5693  
5694 This library contains a L<Venus::True> class which provides the global C<true>
5695 value.
5696  
5697 =back
5698  
5699 =over 4
5700  
5701 =item venus-try
5702  
5703 This library contains a L<Venus::Try> class which provides an object-oriented
5704 interface for performing complex try/catch operations.
5705  
5706 =back
5707  
5708 =over 4
5709  
5710 =item venus-type
5711  
5712 This library contains a L<Venus::Type> class which provides methods for casting
5713 native data types to objects.
5714  
5715 =back
5716  
5717 =over 4
5718  
5719 =item venus-undef
5720  
5721 This library contains a L<Venus::Undef> class which provides methods for
5722 manipulating undef data.
5723  
5724 =back
5725  
5726 =over 4
5727  
5728 =item venus-unpack
5729  
5730 This library contains a L<Venus::Unpack> class which provides methods for
5731 validating, coercing, and otherwise operating on lists of arguments.
5732  
5733 =back
5734  
5735 =over 4
5736  
5737 =item venus-vars
5738  
5739 This library contains a L<Venus::Vars> class which provides methods for
5740 accessing C<%ENV> items.
5741  
5742 =back
5743  
5744 =over 4
5745  
5746 =item venus-yaml
5747  
5748 This library contains a L<Venus::Yaml> class which provides methods for reading
5749 and writing YAML data.
5750  
5751 =back
5752  
5753 =head1 AUTHORS
5754  
5755 Awncorp, C<awncorp@cpan.org>
5756  
5757 =cut
5758  
5759 =head1 LICENSE
5760  
5761 Copyright (C) 2000, Awncorp, C<awncorp@cpan.org>.
5762  
5763 This program is free software, you can redistribute it and/or modify it under
5764 the terms of the Apache license version 2.0.
5765  
5766 =cut
↑ Summary blib/lib/Venus/Process.pm »