File Coverage

blib/lib/Venus/Space.pm
Criterion Covered Total %
statement 378 386 97.9
branch 64 76 84.2
condition 10 14 71.4
subroutine 91 92 98.9
pod 64 66 96.9
total 607 634 95.7


line stmt bran cond sub pod time code
1             package Venus::Space;
2              
3 10     10   71494 use 5.018;
  10         42  
4              
5 10     10   62 use strict;
  10         22  
  10         241  
6 10     10   46 use warnings;
  10         31  
  10         334  
7              
8 10     10   465 use Venus::Class 'base';
  10         20  
  10         90  
9              
10             base 'Venus::Name';
11              
12             state $SERIAL = 0;
13              
14             # BUILDERS
15              
16             sub build_self {
17 499     499 0 1037 my ($self, $data) = @_;
18              
19 499 50       1517 $self->{value} = $self->package if !$self->lookslike_a_pragma;
20              
21 499         1249 return $self;
22             }
23              
24             # METHODS
25              
26             sub all {
27 3     3 1 10 my ($self, $name, @args) = @_;
28              
29 3         5 my $result = [];
30 3         18 my $class = $self->class;
31              
32 3         8 for my $package ($self->package, @{$self->inherits}) {
  3         15  
33 7         23 push @$result, [$package, $class->new($package)->$name(@args)];
34             }
35              
36 3         16 return $result;
37             }
38              
39             sub append {
40 9     9 1 33 my ($self, @args) = @_;
41              
42 9         48 my $class = $self->class;
43              
44 9         46 my $path = join '/',
45             $self->path, map $class->new($_)->path, @args;
46              
47 9         50 return $class->new($path);
48             }
49              
50             sub array {
51 11     11 1 40 my ($self, $name, @data) = @_;
52              
53 10     10   75 no strict 'refs';
  10         21  
  10         1419  
54              
55 11         36 my $class = $self->package;
56              
57 11 100       43 @{"${class}::${name}"} = @data if @data;
  2         47  
58              
59 11         23 return [@{"${class}::${name}"}];
  11         94  
60             }
61              
62             sub arrays {
63 2     2 1 14 my ($self) = @_;
64              
65 10     10   229 no strict 'refs';
  10         24  
  10         4488  
66              
67 2         18 my $class = $self->package;
68              
69             my $arrays = [
70 6         36 sort grep !!@{"${class}::$_"},
71 2         8 grep /^[_a-zA-Z]\w*$/, keys %{"${class}::"}
  2         40  
72             ];
73              
74 2         13 return $arrays;
75             }
76              
77             sub attributes {
78 2     2 1 9 my ($self) = @_;
79              
80 2         8 return $self->meta->local('attrs');
81             }
82              
83             sub authority {
84 2     2 1 8 my ($self) = @_;
85              
86 2         12 return $self->scalar('AUTHORITY');
87             }
88              
89             sub basename {
90 2     2 1 12 my ($self) = @_;
91              
92 2         16 return $self->parse->[-1];
93             }
94              
95             sub blessed {
96 7     7 1 22 my ($self, $data) = @_;
97              
98 7   100     42 $data //= {};
99              
100 7         34 my $class = $self->load;
101              
102 7         39 return CORE::bless($data, $class);
103             }
104              
105             sub build {
106 3     3 1 9 my ($self, @args) = @_;
107              
108 3         10 my $class = $self->load;
109              
110 3         12 return $self->call('new', $class, @args);
111             }
112              
113             sub call {
114 42     42 1 112 my ($self, $func, @args) = @_;
115              
116 42         77 my $class = $self->load;
117              
118 42 50       87 unless ($func) {
119 0         0 $self->throw('error_on_call_undefined', $class, $func)->error;
120             }
121              
122 42         216 my $next = $class->can($func);
123              
124 42 100       100 unless ($next) {
125 2 100       11 if ($class->can('AUTOLOAD')) {
126 10     10   84 $next = sub { no strict 'refs'; &{"${class}::${func}"}(@args) };
  10     1   24  
  10         6392  
  1         9  
  1         4  
  1         28  
127             }
128             }
129              
130 42 100       96 unless ($next) {
131 1         17 $self->throw('error_on_call_missing', $class, $func)->error;
132             }
133              
134 41         108 @_ = @args; goto $next;
  41         228  
135             }
136              
137             sub chain {
138 3     3 1 11 my ($self, @steps) = @_;
139              
140 3         6 my $result = $self;
141              
142 3         7 for my $step (@steps) {
143 5 100       21 my ($name, @args) = (ref($step) eq 'ARRAY') ? @$step : ($step);
144              
145 5         59 $result = $result->$name(@args);
146             }
147              
148 3         17 return $result;
149             }
150              
151             sub child {
152 6     6 1 21 my ($self, @args) = @_;
153              
154 6         23 return $self->append(@args);
155             }
156              
157             sub children {
158 1     1 1 4 my ($self) = @_;
159              
160 1         4 my %list;
161             my $path;
162 1         0 my $type;
163              
164 1         6 $path = quotemeta $self->path;
165 1         4 $type = 'pm';
166              
167 1         32 my $regexp = qr/$path\/[^\/]+\.$type/;
168              
169 1         92 for my $item (keys %INC) {
170 157 50       387 $list{$item}++ if $item =~ /$regexp$/;
171             }
172              
173 1         9 my %seen;
174              
175 1         3 for my $dir (@INC) {
176 11 100       51 next if $seen{$dir}++;
177              
178 9         27 my $re = quotemeta $dir;
179 27         122 map { s/^$re\///; $list{$_}++ }
  27         72  
180 9         17 grep !$list{$_}, glob "$dir/@{[$self->path]}/*.$type";
  9         32  
181             }
182              
183 1         10 my $class = $self->class;
184              
185             return [
186             map $class->new($_),
187 1         19 map {s/(.*)\.$type$/$1/r}
  27         209  
188             sort keys %list
189             ];
190             }
191              
192             sub cop {
193 2     2 1 9 my ($self, $func, @args) = @_;
194              
195 2         7 my $class = $self->load;
196              
197 2 50       16 unless ($func) {
198 0         0 $self->throw('error_on_cop_undefined', $class, $func)->error;
199             }
200              
201 2         20 my $next = $class->can($func);
202              
203 2 100       9 unless ($next) {
204 1         7 $self->throw('error_on_cop_missing', $class, $func)->error;
205             }
206              
207 1 50   1   12 return sub { $next->(@args ? (@args, @_) : @_) };
  1         30  
208             }
209              
210             sub data {
211 1     1 1 3 my ($self) = @_;
212              
213 10     10   90 no strict 'refs';
  10         30  
  10         3487  
214              
215 1         5 my $class = $self->package;
216              
217 1         8 local $.;
218              
219 1         3 my $handle = \*{"${class}::DATA"};
  1         12  
220              
221 1 50       10 return '' if !fileno $handle;
222              
223 0         0 seek $handle, 0, 0;
224              
225 0         0 my $data = join '', <$handle>;
226              
227 0         0 $data =~ s/^.*\n__DATA__\r?\n/\n/s;
228 0         0 $data =~ s/\n__END__\r?\n.*$/\n/s;
229              
230 0         0 return $data;
231             }
232              
233             sub eval {
234 13     13 1 57 my ($self, @args) = @_;
235              
236 13         52 local $@;
237              
238 13     1   39 my $result = eval join ' ', map "$_", "package @{[$self->package]};", @args;
  13     1   52  
  1     1   15  
  1         2  
  1         81  
  1         11  
  1         2  
  1         65  
  1         7  
  1         5  
  1         79  
239              
240 13 100       137 if (my $error = $@) {
241 2         19 $self->throw('error_on_eval', $self->package, $error)->error;
242             }
243              
244 11         96 return $result;
245             }
246              
247             sub explain {
248 54     54 1 3360 my ($self) = @_;
249              
250 54         195 return $self->package;
251             }
252              
253             sub hash {
254 2     2 1 10 my ($self, $name, @data) = @_;
255              
256 10     10   99 no strict 'refs';
  10         26  
  10         1141  
257              
258 2         9 my $class = $self->package;
259              
260 2 100       10 %{"${class}::${name}"} = (@data) if @data;
  1         7  
261              
262 2         6 return {%{"${class}::${name}"}};
  2         24  
263             }
264              
265             sub hashes {
266 2     2 1 9 my ($self) = @_;
267              
268 10     10   89 no strict 'refs';
  10         48  
  10         2984  
269              
270 2         9 my $class = $self->package;
271              
272             return [
273 14         78 sort grep !!%{"${class}::$_"},
274 2         14 grep /^[_a-zA-Z]\w*$/, keys %{"${class}::"}
  2         40  
275             ];
276             }
277              
278             sub id {
279 2     2 1 9 my ($self) = @_;
280              
281 2         15 return $self->label;
282             }
283              
284             sub init {
285 6     6 1 26 my ($self) = @_;
286              
287 6         42 $self->tryload;
288              
289 6 100       24 $self->eval('sub import') if !$self->loaded;
290              
291 6         30 return $self->package;
292             }
293              
294             sub inherits {
295 8     8 1 18 my ($self) = @_;
296              
297 8         25 return $self->array('ISA');
298             }
299              
300             sub included {
301 428     428 1 688 my ($self) = @_;
302              
303 428         1171 return $INC{$self->format('path', '%s.pm')};
304             }
305              
306             sub inject {
307 1     1 1 5 my ($self, $name, $coderef) = @_;
308              
309 10     10   79 no strict 'refs';
  10         35  
  10         383  
310 10     10   81 no warnings 'redefine';
  10         20  
  10         9668  
311              
312 1         6 my $class = $self->package;
313              
314 1   50 0   5 return *{"${class}::${name}"} = $coderef || sub{$class};
  1         16  
  0         0  
315             }
316              
317             sub integrates {
318 2     2 1 5 my ($self) = @_;
319              
320 2         8 my $roles = $self->meta->roles;
321              
322 2   50     8 return $roles || [];
323             }
324              
325             sub lfile {
326 1     1 1 4 my ($self) = @_;
327              
328 1         6 return $self->format('path', '%s.pm');
329             }
330              
331             sub load {
332 325     325 1 662 my ($self) = @_;
333              
334 325         757 my $class = $self->package;
335              
336 325 100 66     1251 return $class if $class eq 'main' || $self->loaded;
337              
338 19         49 my $error = do{local $@; eval "require $class"; $@};
  19         47  
  19         1150  
  19         304022  
339              
340 19 100       118 if ($error) {
341 6   50     83 $self->throw('error_on_load', $class, $error || 'cause unknown')->error;
342             }
343              
344 13         188 return $class;
345             }
346              
347             sub loaded {
348 427     427 1 794 my ($self) = @_;
349              
350 427 100 100     924 return ($self->included || @{$self->routines}) ? true : false;
351             }
352              
353             sub locate {
354 5     5 1 15 my ($self) = @_;
355              
356 5         10 my $found = '';
357              
358 5         21 my $file = $self->format('path', '%s.pm');
359              
360 5         22 for my $path (@INC) {
361 26 100       408 do { $found = "$path/$file"; last } if -f "$path/$file";
  4         17  
  4         11  
362             }
363              
364 5         35 return $found;
365             }
366              
367             sub meta {
368 5     5 1 14 my ($self) = @_;
369              
370 5         25 require Venus::Meta;
371              
372 5         20 return Venus::Meta->new(name => $self->package);
373             }
374              
375             sub mock {
376 1     1 1 9 my ($self) = @_;
377              
378 1         31 my $name = sprintf '%s::Mock::%04d::%s', $self->class, ++$SERIAL, $self->package;
379              
380 1         7 my $space = $self->class->new($name);
381              
382 1 50       10 $space->do('init')->array('ISA', $self->package) if !$space->loaded;
383              
384 1         7 return $space;
385             }
386              
387             sub name {
388 1     1 1 3 my ($self) = @_;
389              
390 1         4 return $self->package;
391             }
392              
393             sub parent {
394 3     3 1 18 my ($self) = @_;
395              
396 3         6 my @parts = @{$self->parse};
  3         22  
397              
398 3 50       26 pop @parts if @parts > 1;
399              
400 3         19 my $class = $self->class;
401              
402 3         18 return $class->new(join '/', @parts);
403             }
404              
405             sub parse {
406 18     18 1 46 my ($self) = @_;
407              
408             return [
409 18         77 map ucfirst,
410             map join('', map(ucfirst, split /[-_]/)),
411             split /[^-_a-zA-Z0-9.]+/,
412             $self->path
413             ];
414             }
415              
416             sub parts {
417 7     7 1 21 my ($self) = @_;
418              
419 7         21 return $self->parse;
420             }
421              
422             sub pfile {
423 1     1 1 7 my ($self) = @_;
424              
425 1         9 return $self->format('path', '%s.pod');
426             }
427              
428             sub prepend {
429 3     3 1 22 my ($self, @args) = @_;
430              
431 3         16 my $class = $self->class;
432              
433 3         16 my $path = join '/',
434             (map $class->new($_)->path, @args), $self->path;
435              
436 3         14 return $class->new($path);
437             }
438              
439             sub purge {
440 1     1 1 4 my ($self) = @_;
441              
442 1 50       4 return $self if $self->unloaded;
443              
444 1         6 my $package = $self->package;
445              
446 10     10   78 no strict 'refs';
  10         45  
  10         4141  
447              
448 1         11 for my $name (grep !/\A[^:]+::\z/, keys %{"${package}::"}) {
  1         24  
449 5         10 undef *{"${package}::${name}"}; delete ${"${package}::"}{$name};
  5         27  
  5         8  
  5         16  
450             }
451              
452 1         9 delete $INC{$self->format('path', '%s.pm')};
453              
454 1         13 return $self;
455             }
456              
457             sub rebase {
458 1     1 1 6 my ($self, @args) = @_;
459              
460 1         7 my $class = $self->class;
461              
462 1         7 my $path = join '/', map $class->new($_)->path, @args;
463              
464 1         30 return $class->new($self->basename)->prepend($path);
465             }
466              
467             sub reload {
468 2     2 1 7 my ($self) = @_;
469              
470 2         9 $self->unload;
471              
472 2         10 return $self->load;
473             }
474              
475             sub require {
476 4     4 1 14 my ($self, $target) = @_;
477              
478 4 50       108 $target = "'$target'" if -f $target;
479              
480 4         55 return $self->eval("require $target");
481             }
482              
483             sub root {
484 1     1 1 4 my ($self) = @_;
485              
486 1         5 return $self->parse->[0];
487             }
488              
489             sub routine {
490 3     3 1 15 my ($self, $name, $code) = @_;
491              
492 10     10   101 no strict 'refs';
  10         24  
  10         1203  
493              
494 3         13 my $class = $self->package;
495              
496 3 100       17 *{"${class}::${name}"} = $code if $code;
  2         32  
497              
498 3         9 return *{"${class}::${name}"}{"CODE"};
  3         28  
499             }
500              
501             sub routines {
502 209     209 1 438 my ($self) = @_;
503              
504 10     10   77 no strict 'refs';
  10         32  
  10         1608  
505              
506 209         493 my $class = $self->package;
507              
508             return [
509 8047         16631 sort grep *{"${class}::$_"}{"CODE"},
510 209         474 grep /^[_a-zA-Z]\w*$/, keys %{"${class}::"}
  209         5373  
511             ];
512             }
513              
514             sub scalar {
515 6     6 1 21 my ($self, $name, @data) = @_;
516              
517 10     10   95 no strict 'refs';
  10         26  
  10         1164  
518              
519 6         41 my $class = $self->package;
520              
521 6 100       62 ${"${class}::${name}"} = $data[0] if @data;
  1         16  
522              
523 6         17 return ${"${class}::${name}"};
  6         70  
524             }
525              
526             sub scalars {
527 2     2 1 11 my ($self) = @_;
528              
529 10     10   103 no strict 'refs';
  10         34  
  10         10215  
530              
531 2         11 my $class = $self->package;
532              
533             return [
534 19         80 sort grep defined ${"${class}::$_"},
535 2         8 grep /^[_a-zA-Z]\w*$/, keys %{"${class}::"}
  2         51  
536             ];
537             }
538              
539             sub sibling {
540 1     1 1 6 my ($self, @args) = @_;
541              
542 1         15 return $self->parent->append(@args);
543             }
544              
545             sub siblings {
546 1     1 1 4 my ($self) = @_;
547              
548 1         6 my %list;
549             my $path;
550 1         0 my $type;
551              
552 1         5 $path = quotemeta $self->parent->path;
553 1         12 $type = 'pm';
554              
555 1         44 my $regexp = qr/$path\/[^\/]+\.$type/;
556              
557 1         735 for my $item (keys %INC) {
558 219 100       619 $list{$item}++ if $item =~ /$regexp$/;
559             }
560              
561 1         19 my %seen;
562              
563 1         5 for my $dir (@INC) {
564 14 100       100 next if $seen{$dir}++;
565              
566 10         26 my $re = quotemeta $dir;
567 2         32 map { s/^$re\///; $list{$_}++ }
  2         20  
568 10         27 grep !$list{$_}, glob "$dir/@{[$self->path]}/*.$type";
  10         37  
569             }
570              
571 1         7 my $class = $self->class;
572              
573             return [
574             map $class->new($_),
575 1         10 map {s/(.*)\.$type$/$1/r}
  5         74  
576             sort keys %list
577             ];
578             }
579              
580             sub splice {
581 4     4 1 16 my ($self, $offset, $length, @list) = @_;
582              
583 4         22 my $class = $self->class;
584 4         17 my $parts = $self->parts;
585              
586 4 100       27 if (@list) {
    100          
    50          
587 1         3 CORE::splice(@{$parts}, $offset, $length, @list);
  1         5  
588             }
589             elsif (defined $length) {
590 2         5 CORE::splice(@{$parts}, $offset, $length);
  2         5  
591             }
592             elsif (defined $offset) {
593 1         3 CORE::splice(@{$parts}, $offset);
  1         5  
594             }
595              
596 4         20 return $class->new(join '/', @$parts);
597             }
598              
599             sub swap {
600 2     2 1 9 my ($self, $name, $code) = @_;
601              
602 2         9 my $orig = (my $package = $self->package)->can($name);
603              
604 2 50       8 return $orig if !$code;
605              
606 2 100       9 if (!$orig) {
607 1         11 $self->throw('error_on_swap', $package, $name)->error;
608             }
609              
610 1     1   31 $self->routine($name, sub {$code->($orig, @_)});
  1         750  
611              
612 1         7 return $orig;
613             }
614              
615             sub tfile {
616 1     1 1 4 my ($self) = @_;
617              
618 1         5 return $self->format('label', '%s.t');
619             }
620              
621             sub tryload {
622 10     10 1 29 my ($self) = @_;
623              
624 10         23 return do { local $@; eval { $self->load }; int!$@ };
  10         27  
  10         31  
  10         41  
  10         52  
625             }
626              
627             sub use {
628 3     3 1 21 my ($self, $target, @params) = @_;
629              
630 3         10 my $version;
631              
632 3 100       15 ($target, $version) = @$target if ref $target eq 'ARRAY';
633              
634 3         14 $self->require($target);
635              
636 3         16 require Scalar::Util;
637              
638 3 100       36 my @statement = (
639             'no strict "subs";',
640             (
641             Scalar::Util::looks_like_number($version)
642             ? "${target}->VERSION($version);" : ()
643             ),
644             'sub{ my ($target, @params) = @_; $target->import(@params)}'
645             );
646              
647 3         17 $self->eval(join("\n", @statement))->($target, @params);
648              
649 2         32 return $self;
650             }
651              
652             sub variables {
653 1     1 1 4 my ($self) = @_;
654              
655 1         4 return [map [$_, [sort @{$self->$_}]], qw(arrays hashes scalars)];
  3         28  
656             }
657              
658             sub version {
659 2     2 1 9 my ($self) = @_;
660              
661 2         11 return $self->scalar('VERSION');
662             }
663              
664             sub unload {
665 87     87 1 478 my ($self) = @_;
666              
667 87 100       234 return $self if $self->unloaded;
668              
669 53         224 my $package = $self->package;
670              
671 10     10   104 no strict 'refs';
  10         38  
  10         2146  
672              
673 53         178 for my $name (grep !/\A[^:]+::\z/, keys %{"${package}::"}) {
  53         1287  
674 3553         4146 undef *{"${package}::${name}"};
  3553         9186  
675             }
676              
677 53         428 delete $INC{$self->format('path', '%s.pm')};
678              
679 53         276 return $self;
680             }
681              
682             sub unloaded {
683 90     90 0 183 my ($self) = @_;
684              
685 90 100       238 return $self->loaded ? false : true;
686             }
687              
688             sub visible {
689 6     6 1 24 my ($self) = @_;
690              
691 10     10   91 no strict 'refs';
  10         38  
  10         8295  
692              
693 6         28 my $package = $self->package;
694              
695 6 100       18 return (grep !/\A[^:]+::\z/, keys %{"${package}::"}) ? true : false;
  6         108  
696             }
697              
698             # ERRORS
699              
700             sub error_on_call_missing {
701 2     2 1 35 my ($self, $class, $routine) = @_;
702              
703             return {
704 2         30 name => 'on.call.missing',
705             message => "Unable to locate class method \"$routine\" via package \"$class\"",
706             stash => {
707             package => $class,
708             routine => $routine,
709             },
710             };
711             }
712              
713             sub error_on_call_undefined {
714 1     1 1 4 my ($self, $class, $routine) = @_;
715              
716             return {
717 1         25 name => 'on.call.undefined',
718             message => "Attempt to call undefined class method in package \"$class\"",
719             stash => {
720             package => $class,
721             routine => $routine,
722             },
723             };
724             }
725              
726             sub error_on_cop_missing {
727 2     2 1 15 my ($self, $class, $routine) = @_;
728              
729             return {
730 2         34 name => 'on.cop.missing',
731             message => "Unable to locate object method \"$routine\" via package \"$class\"",
732             stash => {
733             package => $class,
734             routine => $routine,
735             },
736             };
737             }
738              
739             sub error_on_cop_undefined {
740 1     1 1 5 my ($self, $class, $routine) = @_;
741              
742             return {
743 1         12 name => 'on.cop.undefined',
744             message => "Attempt to cop undefined object method from package \"$class\"",
745             stash => {
746             package => $class,
747             routine => $routine,
748             },
749             };
750             }
751              
752             sub error_on_eval {
753 3     3 1 17 my ($self, $class, $error) = @_;
754              
755             return {
756 3         43 name => 'on.eval',
757             message => "$error",
758             stash => {
759             package => $class,
760             },
761             };
762             }
763              
764             sub error_on_load {
765 7     7 1 34 my ($self, $class, $cause) = @_;
766              
767             return {
768 7         107 name => 'on.load',
769             message => "Error attempting to load $class: \"$cause\"",
770             stash => {
771             package => $class,
772             },
773             };
774             }
775              
776             sub error_on_swap {
777 2     2 1 8 my ($self, $package, $routine) = @_;
778              
779             return {
780 2         35 name => 'on.swap',
781             message => "Attempt to swap undefined subroutine in package \"$package\"",
782             stash => {
783             package => $package,
784             routine => $routine,
785             },
786             };
787             }
788              
789             1;
790              
791              
792              
793             =head1 NAME
794              
795             Venus::Space - Space Class
796              
797             =cut
798              
799             =head1 ABSTRACT
800              
801             Space Class for Perl 5
802              
803             =cut
804              
805             =head1 SYNOPSIS
806              
807             package main;
808              
809             use Venus::Space;
810              
811             my $space = Venus::Space->new('foo/bar');
812              
813             # $space->package; # Foo::Bar
814              
815             =cut
816              
817             =head1 DESCRIPTION
818              
819             This package provides methods for parsing and manipulating package namespaces.
820              
821             =cut
822              
823             =head1 INHERITS
824              
825             This package inherits behaviors from:
826              
827             L
828              
829             =cut
830              
831             =head1 METHODS
832              
833             This package provides the following methods:
834              
835             =cut
836              
837             =head2 all
838              
839             all(Str $method, Any @args) (ArrayRef[Tuple[Str, Any]])
840              
841             The all method executes any available method on the instance and all instances
842             representing packages inherited by the package represented by the invocant.
843             This method supports dispatching, i.e. providing a method name and arguments
844             whose return value will be acted on by this method.
845              
846             I>
847              
848             =over 4
849              
850             =item all example 1
851              
852             package main;
853              
854             use Venus::Space;
855              
856             my $space = Venus::Space->new('Venus');
857              
858             my $all = $space->all('id');
859              
860             # [["Venus", "Venus"]]
861              
862             =back
863              
864             =over 4
865              
866             =item all example 2
867              
868             package main;
869              
870             use Venus::Space;
871              
872             my $space = Venus::Space->new('Venus/Space');
873              
874             my $all = $space->all('inherits');
875              
876             # [
877             # [
878             # "Venus::Space", ["Venus::Name"]
879             # ],
880             # [
881             # "Venus::Name", ["Venus::Kind::Utility"]
882             # ],
883             # ]
884              
885             =back
886              
887             =over 4
888              
889             =item all example 3
890              
891             package main;
892              
893             use Venus::Space;
894              
895             my $space = Venus::Space->new('Venus/Space');
896              
897             my $all = $space->all('locate');
898              
899             # [
900             # [
901             # "Venus::Space",
902             # "/path/to/lib/Venus/Space.pm",
903             # ],
904             # [
905             # "Venus::Name",
906             # "/path/to/lib/Venus/Name.pm",
907             # ],
908             # ]
909              
910             =back
911              
912             =cut
913              
914             =head2 append
915              
916             append(Str @path) (Space)
917              
918             The append method modifies the object by appending to the package namespace
919             parts.
920              
921             I>
922              
923             =over 4
924              
925             =item append example 1
926              
927             # given: synopsis;
928              
929             my $append = $space->append('baz');
930              
931             # bless({ value => "Foo/Bar/Baz" }, "Venus::Space")
932              
933             =back
934              
935             =over 4
936              
937             =item append example 2
938              
939             # given: synopsis;
940              
941             my $append = $space->append('baz', 'bax');
942              
943             # bless({ value => "Foo/Bar/Baz/Bax" }, "Venus::Space")
944              
945             =back
946              
947             =cut
948              
949             =head2 array
950              
951             array(Str $name, Any @data) (ArrayRef)
952              
953             The array method gets or sets the value for the given package array variable name.
954              
955             I>
956              
957             =over 4
958              
959             =item array example 1
960              
961             # given: synopsis;
962              
963             package Foo::Bar;
964              
965             our @handler = 'start';
966              
967             package main;
968              
969             my $array = $space->array('handler');
970              
971             # ["start"]
972              
973             =back
974              
975             =over 4
976              
977             =item array example 2
978              
979             # given: synopsis;
980              
981             package Foo::Bar;
982              
983             our @handler = 'start';
984              
985             package main;
986              
987             my $array = $space->array('handler', 'restart');
988              
989             # ["restart"]
990              
991             =back
992              
993             =cut
994              
995             =head2 arrays
996              
997             arrays() (ArrayRef)
998              
999             The arrays method searches the package namespace for arrays and returns their
1000             names.
1001              
1002             I>
1003              
1004             =over 4
1005              
1006             =item arrays example 1
1007              
1008             # given: synopsis;
1009              
1010             package Foo::Bar;
1011              
1012             our @handler = 'start';
1013             our @initial = ('next', 'prev');
1014              
1015             package main;
1016              
1017             my $arrays = $space->arrays;
1018              
1019             # ["handler", "initial"]
1020              
1021             =back
1022              
1023             =cut
1024              
1025             =head2 attributes
1026              
1027             attributes() (ArrayRef)
1028              
1029             The attributes method searches the package namespace for attributes and returns
1030             their names. This will not include attributes from roles, mixins, or superclasses.
1031              
1032             I>
1033              
1034             =over 4
1035              
1036             =item attributes example 1
1037              
1038             package Foo::Attrs;
1039              
1040             use Venus::Class 'attr';
1041              
1042             attr 'start';
1043             attr 'abort';
1044              
1045             package main;
1046              
1047             use Venus::Space;
1048              
1049             my $space = Venus::Space->new('foo/attrs');
1050              
1051             my $attributes = $space->attributes;
1052              
1053             # ["start", "abort"]
1054              
1055             =back
1056              
1057             =over 4
1058              
1059             =item attributes example 2
1060              
1061             package Foo::Base;
1062              
1063             use Venus::Class 'attr', 'base';
1064              
1065             attr 'start';
1066             attr 'abort';
1067              
1068             package Foo::Attrs;
1069              
1070             use Venus::Class 'attr';
1071              
1072             attr 'show';
1073             attr 'hide';
1074              
1075             package main;
1076              
1077             use Venus::Space;
1078              
1079             my $space = Venus::Space->new('foo/attrs');
1080              
1081             my $attributes = $space->attributes;
1082              
1083             # ["show", "hide"]
1084              
1085             =back
1086              
1087             =cut
1088              
1089             =head2 authority
1090              
1091             authority() (Maybe[Str])
1092              
1093             The authority method returns the C declared on the target package,
1094             if any.
1095              
1096             I>
1097              
1098             =over 4
1099              
1100             =item authority example 1
1101              
1102             package Foo::Boo;
1103              
1104             package main;
1105              
1106             use Venus::Space;
1107              
1108             my $space = Venus::Space->new('foo/boo');
1109              
1110             my $authority = $space->authority;
1111              
1112             # undef
1113              
1114             =back
1115              
1116             =over 4
1117              
1118             =item authority example 2
1119              
1120             package Foo::Boo;
1121              
1122             our $AUTHORITY = 'cpan:CPANERY';
1123              
1124             package main;
1125              
1126             use Venus::Space;
1127              
1128             my $space = Venus::Space->new('foo/boo');
1129              
1130             my $authority = $space->authority;
1131              
1132             # "cpan:CPANERY"
1133              
1134             =back
1135              
1136             =cut
1137              
1138             =head2 basename
1139              
1140             basename() (Str)
1141              
1142             The basename method returns the last segment of the package namespace parts.
1143              
1144             I>
1145              
1146             =over 4
1147              
1148             =item basename example 1
1149              
1150             # given: synopsis;
1151              
1152             my $basename = $space->basename;
1153              
1154             # "Bar"
1155              
1156             =back
1157              
1158             =cut
1159              
1160             =head2 blessed
1161              
1162             blessed(Ref $data) (Self)
1163              
1164             The blessed method blesses the given value into the package namespace and
1165             returns an object. If no value is given, an empty hashref is used.
1166              
1167             I>
1168              
1169             =over 4
1170              
1171             =item blessed example 1
1172              
1173             # given: synopsis;
1174              
1175             package Foo::Bar;
1176              
1177             sub import;
1178              
1179             package main;
1180              
1181             my $blessed = $space->blessed;
1182              
1183             # bless({}, "Foo::Bar")
1184              
1185             =back
1186              
1187             =over 4
1188              
1189             =item blessed example 2
1190              
1191             # given: synopsis;
1192              
1193             package Foo::Bar;
1194              
1195             sub import;
1196              
1197             package main;
1198              
1199             my $blessed = $space->blessed({okay => 1});
1200              
1201             # bless({ okay => 1 }, "Foo::Bar")
1202              
1203             =back
1204              
1205             =cut
1206              
1207             =head2 build
1208              
1209             build(Any @args) (Self)
1210              
1211             The build method attempts to call C on the package namespace and if
1212             successful returns the resulting object.
1213              
1214             I>
1215              
1216             =over 4
1217              
1218             =item build example 1
1219              
1220             # given: synopsis;
1221              
1222             package Foo::Bar::Baz;
1223              
1224             sub new {
1225             bless {}, $_[0];
1226             }
1227              
1228             package main;
1229              
1230             my $build = $space->child('baz')->build;
1231              
1232             # bless({}, "Foo::Bar::Baz")
1233              
1234             =back
1235              
1236             =over 4
1237              
1238             =item build example 2
1239              
1240             # given: synopsis;
1241              
1242             package Foo::Bar::Bax;
1243              
1244             sub new {
1245             bless $_[1], $_[0];
1246             }
1247              
1248             package main;
1249              
1250             my $build = $space->child('bax')->build({okay => 1});
1251              
1252             # bless({ okay => 1 }, "Foo::Bar::Bax")
1253              
1254             =back
1255              
1256             =over 4
1257              
1258             =item build example 3
1259              
1260             # given: synopsis;
1261              
1262             package Foo::Bar::Bay;
1263              
1264             sub new {
1265             bless $_[1], $_[0];
1266             }
1267              
1268             package main;
1269              
1270             my $build = $space->child('bay')->build([okay => 1]);
1271              
1272             # bless(["okay", 1], "Foo::Bar::Bay")
1273              
1274             =back
1275              
1276             =cut
1277              
1278             =head2 call
1279              
1280             call(Any @args) (Any)
1281              
1282             The call method attempts to call the given subroutine on the package namespace
1283             and if successful returns the resulting value.
1284              
1285             I>
1286              
1287             =over 4
1288              
1289             =item call example 1
1290              
1291             package Foo;
1292              
1293             sub import;
1294              
1295             sub start {
1296             'started'
1297             }
1298              
1299             package main;
1300              
1301             use Venus::Space;
1302              
1303             my $space = Venus::Space->new('foo');
1304              
1305             my $result = $space->call('start');
1306              
1307             # "started"
1308              
1309             =back
1310              
1311             =over 4
1312              
1313             =item call example 2
1314              
1315             package Zoo;
1316              
1317             sub import;
1318              
1319             sub AUTOLOAD {
1320             bless {};
1321             }
1322              
1323             sub DESTROY {
1324             ; # noop
1325             }
1326              
1327             package main;
1328              
1329             use Venus::Space;
1330              
1331             my $space = Venus::Space->new('zoo');
1332              
1333             my $result = $space->call('start');
1334              
1335             # bless({}, "Zoo")
1336              
1337             =back
1338              
1339             =over 4
1340              
1341             =item call example 3
1342              
1343             package main;
1344              
1345             use Venus::Space;
1346              
1347             my $space = Venus::Space->new('foo');
1348              
1349             my $result = $space->call('missing');
1350              
1351             # Exception! (isa Venus::Space::Error) (see error_on_call_missing)
1352              
1353             =back
1354              
1355             =cut
1356              
1357             =head2 chain
1358              
1359             chain(Str | Tuple[Str, Any] @steps) (Any)
1360              
1361             The chain method chains one or more method calls and returns the result.
1362              
1363             I>
1364              
1365             =over 4
1366              
1367             =item chain example 1
1368              
1369             package Chu::Chu0;
1370              
1371             sub import;
1372              
1373             package main;
1374              
1375             use Venus::Space;
1376              
1377             my $space = Venus::Space->new('Chu::Chu0');
1378              
1379             my $result = $space->chain('blessed');
1380              
1381             # bless({}, "Chu::Chu0")
1382              
1383             =back
1384              
1385             =over 4
1386              
1387             =item chain example 2
1388              
1389             package Chu::Chu1;
1390              
1391             sub new {
1392             bless pop;
1393             }
1394              
1395             sub frame {
1396             [@_]
1397             }
1398              
1399             package main;
1400              
1401             use Venus::Space;
1402              
1403             my $space = Venus::Space->new('Chu::Chu1');
1404              
1405             my $result = $space->chain(['blessed', {1..4}], 'frame');
1406              
1407             # [bless({ 1 => 2, 3 => 4 }, "Chu::Chu1")]
1408              
1409             =back
1410              
1411             =over 4
1412              
1413             =item chain example 3
1414              
1415             package Chu::Chu2;
1416              
1417             sub new {
1418             bless pop;
1419             }
1420              
1421             sub frame {
1422             [@_]
1423             }
1424              
1425             package main;
1426              
1427             use Venus::Space;
1428              
1429             my $space = Venus::Space->new('Chu::Chu2');
1430              
1431             my $chain = $space->chain('blessed', ['frame', {1..4}]);
1432              
1433             # [bless({}, "Chu::Chu2"), { 1 => 2, 3 => 4 }]
1434              
1435             =back
1436              
1437             =cut
1438              
1439             =head2 child
1440              
1441             child(Str @path) (Space)
1442              
1443             The child method returns a new L object for the child
1444             package namespace.
1445              
1446             I>
1447              
1448             =over 4
1449              
1450             =item child example 1
1451              
1452             # given: synopsis;
1453              
1454             my $child = $space->child('baz');
1455              
1456             # bless({ value => "Foo/Bar/Baz" }, "Venus::Space")
1457              
1458             =back
1459              
1460             =cut
1461              
1462             =head2 children
1463              
1464             children() (ArrayRef[Object])
1465              
1466             The children method searches C<%INC> and C<@INC> and retuns a list of
1467             L objects for each child namespace found (one level deep).
1468              
1469             I>
1470              
1471             =over 4
1472              
1473             =item children example 1
1474              
1475             package main;
1476              
1477             use Venus::Space;
1478              
1479             my $space = Venus::Space->new('c_p_a_n');
1480              
1481             my $children = $space->children;
1482              
1483             # [
1484             # bless({ value => "CPAN/Author" }, "Venus::Space"),
1485             # bless({ value => "CPAN/Bundle" }, "Venus::Space"),
1486             # bless({ value => "CPAN/CacheMgr" }, "Venus::Space"),
1487             # ...
1488             # ]
1489              
1490             =back
1491              
1492             =cut
1493              
1494             =head2 cop
1495              
1496             cop(Str $method, Any @args) (CodeRef)
1497              
1498             The cop method attempts to curry the given subroutine on the package namespace
1499             and if successful returns a closure. This method supports dispatching, i.e.
1500             providing a method name and arguments whose return value will be acted on by
1501             this method.
1502              
1503             I>
1504              
1505             =over 4
1506              
1507             =item cop example 1
1508              
1509             package Foo::Bar;
1510              
1511             sub import;
1512              
1513             sub handler {
1514             [@_]
1515             }
1516              
1517             package main;
1518              
1519             use Venus::Space;
1520              
1521             my $space = Venus::Space->new('foo/bar');
1522              
1523             my $code = $space->cop('handler', $space->blessed);
1524              
1525             # sub { Foo::Bar::handler(..., @_) }
1526              
1527             =back
1528              
1529             =over 4
1530              
1531             =item cop example 2
1532              
1533             package main;
1534              
1535             use Venus::Space;
1536              
1537             my $space = Venus::Space->new('foo/bar');
1538              
1539             my $code = $space->cop('missing', $space->blessed);
1540              
1541             # Exception! (isa Venus::Space::Error) (see error_on_cop_missing)
1542              
1543             =back
1544              
1545             =cut
1546              
1547             =head2 data
1548              
1549             data() (Str)
1550              
1551             The data method attempts to read and return any content stored in the C
1552             section of the package namespace.
1553              
1554             I>
1555              
1556             =over 4
1557              
1558             =item data example 1
1559              
1560             # given: synopsis;
1561              
1562             my $data = $space->data;
1563              
1564             # ""
1565              
1566             =back
1567              
1568             =cut
1569              
1570             =head2 eval
1571              
1572             eval(Str @data) (Any)
1573              
1574             The eval method takes a list of strings and evaluates them under the namespace
1575             represented by the instance.
1576              
1577             I>
1578              
1579             =over 4
1580              
1581             =item eval example 1
1582              
1583             package main;
1584              
1585             use Venus::Space;
1586              
1587             my $space = Venus::Space->new('foo');
1588              
1589             my $eval = $space->eval('our $VERSION = 0.01');
1590              
1591             # 0.01
1592              
1593             =back
1594              
1595             =over 4
1596              
1597             =item eval example 2
1598              
1599             package main;
1600              
1601             use Venus::Space;
1602              
1603             my $space = Venus::Space->new('foo');
1604              
1605             my $eval = $space->eval('die');
1606              
1607             # Exception! (isa Venus::Space::Error) (see error_on_eval)
1608              
1609             =back
1610              
1611             =cut
1612              
1613             =head2 explain
1614              
1615             explain() (Str)
1616              
1617             The explain method returns the package name and is used in stringification
1618             operations.
1619              
1620             I>
1621              
1622             =over 4
1623              
1624             =item explain example 1
1625              
1626             # given: synopsis;
1627              
1628             my $explain = $space->explain;
1629              
1630             # "Foo::Bar"
1631              
1632             =back
1633              
1634             =cut
1635              
1636             =head2 hash
1637              
1638             hash(Str $name, Any @data) (HashRef)
1639              
1640             The hash method gets or sets the value for the given package hash variable name.
1641              
1642             I>
1643              
1644             =over 4
1645              
1646             =item hash example 1
1647              
1648             # given: synopsis;
1649              
1650             package Foo::Bar;
1651              
1652             our %settings = (
1653             active => 1
1654             );
1655              
1656             package main;
1657              
1658             my $hash = $space->hash('settings');
1659              
1660             # { active => 1 }
1661              
1662             =back
1663              
1664             =over 4
1665              
1666             =item hash example 2
1667              
1668             # given: synopsis;
1669              
1670             package Foo::Bar;
1671              
1672             our %settings = (
1673             active => 1
1674             );
1675              
1676             package main;
1677              
1678             my $hash = $space->hash('settings', inactive => 1);
1679              
1680             # { inactive => 1 }
1681              
1682             =back
1683              
1684             =cut
1685              
1686             =head2 hashes
1687              
1688             hashes() (ArrayRef)
1689              
1690             The hashes method searches the package namespace for hashes and returns their
1691             names.
1692              
1693             I>
1694              
1695             =over 4
1696              
1697             =item hashes example 1
1698              
1699             # given: synopsis;
1700              
1701             package Foo::Bar;
1702              
1703             our %defaults = (
1704             active => 0
1705             );
1706              
1707             our %settings = (
1708             active => 1
1709             );
1710              
1711             package main;
1712              
1713             my $hashes = $space->hashes;
1714              
1715             # ["defaults", "settings"]
1716              
1717             =back
1718              
1719             =cut
1720              
1721             =head2 id
1722              
1723             id() (Str)
1724              
1725             The id method returns the fully-qualified package name as a label.
1726              
1727             I>
1728              
1729             =over 4
1730              
1731             =item id example 1
1732              
1733             # given: synopsis;
1734              
1735             my $id = $space->id;
1736              
1737             # "Foo_Bar"
1738              
1739             =back
1740              
1741             =cut
1742              
1743             =head2 included
1744              
1745             included() (Str | Undef)
1746              
1747             The included method returns the path of the namespace if it exists in C<%INC>.
1748              
1749             I>
1750              
1751             =over 4
1752              
1753             =item included example 1
1754              
1755             package main;
1756              
1757             use Venus::Space;
1758              
1759             my $space = Venus::Space->new('Venus/Space');
1760              
1761             my $included = $space->included;
1762              
1763             # "/path/to/lib/Venus/Space.pm"
1764              
1765             =back
1766              
1767             =cut
1768              
1769             =head2 inherits
1770              
1771             inherits() (ArrayRef)
1772              
1773             The inherits method returns the list of superclasses the target package is
1774             derived from.
1775              
1776             I>
1777              
1778             =over 4
1779              
1780             =item inherits example 1
1781              
1782             package Bar;
1783              
1784             package main;
1785              
1786             use Venus::Space;
1787              
1788             my $space = Venus::Space->new('bar');
1789              
1790             my $inherits = $space->inherits;
1791              
1792             # []
1793              
1794             =back
1795              
1796             =over 4
1797              
1798             =item inherits example 2
1799              
1800             package Foo;
1801              
1802             sub import;
1803              
1804             package Bar;
1805              
1806             use base 'Foo';
1807              
1808             package main;
1809              
1810             use Venus::Space;
1811              
1812             my $space = Venus::Space->new('bar');
1813              
1814             my $inherits = $space->inherits;
1815              
1816             # ["Foo"]
1817              
1818             =back
1819              
1820             =cut
1821              
1822             =head2 init
1823              
1824             init() (Str)
1825              
1826             The init method ensures that the package namespace is loaded and, whether
1827             created in-memory or on-disk, is flagged as being loaded and loadable.
1828              
1829             I>
1830              
1831             =over 4
1832              
1833             =item init example 1
1834              
1835             package main;
1836              
1837             use Venus::Space;
1838              
1839             my $space = Venus::Space->new('kit');
1840              
1841             my $init = $space->init;
1842              
1843             # "Kit"
1844              
1845             =back
1846              
1847             =cut
1848              
1849             =head2 inject
1850              
1851             inject(Str $name, Maybe[CodeRef] $coderef) (Any)
1852              
1853             The inject method monkey-patches the package namespace, installing a named
1854             subroutine into the package which can then be called normally, returning the
1855             fully-qualified subroutine name.
1856              
1857             I>
1858              
1859             =over 4
1860              
1861             =item inject example 1
1862              
1863             package main;
1864              
1865             use Venus::Space;
1866              
1867             my $space = Venus::Space->new('kit');
1868              
1869             my $inject = $space->inject('build', sub { 'finished' });
1870              
1871             # *Kit::build
1872              
1873             =back
1874              
1875             =cut
1876              
1877             =head2 integrates
1878              
1879             integrates() (ArrayRef)
1880              
1881             The integrates method returns the list of roles integrated into the target
1882             package.
1883              
1884             I>
1885              
1886             =over 4
1887              
1888             =item integrates example 1
1889              
1890             # given: synopsis
1891              
1892             package main;
1893              
1894             my $integrates = $space->integrates;
1895              
1896             # []
1897              
1898             =back
1899              
1900             =over 4
1901              
1902             =item integrates example 2
1903              
1904             package main;
1905              
1906             use Venus::Space;
1907              
1908             my $space = Venus::Space->new('Venus::Test');
1909              
1910             my $integrates = $space->integrates;
1911              
1912             # [...]
1913              
1914             =back
1915              
1916             =cut
1917              
1918             =head2 lfile
1919              
1920             lfile() (Str)
1921              
1922             The lfile method returns a C<.pm> file path for the underlying package.
1923              
1924             I>
1925              
1926             =over 4
1927              
1928             =item lfile example 1
1929              
1930             # given: synopsis
1931              
1932             package main;
1933              
1934             my $lfile = $space->lfile;
1935              
1936             # "Foo/Bar.pm"
1937              
1938             =back
1939              
1940             =cut
1941              
1942             =head2 load
1943              
1944             load() (Str)
1945              
1946             The load method checks whether the package namespace is already loaded and if
1947             not attempts to load the package. If the package is not loaded and is not
1948             loadable, this method will throw an exception using confess. If the package is
1949             loadable, this method returns truthy with the package name. As a workaround for
1950             packages that only exist in-memory, if the package contains a C, C,
1951             C, or C routine it will be recognized as having been loaded.
1952              
1953             I>
1954              
1955             =over 4
1956              
1957             =item load example 1
1958              
1959             package main;
1960              
1961             use Venus::Space;
1962              
1963             my $space = Venus::Space->new('c_p_a_n');
1964              
1965             my $load = $space->load;
1966              
1967             # "CPAN"
1968              
1969             =back
1970              
1971             =over 4
1972              
1973             =item load example 2
1974              
1975             package main;
1976              
1977             use Venus::Space;
1978              
1979             my $space = Venus::Space->new('no/thing');
1980              
1981             my $load = $space->load;
1982              
1983             # Exception! (isa Venus::Space::Error) (see error_on_load)
1984              
1985             =back
1986              
1987             =cut
1988              
1989             =head2 loaded
1990              
1991             loaded() (Bool)
1992              
1993             The loaded method checks whether the package namespace is already loaded and
1994             returns truthy or falsy.
1995              
1996             I>
1997              
1998             =over 4
1999              
2000             =item loaded example 1
2001              
2002             package main;
2003              
2004             use Venus::Space;
2005              
2006             my $space = Venus::Space->new('Kit');
2007              
2008             $space->init;
2009              
2010             $space->unload;
2011              
2012             my $loaded = $space->loaded;
2013              
2014             # 0
2015              
2016             =back
2017              
2018             =over 4
2019              
2020             =item loaded example 2
2021              
2022             package main;
2023              
2024             use Venus::Space;
2025              
2026             my $space = Venus::Space->new('Kit');
2027              
2028             $space->init;
2029              
2030             my $loaded = $space->loaded;
2031              
2032             # 1
2033              
2034             =back
2035              
2036             =cut
2037              
2038             =head2 locate
2039              
2040             locate() (Str)
2041              
2042             The locate method checks whether the package namespace is available in
2043             C<@INC>, i.e. on disk. This method returns the file if found or an empty
2044             string.
2045              
2046             I>
2047              
2048             =over 4
2049              
2050             =item locate example 1
2051              
2052             package main;
2053              
2054             use Venus::Space;
2055              
2056             my $space = Venus::Space->new('xyz');
2057              
2058             my $locate = $space->locate;
2059              
2060             # ""
2061              
2062             =back
2063              
2064             =over 4
2065              
2066             =item locate example 2
2067              
2068             package main;
2069              
2070             use Venus::Space;
2071              
2072             my $space = Venus::Space->new('data/dumper');
2073              
2074             $space->load;
2075              
2076             my $locate = $space->locate;
2077              
2078             # "/path/to/lib/Data/Dumper.pm"
2079              
2080             =back
2081              
2082             =cut
2083              
2084             =head2 meta
2085              
2086             meta() (Meta)
2087              
2088             The meta method returns a L object representing the underlying
2089             package namespace. To access the meta object for the instance itself, use the
2090             superclass' L method.
2091              
2092             I>
2093              
2094             =over 4
2095              
2096             =item meta example 1
2097              
2098             # given: synopsis
2099              
2100             package main;
2101              
2102             my $meta = $space->meta;
2103              
2104             # bless({'name' => 'Foo::Bar'}, 'Venus::Meta')
2105              
2106             =back
2107              
2108             =over 4
2109              
2110             =item meta example 2
2111              
2112             # given: synopsis
2113              
2114             package main;
2115              
2116             my $meta = $space->META;
2117              
2118             # bless({'name' => 'Venus::Space'}, 'Venus::Meta')
2119              
2120             =back
2121              
2122             =cut
2123              
2124             =head2 mock
2125              
2126             mock() (Space)
2127              
2128             The mock method returns a L object representing an anonymous
2129             package that derives from the invoking package.
2130              
2131             I>
2132              
2133             =over 4
2134              
2135             =item mock example 1
2136              
2137             # given: synopsis
2138              
2139             package main;
2140              
2141             my $mock = $space->mock;
2142              
2143             # bless({'name' => 'Venus::Space::Mock::0001::Foo::Bar'}, 'Venus::Space')
2144              
2145             # $mock->isa('Foo::Bar') # true
2146              
2147             =back
2148              
2149             =cut
2150              
2151             =head2 name
2152              
2153             name() (Str)
2154              
2155             The name method returns the fully-qualified package name.
2156              
2157             I>
2158              
2159             =over 4
2160              
2161             =item name example 1
2162              
2163             # given: synopsis;
2164              
2165             my $name = $space->name;
2166              
2167             # "Foo::Bar"
2168              
2169             =back
2170              
2171             =cut
2172              
2173             =head2 parent
2174              
2175             parent() (Space)
2176              
2177             The parent method returns a new L object for the parent package
2178             namespace.
2179              
2180             I>
2181              
2182             =over 4
2183              
2184             =item parent example 1
2185              
2186             # given: synopsis;
2187              
2188             my $parent = $space->parent;
2189              
2190             # bless({ value => "Foo" }, "Venus::Space")
2191              
2192             =back
2193              
2194             =cut
2195              
2196             =head2 parse
2197              
2198             parse() (ArrayRef)
2199              
2200             The parse method parses the string argument and returns an arrayref of package
2201             namespace segments (parts).
2202              
2203             I>
2204              
2205             =over 4
2206              
2207             =item parse example 1
2208              
2209             # given: synopsis;
2210              
2211             my $parse = $space->parse;
2212              
2213             # ["Foo", "Bar"]
2214              
2215             =back
2216              
2217             =over 4
2218              
2219             =item parse example 2
2220              
2221             package main;
2222              
2223             use Venus::Space;
2224              
2225             my $space = Venus::Space->new('Foo/Bar');
2226              
2227             my $parse = $space->parse;
2228              
2229             # ["Foo", "Bar"]
2230              
2231             =back
2232              
2233             =over 4
2234              
2235             =item parse example 3
2236              
2237             package main;
2238              
2239             use Venus::Space;
2240              
2241             my $space = Venus::Space->new('Foo\Bar');
2242              
2243             my $parse = $space->parse;
2244              
2245             # ["Foo", "Bar"]
2246              
2247             =back
2248              
2249             =over 4
2250              
2251             =item parse example 4
2252              
2253             package main;
2254              
2255             use Venus::Space;
2256              
2257             my $space = Venus::Space->new('Foo-Bar');
2258              
2259             my $parse = $space->parse;
2260              
2261             # ["FooBar"]
2262              
2263             =back
2264              
2265             =over 4
2266              
2267             =item parse example 5
2268              
2269             package main;
2270              
2271             use Venus::Space;
2272              
2273             my $space = Venus::Space->new('Foo_Bar');
2274              
2275             my $parse = $space->parse;
2276              
2277             # ["FooBar"]
2278              
2279             =back
2280              
2281             =cut
2282              
2283             =head2 parts
2284              
2285             parts() (ArrayRef)
2286              
2287             The parts method returns an arrayref of package namespace segments (parts).
2288              
2289             I>
2290              
2291             =over 4
2292              
2293             =item parts example 1
2294              
2295             package main;
2296              
2297             use Venus::Space;
2298              
2299             my $space = Venus::Space->new('Foo');
2300              
2301             my $parts = $space->parts;
2302              
2303             # ["Foo"]
2304              
2305             =back
2306              
2307             =over 4
2308              
2309             =item parts example 2
2310              
2311             package main;
2312              
2313             use Venus::Space;
2314              
2315             my $space = Venus::Space->new('Foo/Bar');
2316              
2317             my $parts = $space->parts;
2318              
2319             # ["Foo", "Bar"]
2320              
2321             =back
2322              
2323             =over 4
2324              
2325             =item parts example 3
2326              
2327             package main;
2328              
2329             use Venus::Space;
2330              
2331             my $space = Venus::Space->new('Foo_Bar');
2332              
2333             my $parts = $space->parts;
2334              
2335             # ["FooBar"]
2336              
2337             =back
2338              
2339             =cut
2340              
2341             =head2 pfile
2342              
2343             pfile() (Str)
2344              
2345             The pfile method returns a C<.pod> file path for the underlying package.
2346              
2347             I>
2348              
2349             =over 4
2350              
2351             =item pfile example 1
2352              
2353             # given: synopsis
2354              
2355             package main;
2356              
2357             my $pfile = $space->pfile;
2358              
2359             # "Foo/Bar.pod"
2360              
2361             =back
2362              
2363             =cut
2364              
2365             =head2 prepend
2366              
2367             prepend(Str @path) (Space)
2368              
2369             The prepend method modifies the object by prepending to the package namespace
2370             parts.
2371              
2372             I>
2373              
2374             =over 4
2375              
2376             =item prepend example 1
2377              
2378             # given: synopsis;
2379              
2380             my $prepend = $space->prepend('etc');
2381              
2382             # bless({ value => "Etc/Foo/Bar" }, "Venus::Space")
2383              
2384             =back
2385              
2386             =over 4
2387              
2388             =item prepend example 2
2389              
2390             # given: synopsis;
2391              
2392             my $prepend = $space->prepend('etc', 'tmp');
2393              
2394             # bless({ value => "Etc/Tmp/Foo/Bar" }, "Venus::Space")
2395              
2396             =back
2397              
2398             =cut
2399              
2400             =head2 purge
2401              
2402             purge() (Self)
2403              
2404             The purge method purges a package space by expunging its symbol table and
2405             removing it from C<%INC>.
2406              
2407             I>
2408              
2409             =over 4
2410              
2411             =item purge example 1
2412              
2413             package main;
2414              
2415             use Venus::Space;
2416              
2417             # Bar::Gen is generated with $VERSION as 0.01
2418              
2419             my $space = Venus::Space->new('Bar/Gen');
2420              
2421             $space->load;
2422              
2423             my $purge = $space->purge;
2424              
2425             # bless({ value => "Bar::Gen" }, "Venus::Space")
2426              
2427             # Bar::Gen->VERSION was 0.01, now undef
2428              
2429             # Symbol table is gone, $space->visible is 0
2430              
2431             =back
2432              
2433             =cut
2434              
2435             =head2 rebase
2436              
2437             rebase(Str @path) (Space)
2438              
2439             The rebase method returns an object by prepending the package namespace
2440             specified to the base of the current object's namespace.
2441              
2442             I>
2443              
2444             =over 4
2445              
2446             =item rebase example 1
2447              
2448             # given: synopsis;
2449              
2450             my $rebase = $space->rebase('zoo');
2451              
2452             # bless({ value => "Zoo/Bar" }, "Venus::Space")
2453              
2454             =back
2455              
2456             =cut
2457              
2458             =head2 reload
2459              
2460             reload() (Str)
2461              
2462             The reload method attempts to delete and reload the package namespace using the
2463             L method. B Reloading is additive and will overwrite existing
2464             symbols but does not remove symbols.
2465              
2466             I>
2467              
2468             =over 4
2469              
2470             =item reload example 1
2471              
2472             package main;
2473              
2474             use Venus::Space;
2475              
2476             # Foo::Gen is generated with $VERSION as 0.01
2477              
2478             my $space = Venus::Space->new('Foo/Gen');
2479              
2480             my $reload = $space->reload;
2481              
2482             # Foo::Gen
2483             # Foo::Gen->VERSION is 0.01
2484              
2485             =back
2486              
2487             =over 4
2488              
2489             =item reload example 2
2490              
2491             package main;
2492              
2493             use Venus::Space;
2494              
2495             # Foo::Gen is generated with $VERSION as 0.02
2496              
2497             my $space = Venus::Space->new('Foo/Gen');
2498              
2499             my $reload = $space->reload;
2500              
2501             # Foo::Gen
2502             # Foo::Gen->VERSION is 0.02
2503              
2504             =back
2505              
2506             =cut
2507              
2508             =head2 require
2509              
2510             require(Str $target) (Any)
2511              
2512             The require method executes a C statement within the package namespace
2513             specified.
2514              
2515             I>
2516              
2517             =over 4
2518              
2519             =item require example 1
2520              
2521             # given: synopsis;
2522              
2523             my $require = $space->require('Venus');
2524              
2525             # 1
2526              
2527             =back
2528              
2529             =cut
2530              
2531             =head2 root
2532              
2533             root() (Str)
2534              
2535             The root method returns the root package namespace segments (parts). Sometimes
2536             separating the C from the C helps identify how subsequent child
2537             objects were derived.
2538              
2539             I>
2540              
2541             =over 4
2542              
2543             =item root example 1
2544              
2545             # given: synopsis;
2546              
2547             my $root = $space->root;
2548              
2549             # "Foo"
2550              
2551             =back
2552              
2553             =cut
2554              
2555             =head2 routine
2556              
2557             routine(Str $name, CodeRef $code) (CodeRef)
2558              
2559             The routine method gets or sets the subroutine reference for the given subroutine
2560             name.
2561              
2562             I>
2563              
2564             =over 4
2565              
2566             =item routine example 1
2567              
2568             package Foo;
2569              
2570             sub cont {
2571             [@_]
2572             }
2573              
2574             sub abort {
2575             [@_]
2576             }
2577              
2578             package main;
2579              
2580             use Venus::Space;
2581              
2582             my $space = Venus::Space->new('foo');
2583              
2584             my $routine = $space->routine('cont');
2585              
2586             # sub { ... }
2587              
2588             =back
2589              
2590             =over 4
2591              
2592             =item routine example 2
2593              
2594             package Foo;
2595              
2596             sub cont {
2597             [@_]
2598             }
2599              
2600             sub abort {
2601             [@_]
2602             }
2603              
2604             package main;
2605              
2606             use Venus::Space;
2607              
2608             my $space = Venus::Space->new('foo');
2609              
2610             my $routine = $space->routine('report', sub{[@_]});
2611              
2612             # sub { ... }
2613              
2614             =back
2615              
2616             =cut
2617              
2618             =head2 routines
2619              
2620             routines() (ArrayRef)
2621              
2622             The routines method searches the package namespace for routines and returns
2623             their names.
2624              
2625             I>
2626              
2627             =over 4
2628              
2629             =item routines example 1
2630              
2631             package Foo::Subs;
2632              
2633             sub start {
2634             1
2635             }
2636              
2637             sub abort {
2638             1
2639             }
2640              
2641             package main;
2642              
2643             use Venus::Space;
2644              
2645             my $space = Venus::Space->new('foo/subs');
2646              
2647             my $routines = $space->routines;
2648              
2649             # ["abort", "start"]
2650              
2651             =back
2652              
2653             =cut
2654              
2655             =head2 scalar
2656              
2657             scalar(Str $name, Any @data) (Any)
2658              
2659             The scalar method gets or sets the value for the given package scalar variable name.
2660              
2661             I>
2662              
2663             =over 4
2664              
2665             =item scalar example 1
2666              
2667             # given: synopsis;
2668              
2669             package Foo::Bar;
2670              
2671             our $root = '/path/to/file';
2672              
2673             package main;
2674              
2675             my $scalar = $space->scalar('root');
2676              
2677             # "/path/to/file"
2678              
2679             =back
2680              
2681             =over 4
2682              
2683             =item scalar example 2
2684              
2685             # given: synopsis;
2686              
2687             package Foo::Bar;
2688              
2689             our $root = '/path/to/file';
2690              
2691             package main;
2692              
2693             my $scalar = $space->scalar('root', '/tmp/path/to/file');
2694              
2695             # "/tmp/path/to/file"
2696              
2697             =back
2698              
2699             =cut
2700              
2701             =head2 scalars
2702              
2703             scalars() (ArrayRef)
2704              
2705             The scalars method searches the package namespace for scalars and returns their
2706             names.
2707              
2708             I>
2709              
2710             =over 4
2711              
2712             =item scalars example 1
2713              
2714             # given: synopsis;
2715              
2716             package Foo::Bar;
2717              
2718             our $root = 'root';
2719             our $base = 'path/to';
2720             our $file = 'file';
2721              
2722             package main;
2723              
2724             my $scalars = $space->scalars;
2725              
2726             # ["base", "file", "root"]
2727              
2728             =back
2729              
2730             =cut
2731              
2732             =head2 sibling
2733              
2734             sibling(Str $path) (Space)
2735              
2736             The sibling method returns a new L object for the sibling package
2737             namespace.
2738              
2739             I>
2740              
2741             =over 4
2742              
2743             =item sibling example 1
2744              
2745             # given: synopsis;
2746              
2747             my $sibling = $space->sibling('baz');
2748              
2749             # bless({ value => "Foo/Baz" }, "Venus::Space")
2750              
2751             =back
2752              
2753             =cut
2754              
2755             =head2 siblings
2756              
2757             siblings() (ArrayRef[Object])
2758              
2759             The siblings method searches C<%INC> and C<@INC> and retuns a list of
2760             L objects for each sibling namespace found (one level deep).
2761              
2762             I>
2763              
2764             =over 4
2765              
2766             =item siblings example 1
2767              
2768             package main;
2769              
2770             use Venus::Space;
2771              
2772             my $space = Venus::Space->new('encode/m_i_m_e');
2773              
2774             my $siblings = $space->siblings;
2775              
2776             # [
2777             # bless({ value => "Encode/MIME/Header" }, "Venus::Space"),
2778             # bless({ value => "Encode/MIME/Name" }, "Venus::Space"),
2779             # ...
2780             # ]
2781              
2782             =back
2783              
2784             =cut
2785              
2786             =head2 splice
2787              
2788             splice(Int $offset, Int $length, Any @list) (Space)
2789              
2790             The splice method perform a Perl L operation on the package
2791             namespace.
2792              
2793             I>
2794              
2795             =over 4
2796              
2797             =item splice example 1
2798              
2799             package main;
2800              
2801             use Venus::Space;
2802              
2803             my $space = Venus::Space->new('foo/baz');
2804              
2805             my $splice = $space->splice(1, 0, 'bar');
2806              
2807             # bless({ value => "Foo/Bar/Baz" }, "Venus::Space")
2808              
2809             =back
2810              
2811             =over 4
2812              
2813             =item splice example 2
2814              
2815             package main;
2816              
2817             use Venus::Space;
2818              
2819             my $space = Venus::Space->new('foo/baz');
2820              
2821             my $splice = $space->splice(1, 1);
2822              
2823             # bless({ value => "Foo" }, "Venus::Space")
2824              
2825             =back
2826              
2827             =over 4
2828              
2829             =item splice example 3
2830              
2831             package main;
2832              
2833             use Venus::Space;
2834              
2835             my $space = Venus::Space->new('foo/baz');
2836              
2837             my $splice = $space->splice(-2, 1);
2838              
2839             # bless({ value => "Baz" }, "Venus::Space")
2840              
2841             =back
2842              
2843             =over 4
2844              
2845             =item splice example 4
2846              
2847             package main;
2848              
2849             use Venus::Space;
2850              
2851             my $space = Venus::Space->new('foo/baz');
2852              
2853             my $splice = $space->splice(1);
2854              
2855             # bless({ value => "Foo" }, "Venus::Space")
2856              
2857             =back
2858              
2859             =cut
2860              
2861             =head2 swap
2862              
2863             swap(Str $name, CodeRef $code) (CodeRef)
2864              
2865             The swap method overwrites the named subroutine in the underlying package with
2866             the code reference provided and returns the original subroutine as a code
2867             reference. The code provided will be passed a reference to the original
2868             subroutine as its first argument.
2869              
2870             I>
2871              
2872             =over 4
2873              
2874             =item swap example 1
2875              
2876             package Foo::Swap;
2877              
2878             use Venus::Class;
2879              
2880             package main;
2881              
2882             use Venus::Space;
2883              
2884             my $space = Venus::Space->new('foo/swap');
2885              
2886             my $subroutine = $space->swap('new', sub {
2887             my ($next, @args) = @_;
2888             my $self = $next->(@args);
2889             $self->{swapped} = 1;
2890             return $self;
2891             });
2892              
2893             # sub { ... }
2894              
2895             =back
2896              
2897             =over 4
2898              
2899             =item swap example 2
2900              
2901             package Foo::Swap;
2902              
2903             use Venus::Class;
2904              
2905             package main;
2906              
2907             use Venus::Space;
2908              
2909             my $space = Venus::Space->new('foo/swap');
2910              
2911             my $subroutine = $space->swap('something', sub {
2912             my ($next, @args) = @_;
2913             my $self = $next->(@args);
2914             $self->{swapped} = 1;
2915             return $self;
2916             });
2917              
2918             # Exception! (isa Venus::Space::Error) (see error_on_swap)
2919              
2920             =back
2921              
2922             =cut
2923              
2924             =head2 tfile
2925              
2926             tfile() (Str)
2927              
2928             The tfile method returns a C<.t> file path for the underlying package.
2929              
2930             I>
2931              
2932             =over 4
2933              
2934             =item tfile example 1
2935              
2936             # given: synopsis
2937              
2938             package main;
2939              
2940             my $tfile = $space->tfile;
2941              
2942             # "Foo_Bar.t"
2943              
2944             =back
2945              
2946             =cut
2947              
2948             =head2 tryload
2949              
2950             tryload() (Bool)
2951              
2952             The tryload method attempt to C the represented package using the
2953             L method and returns truthy/falsy based on whether the package was
2954             loaded.
2955              
2956             I>
2957              
2958             =over 4
2959              
2960             =item tryload example 1
2961              
2962             package main;
2963              
2964             use Venus::Space;
2965              
2966             my $space = Venus::Space->new('c_p_a_n');
2967              
2968             my $tryload = $space->tryload;
2969              
2970             # 1
2971              
2972             =back
2973              
2974             =over 4
2975              
2976             =item tryload example 2
2977              
2978             package main;
2979              
2980             use Venus::Space;
2981              
2982             my $space = Venus::Space->new('n_a_p_c');
2983              
2984             my $tryload = $space->tryload;
2985              
2986             # 0
2987              
2988             =back
2989              
2990             =cut
2991              
2992             =head2 unload
2993              
2994             unload() (Self)
2995              
2996             The unload method unloads a package space by nullifying its symbol table and
2997             removing it from C<%INC>.
2998              
2999             I>
3000              
3001             =over 4
3002              
3003             =item unload example 1
3004              
3005             package main;
3006              
3007             use Venus::Space;
3008              
3009             # Bar::Gen is generated with $VERSION as 0.01
3010              
3011             my $space = Venus::Space->new('Bar/Gen');
3012              
3013             $space->load;
3014              
3015             my $unload = $space->unload;
3016              
3017             # bless({ value => "Bar::Gen" }, "Venus::Space")
3018              
3019             # Bar::Gen->VERSION was 0.01, now undef
3020              
3021             # Symbol table remains, $space->visible is 1
3022              
3023             =back
3024              
3025             =cut
3026              
3027             =head2 use
3028              
3029             use(Str | Tuple[Str, Str] $target, Any @params) (Space)
3030              
3031             The use method executes a C statement within the package namespace
3032             specified.
3033              
3034             I>
3035              
3036             =over 4
3037              
3038             =item use example 1
3039              
3040             package main;
3041              
3042             use Venus::Space;
3043              
3044             my $space = Venus::Space->new('foo/goo');
3045              
3046             my $use = $space->use('Venus');
3047              
3048             # bless({ value => "foo/goo" }, "Venus::Space")
3049              
3050             =back
3051              
3052             =over 4
3053              
3054             =item use example 2
3055              
3056             package main;
3057              
3058             use Venus::Space;
3059              
3060             my $space = Venus::Space->new('foo/hoo');
3061              
3062             my $use = $space->use('Venus', 'error');
3063              
3064             # bless({ value => "foo/hoo" }, "Venus::Space")
3065              
3066             =back
3067              
3068             =over 4
3069              
3070             =item use example 3
3071              
3072             package main;
3073              
3074             use Venus::Space;
3075              
3076             my $space = Venus::Space->new('foo/foo');
3077              
3078             my $use = $space->use(['Venus', 9.99], 'error');
3079              
3080             =back
3081              
3082             =cut
3083              
3084             =head2 variables
3085              
3086             variables() (ArrayRef[Tuple[Str, ArrayRef]])
3087              
3088             The variables method searches the package namespace for variables and returns
3089             their names.
3090              
3091             I>
3092              
3093             =over 4
3094              
3095             =item variables example 1
3096              
3097             package Etc;
3098              
3099             our $init = 0;
3100             our $func = 1;
3101              
3102             our @does = (1..4);
3103             our %sets = (1..4);
3104              
3105             package main;
3106              
3107             use Venus::Space;
3108              
3109             my $space = Venus::Space->new('etc');
3110              
3111             my $variables = $space->variables;
3112              
3113             # [
3114             # ["arrays", ["does"]],
3115             # ["hashes", ["sets"]],
3116             # ["scalars", ["func", "init"]],
3117             # ]
3118              
3119             =back
3120              
3121             =cut
3122              
3123             =head2 version
3124              
3125             version() (Maybe[Str])
3126              
3127             The version method returns the C declared on the target package, if
3128             any.
3129              
3130             I>
3131              
3132             =over 4
3133              
3134             =item version example 1
3135              
3136             package Foo::Boo;
3137              
3138             sub import;
3139              
3140             package main;
3141              
3142             use Venus::Space;
3143              
3144             my $space = Venus::Space->new('foo/boo');
3145              
3146             my $version = $space->version;
3147              
3148             # undef
3149              
3150             =back
3151              
3152             =over 4
3153              
3154             =item version example 2
3155              
3156             package Foo::Boo;
3157              
3158             our $VERSION = 0.01;
3159              
3160             package main;
3161              
3162             use Venus::Space;
3163              
3164             my $space = Venus::Space->new('foo/boo');
3165              
3166             my $version = $space->version;
3167              
3168             # 0.01
3169              
3170             =back
3171              
3172             =cut
3173              
3174             =head2 visible
3175              
3176             visible() (Bool)
3177              
3178             The visible method returns truthy is the package namespace is visible, i.e. has
3179             symbols defined.
3180              
3181             I>
3182              
3183             =over 4
3184              
3185             =item visible example 1
3186              
3187             # given: synopsis
3188              
3189             package main;
3190              
3191             my $visible = $space->visible;
3192              
3193             # 1
3194              
3195             =back
3196              
3197             =over 4
3198              
3199             =item visible example 2
3200              
3201             package Foo::Fe;
3202              
3203             package main;
3204              
3205             use Venus::Space;
3206              
3207             my $space = Venus::Space->new('foo/fe');
3208              
3209             my $visible = $space->visible;
3210              
3211             # 0
3212              
3213             =back
3214              
3215             =over 4
3216              
3217             =item visible example 3
3218              
3219             package Foo::Fe;
3220              
3221             our $VERSION = 0.01;
3222              
3223             package main;
3224              
3225             use Venus::Space;
3226              
3227             my $space = Venus::Space->new('foo/fe');
3228              
3229             my $visible = $space->visible;
3230              
3231             # 1
3232              
3233             =back
3234              
3235             =over 4
3236              
3237             =item visible example 4
3238              
3239             package Foo::Fi;
3240              
3241             sub import;
3242              
3243             package main;
3244              
3245             use Venus::Space;
3246              
3247             my $space = Venus::Space->new('foo/fi');
3248              
3249             my $visible = $space->visible;
3250              
3251             # 1
3252              
3253             =back
3254              
3255             =cut
3256              
3257             =head1 ERRORS
3258              
3259             This package may raise the following errors:
3260              
3261             =cut
3262              
3263             =over 4
3264              
3265             =item error: C
3266              
3267             This package may raise an error_on_call_missing exception.
3268              
3269             B
3270              
3271             # given: synopsis;
3272              
3273             my @args = ("Example", "execute");
3274              
3275             my $error = $space->throw('error_on_call_missing', @args)->catch('error');
3276              
3277             # my $name = $error->name;
3278              
3279             # "on_call_missing"
3280              
3281             # my $message = $error->message;
3282              
3283             # "Unable to locate class method \"execute\" via package \"Example\""
3284              
3285             # my $package = $error->stash('package');
3286              
3287             # "Example"
3288              
3289             # my $routine = $error->stash('routine');
3290              
3291             # "execute"
3292              
3293             =back
3294              
3295             =over 4
3296              
3297             =item error: C
3298              
3299             This package may raise an error_on_call_undefined exception.
3300              
3301             B
3302              
3303             # given: synopsis;
3304              
3305             my @args = ("Example", "execute");
3306              
3307             my $error = $space->throw('error_on_call_undefined', @args)->catch('error');
3308              
3309             # my $name = $error->name;
3310              
3311             # "on_call_undefined"
3312              
3313             # my $message = $error->message;
3314              
3315             # "Attempt to call undefined class method in package \"Example\""
3316              
3317             # my $package = $error->stash('package');
3318              
3319             # "Example"
3320              
3321             # my $routine = $error->stash('routine');
3322              
3323             # "execute"
3324              
3325             =back
3326              
3327             =over 4
3328              
3329             =item error: C
3330              
3331             This package may raise an error_on_cop_missing exception.
3332              
3333             B
3334              
3335             # given: synopsis;
3336              
3337             my @args = ("Example", "execute");
3338              
3339             my $error = $space->throw('error_on_cop_missing', @args)->catch('error');
3340              
3341             # my $name = $error->name;
3342              
3343             # "on_cop_missing"
3344              
3345             # my $message = $error->message;
3346              
3347             # "Unable to locate object method \"execute\" via package \"Example\""
3348              
3349             # my $package = $error->stash('package');
3350              
3351             # "Example"
3352              
3353             # my $routine = $error->stash('routine');
3354              
3355             # "execute"
3356              
3357             =back
3358              
3359             =over 4
3360              
3361             =item error: C
3362              
3363             This package may raise an error_on_cop_undefined exception.
3364              
3365             B
3366              
3367             # given: synopsis;
3368              
3369             my @args = ("Example", "execute");
3370              
3371             my $error = $space->throw('error_on_cop_undefined', @args)->catch('error');
3372              
3373             # my $name = $error->name;
3374              
3375             # "on_cop_undefined"
3376              
3377             # my $message = $error->message;
3378              
3379             # "Attempt to cop undefined object method from package \"$class\""
3380              
3381             # my $package = $error->stash('package');
3382              
3383             # "Example"
3384              
3385             # my $routine = $error->stash('routine');
3386              
3387             # "execute"
3388              
3389             =back
3390              
3391             =over 4
3392              
3393             =item error: C
3394              
3395             This package may raise an error_on_eval exception.
3396              
3397             B
3398              
3399             # given: synopsis;
3400              
3401             my @args = ("Example", "Exception!");
3402              
3403             my $error = $space->throw('error_on_eval', @args)->catch('error');
3404              
3405             # my $name = $error->name;
3406              
3407             # "on_eval"
3408              
3409             # my $message = $error->message;
3410              
3411             # "Exception!"
3412              
3413             # my $package = $error->stash('package');
3414              
3415             # "Example"
3416              
3417             =back
3418              
3419             =over 4
3420              
3421             =item error: C
3422              
3423             This package may raise an error_on_load exception.
3424              
3425             B
3426              
3427             # given: synopsis;
3428              
3429             my @args = ("Example", "cause unknown");
3430              
3431             my $error = $space->throw('error_on_load', @args)->catch('error');
3432              
3433             # my $name = $error->name;
3434              
3435             # "on_load"
3436              
3437             # my $message = $error->message;
3438              
3439             # "Error attempting to load Example: \"cause unknown\""
3440              
3441             # my $package = $error->stash('package');
3442              
3443             # "Example"
3444              
3445             =back
3446              
3447             =over 4
3448              
3449             =item error: C
3450              
3451             This package may raise an error_on_swap exception.
3452              
3453             B
3454              
3455             # given: synopsis;
3456              
3457             my @args = ("Example", "execute");
3458              
3459             my $error = $space->throw('error_on_swap', @args)->catch('error');
3460              
3461             # my $name = $error->name;
3462              
3463             # "on_swap"
3464              
3465             # my $message = $error->message;
3466              
3467             # "Attempt to swap undefined subroutine in package \"$class\""
3468              
3469             # my $package = $error->stash('package');
3470              
3471             # "Example"
3472              
3473             # my $routine = $error->stash('routine');
3474              
3475             # "execute"
3476              
3477             =back
3478              
3479             =head1 AUTHORS
3480              
3481             Awncorp, C
3482              
3483             =cut
3484              
3485             =head1 LICENSE
3486              
3487             Copyright (C) 2000, Al Newkirk.
3488              
3489             This program is free software, you can redistribute it and/or modify it under
3490             the terms of the Apache license version 2.0.
3491              
3492             =cut