File Coverage

blib/lib/Data/Object/Space.pm
Criterion Covered Total %
statement 403 427 94.3
branch 53 74 71.6
condition 11 24 45.8
subroutine 72 76 94.7
pod 46 47 97.8
total 585 648 90.2


line stmt bran cond sub pod time code
1             package Data::Object::Space;
2              
3 1     1   120687 use 5.014;
  1         6  
4              
5 1     1   9 use strict;
  1         2  
  1         26  
6 1     1   5 use warnings;
  1         3  
  1         39  
7 1     1   7 use routines;
  1         2  
  1         8  
8              
9 1     1   2253 use parent 'Data::Object::Name';
  1         342  
  1         6  
10              
11             our $VERSION = '2.08'; # VERSION
12              
13             # METHODS
14              
15             my %has;
16              
17 1     1 1 193545 method all($name, @args) {
  1         5  
  1         2  
18 1         4 my $result = [];
19              
20 1         7 my $class = $self->class;
21 1         11 for my $package ($self->package, @{$self->inherits}) {
  1         77  
22 2         55 push @$result, [$package, $class->new($package)->$name(@args)];
23             }
24              
25 1         40 return $result;
26             }
27              
28 4     4 1 29806 method append(@args) {
  4         14  
  4         9  
29 4         17 my $class = $self->class;
30              
31 4         23 my $path = join '/',
32             $self->path, map $class->new($_)->path, @args;
33              
34 4         450 return $class->new($path);
35             }
36              
37 4     4 1 6556 method array($name) {
  4         10  
  4         8  
38 1     1   4067 no strict 'refs';
  1         2  
  1         61  
39              
40 4         14 my $class = $self->package;
41              
42 4         169 return [@{"${class}::${name}"}];
  4         50  
43             }
44              
45 2     2 1 6503 method arrays() {
  2         7  
46 1     1   79 no strict 'refs';
  1         4  
  1         135  
47              
48 2         9 my $class = $self->package;
49              
50             my $arrays = [
51 6         28 sort grep !!@{"${class}::$_"},
52 2         83 grep /^[_a-zA-Z]\w*$/, keys %{"${class}::"}
  2         22  
53             ];
54              
55 2         17 return $arrays;
56             }
57              
58 2     2 1 14434 method authority() {
  2         4  
59              
60 2         10 return $self->scalar('AUTHORITY');
61             }
62              
63 2     2 1 7713 method base() {
  2         7  
64              
65 2         13 return $self->parse->[-1];
66             }
67              
68 3 100   3 1 31315 method bless($data = {}) {
  3         22  
  3         7  
69 3         14 my $class = $self->load;
70              
71 3         27 return CORE::bless $data, $class;
72             }
73              
74 2     2 1 13367 method build(@args) {
  2         9  
  2         3  
75 2         8 my $class = $self->load;
76              
77 2         9 return $self->call('new', $class, @args);
78             }
79              
80 4     4 1 13769 method call($func, @args) {
  4         10  
  4         7  
81 4         12 my $class = $self->load;
82              
83 4 50       10 unless ($func) {
84 0         0 require Carp;
85              
86 0         0 my $text = qq[Attempt to call undefined class method in package "$class"];
87              
88 0         0 Carp::confess $text;
89             }
90              
91 4         17 my $next = $class->can($func);
92              
93 4 100       12 unless ($next) {
94 1 50       7 if ($class->can('AUTOLOAD')) {
95 1     1   514 $next = sub { no strict 'refs'; &{"${class}::${func}"}(@args) };
  1     1   17  
  1         149  
  1         6  
  1         4  
  1         27  
96             }
97             }
98              
99 4 50       11 unless ($next) {
100 0         0 require Carp;
101              
102 0         0 my $text = qq[Unable to locate class method "$func" via package "$class"];
103              
104 0         0 Carp::confess $text;
105             }
106              
107 4         10 @_ = @args; goto $next;
  4         70  
108             }
109              
110 1     1 1 6290 method child(@args) {
  1         4  
  1         2  
111              
112 1         4 return $self->append(@args);
113             }
114              
115 1     1 1 6608 method children() {
  1         2  
116 1         5 my %list;
117             my $path;
118 1         0 my $type;
119              
120 1         5 $path = quotemeta $self->path;
121 1         60 $type = 'pm';
122              
123 1         44 my $regexp = qr/$path\/[^\/]+\.$type/;
124              
125 1         75 for my $item (keys %INC) {
126 149 50       375 $list{$item}++ if $item =~ /$regexp$/;
127             }
128              
129 1         7 my %seen;
130              
131 1         4 for my $dir (@INC) {
132 11 100       584 next if $seen{$dir}++;
133              
134 9         22 my $re = quotemeta $dir;
135 27         802 map { s/^$re\///; $list{$_}++ }
  27         98  
136 9         21 grep !$list{$_}, glob "$dir/@{[$self->path]}/*.$type";
  9         29  
137             }
138              
139 1         89 my $class = $self->class;
140              
141             return [
142             map $class->new($_),
143 1         23 map {s/(.*)\.$type$/$1/r}
  27         155  
144             sort keys %list
145             ];
146             }
147              
148 14     14 0 31 method class() {
  14         31  
149              
150 14         41 return ref $self;
151             }
152              
153 1     1 1 4 method cop($func, @args) {
  1         5  
  1         2  
154 1         4 my $class = $self->load;
155              
156 1 50       5 unless ($func) {
157 0         0 require Carp;
158              
159 0         0 my $text = qq[Attempt to cop undefined object method from package "$class"];
160              
161 0         0 Carp::confess $text;
162             }
163              
164 1         8 my $next = $class->can($func);
165              
166 1 50       7 unless ($next) {
167 0         0 require Carp;
168              
169 0         0 my $text = qq[Unable to locate object method "$func" via package "$class"];
170              
171 0         0 Carp::confess $text;
172             }
173              
174 1 50   1   14 return sub { $next->(@args ? (@args, @_) : @_) };
  1         801  
175             }
176              
177 1     1 1 8303 method data() {
  1         3  
178 1     1   883 no strict 'refs';
  1         5  
  1         170  
179              
180 1         5 my $class = $self->package;
181              
182 1         37 local $.;
183              
184 1         2 my $handle = \*{"${class}::DATA"};
  1         9  
185              
186 1 50       15 return '' if !fileno $handle;
187              
188 0         0 seek $handle, 0, 0;
189              
190 0         0 my $data = join '', <$handle>;
191              
192 0         0 $data =~ s/^.*\n__DATA__\r?\n/\n/s;
193 0         0 $data =~ s/\n__END__\r?\n.*$/\n/s;
194              
195 0         0 return $data;
196             }
197              
198 1     1 1 10 method destroy() {
  1         1  
199 1         549 require Symbol;
200              
201 1         850 Symbol::delete_package($self->package);
202              
203 1         560 my $c_re = quotemeta $self->package;
204 1         51 my $p_re = quotemeta $self->path;
205              
206 1         74 map {delete $has{$_}} grep /^$c_re/, keys %has;
  1         5  
207 1         204 map {delete $INC{$_}} grep /^$p_re/, keys %INC;
  1         6  
208              
209 1         18 return $self;
210             }
211              
212 8     8 1 5654 method eval(@args) {
  8         28  
  8         15  
213 8         14 local $@;
214              
215 1     1   128 my $result = eval join ' ', map "$_", "package @{[$self->package]};", @args;
  1     1   4  
  1     1   104  
  1         131  
  1         3  
  1         62  
  1         118  
  1         4  
  1         94  
  8         18  
  8         28  
216              
217 8 100       215 Carp::confess $@ if $@;
218              
219 7         85 return $result;
220             }
221              
222 1     1 1 8951 method functions() {
  1         2  
223 1         3 my @functions;
224              
225 1     1   450 no strict 'refs';
  1         3  
  1         171  
226              
227 1         570 require Function::Parameters::Info;
228              
229 1         2181 my $class = $self->package;
230 1         54 for my $routine (@{$self->routines}) {
  1         6  
231 1 50       20 my $code = $class->can($routine) or next;
232 1         6 my $data = Function::Parameters::info($code);
233              
234 1 50 33     1339 push @functions, $routine if $data && !$data->invocant;
235             }
236              
237 1         48 return [sort @functions];
238             }
239              
240 1     1 1 7149 method hash($name) {
  1         5  
  1         1  
241 1     1   85 no strict 'refs';
  1         3  
  1         59  
242              
243 1         5 my $class = $self->package;
244              
245 1         47 return {%{"${class}::${name}"}};
  1         16  
246             }
247              
248 2     2 1 6514 method hashes() {
  2         4  
249 1     1   75 no strict 'refs';
  1         2  
  1         130  
250              
251 2         10 my $class = $self->package;
252              
253             return [
254 13         57 sort grep !!%{"${class}::$_"},
255 2         74 grep /^[_a-zA-Z]\w*$/, keys %{"${class}::"}
  2         32  
256             ];
257             }
258              
259 3     3 1 6480 method id() {
  3         5  
260              
261 3         16 return $self->label;
262             }
263              
264 1     1 1 6537 method init() {
  1         3  
265 1         4 my $class = $self->package;
266              
267 1 50       50 if ($self->routine('import')) {
268              
269 0         0 return $class;
270             }
271              
272 1 50       6 $class = $self->locate ? $self->load : $self->package;
273              
274 1 50       35 if ($self->routine('import')) {
275              
276 0         0 return $class;
277             }
278             else {
279              
280 1     0   5 my $import = sub { $class };
  0     0   0  
281              
282 1         7 $self->inject('import', $import);
283 1         9 $self->load;
284              
285 1         11 return $class;
286             }
287             }
288              
289 3     3 1 13580 method inherits() {
  3         7  
290              
291 3         15 return $self->array('ISA');
292             }
293              
294 2     2 1 6531 method included() {
  2         4  
295              
296 2         29 return $INC{$self->format('path', '%s.pm')};
297             }
298              
299 2     2 1 6545 method inject($name, $coderef) {
  2         7  
  2         4  
300 2         6 my $class = $self->package;
301              
302 2         60 local $@;
303 1     1   489 no strict 'refs';
  1         13  
  1         36  
304 1     1   5 no warnings 'redefine';
  1         3  
  1         186  
305              
306 2 50       77 if (state $subutil = eval "require Sub::Util") {
307 2         23 return *{"${class}::${name}"} = Sub::Util::set_subname(
308 0     0   0 "${class}::${name}", $coderef || sub{$class}
309 2   50     22 );
310             }
311             else {
312 0   0 0   0 return *{"${class}::${name}"} = $coderef || sub{$class};
  0         0  
  0         0  
313             }
314             }
315              
316 17     17 1 26087 method load() {
  17         33  
317 17         47 my $class = $self->package;
318              
319 17 100       795 return $class if $has{$class};
320              
321 10   33     122 my $failed = !$class || $class !~ /^\w(?:[\w:']*\w)?$/;
322 10         21 my $loaded;
323              
324 10 50       77 my $error = do {
325 10         20 local $@;
326 1     1   199 no strict 'refs';
  1         3  
  1         143  
327 10         164 $loaded = !!$class->can('new');
328 10 100       73 $loaded = !!$class->can('import') if !$loaded;
329 10 100       53 $loaded = !!$class->can('meta') if !$loaded;
330 10 100       64 $loaded = !!$class->can('with') if !$loaded;
331 10 100       316 $loaded = eval "require $class; 1" if !$loaded;
332 10         78 $@;
333             }
334             if !$failed;
335              
336 10 50 66     110 do {
      66        
337 1         5 require Carp;
338              
339 1   50     5 my $message = $error || "cause unknown";
340              
341 1         402 Carp::confess "Error attempting to load $class: $message";
342             }
343             if $error
344             or $failed
345             or not $loaded;
346              
347 9         39 $has{$class} = 1;
348              
349 9         182 return $class;
350             }
351              
352 3     3 1 11317 method loaded() {
  3         7  
353 3         24 my $class = $self->package;
354 3         245 my $pexpr = $self->format('path', '%s.pm');
355              
356 3         229 my $is_loaded_eval = $has{$class};
357 3         11 my $is_loaded_used = $INC{$pexpr};
358              
359 3 100 66     48 return ($is_loaded_eval || $is_loaded_used) ? 1 : 0;
360             }
361              
362 3     3 1 12388 method locate() {
  3         6  
363 3         9 my $found = '';
364              
365 3         11 my $file = $self->format('path', '%s.pm');
366              
367 3         224 for my $path (@INC) {
368 31 100       613 do { $found = "$path/$file"; last } if -f "$path/$file";
  1         9  
  1         4  
369             }
370              
371 3         37 return $found;
372             }
373              
374 1     1 1 8716 method methods() {
  1         2  
375 1         3 my @methods;
376              
377 1     1   369 no strict 'refs';
  1         25  
  1         142  
378              
379 1         8 require Function::Parameters::Info;
380              
381 1         14 my $class = $self->package;
382 1         49 for my $routine (@{$self->routines}) {
  1         17  
383 1 50       20 my $code = $class->can($routine) or next;
384 1         10 my $data = Function::Parameters::info($code);
385              
386 1 50 33     226 push @methods, $routine if $data && $data->invocant;
387             }
388              
389 1         114 return [sort @methods];
390             }
391              
392 1     1 1 6895 method name() {
  1         11  
393              
394 1         6 return $self->package;
395             }
396              
397 3     3 1 6703 method parent() {
  3         15  
398 3         40 my @parts = @{$self->parse};
  3         21  
399              
400 3 50       267 pop @parts if @parts > 1;
401              
402 3         28 my $class = $self->class;
403              
404 3         29 return $class->new(join '/', @parts);
405             }
406              
407 14     14 1 32617 method parse() {
  14         32  
408              
409             return [
410 14         46 map ucfirst,
411             map join('', map(ucfirst, split /[-_]/)),
412             split /[^-_a-zA-Z0-9.]+/,
413             $self->path
414             ];
415             }
416              
417 3     3 1 19675 method parts() {
  3         15  
418              
419 3         10 return $self->parse;
420             }
421              
422 3     3 1 13314 method prepend(@args) {
  3         11  
  3         7  
423 3         11 my $class = $self->class;
424              
425 3         17 my $path = join '/',
426             (map $class->new($_)->path, @args), $self->path;
427              
428 3         328 return $class->new($path);
429             }
430              
431 1     1 1 6994 method rebase(@args) {
  1         5  
  1         3  
432 1         13 my $class = $self->class;
433              
434 1         7 my $path = join '/', map $class->new($_)->path, @args;
435              
436 1         71 return $class->new($self->base)->prepend($path);
437             }
438              
439 4     4 1 6629 method require($target) {
  4         11  
  4         7  
440 4 50       85 $target = "'$target'" if -f $target;
441              
442 4         39 return $self->eval("require $target");
443             }
444              
445 1     1 1 6547 method root() {
  1         10  
446              
447 1         7 return $self->parse->[0];
448             }
449              
450 3     3 1 6786 method routine($name) {
  3         15  
  3         11  
451 1     1   922 no strict 'refs';
  1         2  
  1         91  
452              
453 3         12 my $class = $self->package;
454              
455 3         97 return *{"${class}::${name}"}{"CODE"};
  3         34  
456             }
457              
458 3     3 1 6572 method routines() {
  3         7  
459 1     1   76 no strict 'refs';
  1         2  
  1         130  
460              
461 3         15 my $class = $self->package;
462              
463             return [
464 8         54 sort grep *{"${class}::$_"}{"CODE"},
465 3         128 grep /^[_a-zA-Z]\w*$/, keys %{"${class}::"}
  3         34  
466             ];
467             }
468              
469 5     5 1 6715 method scalar($name) {
  5         15  
  5         7  
470 1     1   79 no strict 'refs';
  1         2  
  1         68  
471              
472 5         22 my $class = $self->package;
473              
474 5         246 return ${"${class}::${name}"};
  5         77  
475             }
476              
477 2     2 1 5999 method scalars() {
  2         6  
478 1     1   74 no strict 'refs';
  1         3  
  1         126  
479              
480 2         9 my $class = $self->package;
481              
482             return [
483 16         88 sort grep defined ${"${class}::$_"},
484 2         74 grep /^[_a-zA-Z]\w*$/, keys %{"${class}::"}
  2         38  
485             ];
486             }
487              
488 1     1 1 6712 method sibling(@args) {
  1         5  
  1         4  
489              
490 1         6 return $self->parent->append(@args);
491             }
492              
493 1     1 1 6605 method siblings() {
  1         11  
494 1         7 my %list;
495             my $path;
496 1         0 my $type;
497              
498 1         4 $path = quotemeta $self->parent->path;
499 1         32 $type = 'pm';
500              
501 1         47 my $regexp = qr/$path\/[^\/]+\.$type/;
502              
503 1         656 for my $item (keys %INC) {
504 217 100       587 $list{$item}++ if $item =~ /$regexp$/;
505             }
506              
507 1         12 my %seen;
508              
509 1         5 for my $dir (@INC) {
510 11 100       688 next if $seen{$dir}++;
511              
512 9         25 my $re = quotemeta $dir;
513 2         237 map { s/^$re\///; $list{$_}++ }
  2         19  
514 9         29 grep !$list{$_}, glob "$dir/@{[$self->path]}/*.$type";
  9         28  
515             }
516              
517 1         80 my $class = $self->class;
518              
519             return [
520             map $class->new($_),
521 1         8 map {s/(.*)\.$type$/$1/r}
  5         56  
522             sort keys %list
523             ];
524             }
525              
526 2     2 1 16805 method tryload() {
  2         6  
527              
528 2         3 return do { local $@; eval { $self->load }; int!$@ };
  2         5  
  2         67  
  2         11  
  2         808  
529             }
530              
531 3     3 1 23369 method use($target, @params) {
  3         9  
  3         6  
532 3         5 my $version;
533              
534 3         10 my $class = $self->package;
535              
536 3 100       157 ($target, $version) = @$target if ref $target eq 'ARRAY';
537              
538 3         13 $self->require($target);
539              
540 3         13 require Scalar::Util;
541              
542 3 100       41 my @statement = (
543             'no strict "subs";',
544             (
545             Scalar::Util::looks_like_number($version)
546             ? "${target}->VERSION($version);" : ()
547             ),
548             'sub{ my ($target, @params) = @_; $target->import(@params)}'
549             );
550              
551 3         16 $self->eval(join("\n", @statement))->($target, $class, @params);
552              
553 2         1012 return $self;
554             }
555              
556 4     4 1 17712 method used() {
  4         12  
557 4         57 my $class = $self->package;
558 4         195 my $path = $self->path;
559 4         204 my $regexp = quotemeta $path;
560              
561 4 100       39 return $path if $has{$class};
562              
563 2         131 for my $item (keys %INC) {
564 370 50       917 return $path if $item =~ /$regexp\.pm$/;
565             }
566              
567 2         33 return '';
568             }
569              
570 1     1 1 6751 method variables() {
  1         3  
571              
572 1         4 return [map [$_, [sort @{$self->$_}]], qw(arrays hashes scalars)];
  3         24  
573             }
574              
575 2     2 1 32465 method version() {
  2         5  
576              
577 2         7 return $self->scalar('VERSION');
578             }
579              
580             1;
581              
582             =encoding utf8
583              
584             =head1 NAME
585              
586             Data::Object::Space - Namespace Class
587              
588             =cut
589              
590             =head1 ABSTRACT
591              
592             Namespace Class for Perl 5
593              
594             =cut
595              
596             =head1 SYNOPSIS
597              
598             package main;
599              
600             use Data::Object::Space;
601              
602             my $space = Data::Object::Space->new('foo/bar');
603              
604             =cut
605              
606             =head1 DESCRIPTION
607              
608             This package provides methods for parsing and manipulating package namespaces.
609              
610             =cut
611              
612             =head1 INHERITS
613              
614             This package inherits behaviors from:
615              
616             L<Data::Object::Name>
617              
618             =cut
619              
620             =head1 LIBRARIES
621              
622             This package uses type constraints from:
623              
624             L<Types::Standard>
625              
626             =cut
627              
628             =head1 METHODS
629              
630             This package implements the following methods:
631              
632             =cut
633              
634             =head2 all
635              
636             all(Str $name, Any @args) : ArrayRef[Tuple[Str, Any]]
637              
638             The all method executes any available method on the instance and all instances
639             representing packages inherited by the package represented by the invocant.
640              
641             =over 4
642              
643             =item all example #1
644              
645             package main;
646              
647             use Data::Object::Space;
648              
649             my $space = Data::Object::Space->new('data/object/space');
650              
651             $space->all('id');
652              
653             # [
654             # ['Data::Object::Space', 'Data_Object_Space'],
655             # ['Data::Object::Name', 'Data_Object_Name'],
656             # ]
657              
658             =back
659              
660             =cut
661              
662             =head2 append
663              
664             append(Str @args) : Object
665              
666             The append method modifies the object by appending to the package namespace
667             parts.
668              
669             =over 4
670              
671             =item append example #1
672              
673             # given: synopsis
674              
675             $space->append('baz');
676              
677             # 'Foo/Bar/Baz'
678              
679             =back
680              
681             =over 4
682              
683             =item append example #2
684              
685             # given: synopsis
686              
687             $space->append('baz', 'bax');
688              
689             # $space->package;
690              
691             # 'Foo/Bar/Baz/Bax'
692              
693             =back
694              
695             =cut
696              
697             =head2 array
698              
699             array(Str $arg1) : ArrayRef
700              
701             The array method returns the value for the given package array variable name.
702              
703             =over 4
704              
705             =item array example #1
706              
707             # given: synopsis
708              
709             package Foo::Bar;
710              
711             our @handler = 'start';
712              
713             package main;
714              
715             $space->array('handler')
716              
717             # ['start']
718              
719             =back
720              
721             =cut
722              
723             =head2 arrays
724              
725             arrays() : ArrayRef
726              
727             The arrays method searches the package namespace for arrays and returns their
728             names.
729              
730             =over 4
731              
732             =item arrays example #1
733              
734             # given: synopsis
735              
736             package Foo::Bar;
737              
738             our @handler = 'start';
739             our @initial = ('next', 'prev');
740              
741             package main;
742              
743             $space->arrays
744              
745             # ['handler', 'initial']
746              
747             =back
748              
749             =cut
750              
751             =head2 authority
752              
753             authority() : Maybe[Str]
754              
755             The authority method returns the C<AUTHORITY> declared on the target package,
756             if any.
757              
758             =over 4
759              
760             =item authority example #1
761              
762             package Foo::Boo;
763              
764             package main;
765              
766             use Data::Object::Space;
767              
768             my $space = Data::Object::Space->new('foo/boo');
769              
770             $space->authority
771              
772             # undef
773              
774             =back
775              
776             =over 4
777              
778             =item authority example #2
779              
780             package Foo::Boo;
781              
782             our $AUTHORITY = 'cpan:AWNCORP';
783              
784             package main;
785              
786             use Data::Object::Space;
787              
788             my $space = Data::Object::Space->new('foo/boo');
789              
790             $space->authority
791              
792             # 'cpan:AWNCORP'
793              
794             =back
795              
796             =cut
797              
798             =head2 base
799              
800             base() : Str
801              
802             The base method returns the last segment of the package namespace parts.
803              
804             =over 4
805              
806             =item base example #1
807              
808             # given: synopsis
809              
810             $space->base
811              
812             # Bar
813              
814             =back
815              
816             =cut
817              
818             =head2 bless
819              
820             bless(Any $arg1 = {}) : Object
821              
822             The bless method blesses the given value into the package namespace and returns
823             an object. If no value is given, an empty hashref is used.
824              
825             =over 4
826              
827             =item bless example #1
828              
829             # given: synopsis
830              
831             package Foo::Bar;
832              
833             sub import;
834              
835             package main;
836              
837             $space->bless
838              
839             # bless({}, 'Foo::Bar')
840              
841             =back
842              
843             =over 4
844              
845             =item bless example #2
846              
847             # given: synopsis
848              
849             package Foo::Bar;
850              
851             sub import;
852              
853             package main;
854              
855             $space->bless({okay => 1})
856              
857             # bless({okay => 1}, 'Foo::Bar')
858              
859             =back
860              
861             =cut
862              
863             =head2 build
864              
865             build(Any @args) : Object
866              
867             The build method attempts to call C<new> on the package namespace and if successful returns the resulting object.
868              
869             =over 4
870              
871             =item build example #1
872              
873             package Foo::Bar::Baz;
874              
875             sub new {
876             bless {}, $_[0]
877             }
878              
879             package main;
880              
881             use Data::Object::Space;
882              
883             my $space = Data::Object::Space->new('foo/bar/baz');
884              
885             $space->build
886              
887             # bless({}, 'Foo::Bar::Baz')
888              
889             =back
890              
891             =over 4
892              
893             =item build example #2
894              
895             package Foo::Bar::Bax;
896              
897             sub new {
898             bless $_[1], $_[0]
899             }
900              
901             package main;
902              
903             use Data::Object::Space;
904              
905             my $space = Data::Object::Space->new('foo/bar/bax');
906              
907             $space->build({okay => 1})
908              
909             # bless({okay => 1}, 'Foo::Bar::Bax')
910              
911             =back
912              
913             =cut
914              
915             =head2 call
916              
917             call(Any @args) : Any
918              
919             The call method attempts to call the given subroutine on the package namespace
920             and if successful returns the resulting value.
921              
922             =over 4
923              
924             =item call example #1
925              
926             # given: synopsis
927              
928             package Foo;
929              
930             sub import;
931              
932             sub start {
933             'started'
934             }
935              
936             package main;
937              
938             use Data::Object::Space;
939              
940             $space = Data::Object::Space->new('foo');
941              
942             $space->call('start')
943              
944             # started
945              
946             =back
947              
948             =over 4
949              
950             =item call example #2
951              
952             # given: synopsis
953              
954             package Zoo;
955              
956             sub import;
957              
958             sub AUTOLOAD {
959             bless {};
960             }
961              
962             sub DESTROY {
963             ; # noop
964             }
965              
966             package main;
967              
968             use Data::Object::Space;
969              
970             $space = Data::Object::Space->new('zoo');
971              
972             $space->call('start')
973              
974             # bless({}, 'Zoo')
975              
976             =back
977              
978             =cut
979              
980             =head2 child
981              
982             child(Str $arg1) : Object
983              
984             The child method returns a new L<Data::Object::Space> object for the child
985             package namespace.
986              
987             =over 4
988              
989             =item child example #1
990              
991             # given: synopsis
992              
993             $space->child('baz');
994              
995             # $space->package;
996              
997             # Foo::Bar::Baz
998              
999             =back
1000              
1001             =cut
1002              
1003             =head2 children
1004              
1005             children() : ArrayRef[Object]
1006              
1007             The children method searches C<%INC> and C<@INC> and retuns a list of
1008             L<Data::Object::Space> objects for each child namespace found (one level deep).
1009              
1010             =over 4
1011              
1012             =item children example #1
1013              
1014             package main;
1015              
1016             use Data::Object::Space;
1017              
1018             my $space = Data::Object::Space->new('c_p_a_n');
1019              
1020             $space->children
1021              
1022             # [
1023             # 'CPAN/Author',
1024             # 'CPAN/Bundle',
1025             # 'CPAN/CacheMgr',
1026             # ...
1027             # ]
1028              
1029             =back
1030              
1031             =cut
1032              
1033             =head2 cop
1034              
1035             cop(Any @args) : CodeRef
1036              
1037             The cop method attempts to curry the given subroutine on the package namespace
1038             and if successful returns a closure.
1039              
1040             =over 4
1041              
1042             =item cop example #1
1043              
1044             # given: synopsis
1045              
1046             package Foo::Bar;
1047              
1048             sub import;
1049              
1050             sub handler {
1051             [@_]
1052             }
1053              
1054             package main;
1055              
1056             use Data::Object::Space;
1057              
1058             $space = Data::Object::Space->new('foo/bar');
1059              
1060             $space->cop('handler', $space->bless)
1061              
1062             # sub { Foo::Bar::handler(..., @_) }
1063              
1064             =back
1065              
1066             =cut
1067              
1068             =head2 data
1069              
1070             data() : Str
1071              
1072             The data method attempts to read and return any content stored in the C<DATA>
1073             section of the package namespace.
1074              
1075             =over 4
1076              
1077             =item data example #1
1078              
1079             package main;
1080              
1081             use Data::Object::Space;
1082              
1083             my $space = Data::Object::Space->new('foo');
1084              
1085             $space->data; # ''
1086              
1087             =back
1088              
1089             =cut
1090              
1091             =head2 destroy
1092              
1093             destroy() : Object
1094              
1095             The destroy method attempts to wipe out a namespace and also remove it and its
1096             children from C<%INC>. B<NOTE:> This can cause catastrophic failures if used
1097             incorrectly.
1098              
1099             =over 4
1100              
1101             =item destroy example #1
1102              
1103             package main;
1104              
1105             use Data::Object::Space;
1106              
1107             my $space = Data::Object::Space->new('data/dumper');
1108              
1109             $space->load; # Data/Dumper
1110              
1111             $space->destroy;
1112              
1113             =back
1114              
1115             =cut
1116              
1117             =head2 eval
1118              
1119             eval(Str @args) : Any
1120              
1121             The eval method takes a list of strings and evaluates them under the namespace
1122             represented by the instance.
1123              
1124             =over 4
1125              
1126             =item eval example #1
1127              
1128             package main;
1129              
1130             use Data::Object::Space;
1131              
1132             my $space = Data::Object::Space->new('foo');
1133              
1134             $space->eval('our $VERSION = 0.01');
1135              
1136             =back
1137              
1138             =cut
1139              
1140             =head2 functions
1141              
1142             functions() : ArrayRef
1143              
1144             The functions method searches the package namespace for functions and returns
1145             their names.
1146              
1147             =over 4
1148              
1149             =item functions example #1
1150              
1151             package Foo::Functions;
1152              
1153             use routines;
1154              
1155             fun start() {
1156             1
1157             }
1158              
1159             package main;
1160              
1161             use Data::Object::Space;
1162              
1163             my $space = Data::Object::Space->new('foo/functions');
1164              
1165             $space->functions
1166              
1167             # ['start']
1168              
1169             =back
1170              
1171             =cut
1172              
1173             =head2 hash
1174              
1175             hash(Str $arg1) : HashRef
1176              
1177             The hash method returns the value for the given package hash variable name.
1178              
1179             =over 4
1180              
1181             =item hash example #1
1182              
1183             # given: synopsis
1184              
1185             package Foo::Bar;
1186              
1187             our %settings = (
1188             active => 1
1189             );
1190              
1191             package main;
1192              
1193             $space->hash('settings')
1194              
1195             # {active => 1}
1196              
1197             =back
1198              
1199             =cut
1200              
1201             =head2 hashes
1202              
1203             hashes() : ArrayRef
1204              
1205             The hashes method searches the package namespace for hashes and returns their
1206             names.
1207              
1208             =over 4
1209              
1210             =item hashes example #1
1211              
1212             # given: synopsis
1213              
1214             package Foo::Bar;
1215              
1216             our %defaults = (
1217             active => 0
1218             );
1219              
1220             our %settings = (
1221             active => 1
1222             );
1223              
1224             package main;
1225              
1226             $space->hashes
1227              
1228             # ['defaults', 'settings']
1229              
1230             =back
1231              
1232             =cut
1233              
1234             =head2 id
1235              
1236             id() : Str
1237              
1238             The id method returns the fully-qualified package name as a label.
1239              
1240             =over 4
1241              
1242             =item id example #1
1243              
1244             # given: synopsis
1245              
1246             $space->id
1247              
1248             # Foo_Bar
1249              
1250             =back
1251              
1252             =cut
1253              
1254             =head2 included
1255              
1256             included() : Str
1257              
1258             The included method returns the path of the namespace if it exists in C<%INC>.
1259              
1260             =over 4
1261              
1262             =item included example #1
1263              
1264             package main;
1265              
1266             my $space = Data::Object::Space->new('Data/Object/Space');
1267              
1268             $space->included;
1269              
1270             # lib/Data/Object/Space.pm
1271              
1272             =back
1273              
1274             =cut
1275              
1276             =head2 inherits
1277              
1278             inherits() : ArrayRef
1279              
1280             The inherits method returns the list of superclasses the target package is
1281             derived from.
1282              
1283             =over 4
1284              
1285             =item inherits example #1
1286              
1287             package Bar;
1288              
1289             package main;
1290              
1291             my $space = Data::Object::Space->new('bar');
1292              
1293             $space->inherits
1294              
1295             # []
1296              
1297             =back
1298              
1299             =over 4
1300              
1301             =item inherits example #2
1302              
1303             package Foo;
1304              
1305             package Bar;
1306              
1307             use base 'Foo';
1308              
1309             package main;
1310              
1311             my $space = Data::Object::Space->new('bar');
1312              
1313             $space->inherits
1314              
1315             # ['Foo']
1316              
1317             =back
1318              
1319             =cut
1320              
1321             =head2 init
1322              
1323             init() : Str
1324              
1325             The init method ensures that the package namespace is loaded and, whether
1326             created in-memory or on-disk, is flagged as being loaded and loadable.
1327              
1328             =over 4
1329              
1330             =item init example #1
1331              
1332             package main;
1333              
1334             use Data::Object::Space;
1335              
1336             my $space = Data::Object::Space->new('kit');
1337              
1338             $space->init
1339              
1340             # Kit
1341              
1342             =back
1343              
1344             =cut
1345              
1346             =head2 inject
1347              
1348             inject(Str $name, Maybe[CodeRef] $coderef) : Any
1349              
1350             The inject method monkey-patches the package namespace, installing a named
1351             subroutine into the package which can then be called normally, returning the
1352             fully-qualified subroutine name.
1353              
1354             =over 4
1355              
1356             =item inject example #1
1357              
1358             package main;
1359              
1360             use Data::Object::Space;
1361              
1362             my $space = Data::Object::Space->new('kit');
1363              
1364             $space->inject('build', sub { 'finished' });
1365              
1366             # *Kit::build
1367              
1368             =back
1369              
1370             =cut
1371              
1372             =head2 load
1373              
1374             load() : Str
1375              
1376             The load method checks whether the package namespace is already loaded and if
1377             not attempts to load the package. If the package is not loaded and is not
1378             loadable, this method will throw an exception using confess. If the package is
1379             loadable, this method returns truthy with the package name. As a workaround for
1380             packages that only exist in-memory, if the package contains a C<new>, C<with>,
1381             C<meta>, or C<import> routine it will be recognized as having been loaded.
1382              
1383             =over 4
1384              
1385             =item load example #1
1386              
1387             package main;
1388              
1389             use Data::Object::Space;
1390              
1391             my $space = Data::Object::Space->new('c_p_a_n');
1392              
1393             $space->load
1394              
1395             # CPAN
1396              
1397             =back
1398              
1399             =cut
1400              
1401             =head2 loaded
1402              
1403             loaded() : Int
1404              
1405             The loaded method checks whether the package namespace is already loaded
1406             returns truthy or falsy.
1407              
1408             =over 4
1409              
1410             =item loaded example #1
1411              
1412             package main;
1413              
1414             use Data::Object::Space;
1415              
1416             my $space = Data::Object::Space->new('data/dumper');
1417              
1418             $space->loaded;
1419              
1420             # 0
1421              
1422             =back
1423              
1424             =over 4
1425              
1426             =item loaded example #2
1427              
1428             package main;
1429              
1430             use Data::Object::Space;
1431              
1432             my $space = Data::Object::Space->new('data/dumper');
1433              
1434             $space->load;
1435              
1436             $space->loaded;
1437              
1438             # 1
1439              
1440             =back
1441              
1442             =cut
1443              
1444             =head2 locate
1445              
1446             locate() : Str
1447              
1448             The locate method checks whether the package namespace is available in
1449             C<@INC>, i.e. on disk. This method returns the file if found or an empty
1450             string.
1451              
1452             =over 4
1453              
1454             =item locate example #1
1455              
1456             package main;
1457              
1458             use Data::Object::Space;
1459              
1460             my $space = Data::Object::Space->new('brianne_spinka');
1461              
1462             $space->locate;
1463              
1464             # ''
1465              
1466             =back
1467              
1468             =over 4
1469              
1470             =item locate example #2
1471              
1472             package main;
1473              
1474             use Data::Object::Space;
1475              
1476             my $space = Data::Object::Space->new('data/dumper');
1477              
1478             $space->locate;
1479              
1480             # /path/to/Data/Dumper.pm
1481              
1482             =back
1483              
1484             =cut
1485              
1486             =head2 methods
1487              
1488             methods() : ArrayRef
1489              
1490             The methods method searches the package namespace for methods and returns their
1491             names.
1492              
1493             =over 4
1494              
1495             =item methods example #1
1496              
1497             package Foo::Methods;
1498              
1499             use routines;
1500              
1501             method start() {
1502             1
1503             }
1504              
1505             package main;
1506              
1507             use Data::Object::Space;
1508              
1509             my $space = Data::Object::Space->new('foo/methods');
1510              
1511             $space->methods
1512              
1513             # ['start']
1514              
1515             =back
1516              
1517             =cut
1518              
1519             =head2 name
1520              
1521             name() : Str
1522              
1523             The name method returns the fully-qualified package name.
1524              
1525             =over 4
1526              
1527             =item name example #1
1528              
1529             # given: synopsis
1530              
1531             $space->name
1532              
1533             # Foo::Bar
1534              
1535             =back
1536              
1537             =cut
1538              
1539             =head2 parent
1540              
1541             parent() : Object
1542              
1543             The parent method returns a new L<Data::Object::Space> object for the parent
1544             package namespace.
1545              
1546             =over 4
1547              
1548             =item parent example #1
1549              
1550             # given: synopsis
1551              
1552             $space->parent;
1553              
1554             # $space->package;
1555              
1556             # Foo
1557              
1558             =back
1559              
1560             =cut
1561              
1562             =head2 parse
1563              
1564             parse() : ArrayRef
1565              
1566             The parse method parses the string argument and returns an arrayref of package
1567             namespace segments (parts).
1568              
1569             =over 4
1570              
1571             =item parse example #1
1572              
1573             my $space = Data::Object::Space->new('Foo::Bar');
1574              
1575             $space->parse;
1576              
1577             # ['Foo', 'Bar']
1578              
1579             =back
1580              
1581             =over 4
1582              
1583             =item parse example #2
1584              
1585             my $space = Data::Object::Space->new('Foo/Bar');
1586              
1587             $space->parse;
1588              
1589             # ['Foo', 'Bar']
1590              
1591             =back
1592              
1593             =over 4
1594              
1595             =item parse example #3
1596              
1597             my $space = Data::Object::Space->new('Foo\Bar');
1598              
1599             $space->parse;
1600              
1601             # ['Foo', 'Bar']
1602              
1603             =back
1604              
1605             =over 4
1606              
1607             =item parse example #4
1608              
1609             my $space = Data::Object::Space->new('foo-bar');
1610              
1611             $space->parse;
1612              
1613             # ['FooBar']
1614              
1615             =back
1616              
1617             =over 4
1618              
1619             =item parse example #5
1620              
1621             my $space = Data::Object::Space->new('foo_bar');
1622              
1623             $space->parse;
1624              
1625             # ['FooBar']
1626              
1627             =back
1628              
1629             =cut
1630              
1631             =head2 parts
1632              
1633             parts() : ArrayRef
1634              
1635             The parts method returns an arrayref of package namespace segments (parts).
1636              
1637             =over 4
1638              
1639             =item parts example #1
1640              
1641             my $space = Data::Object::Space->new('foo');
1642              
1643             $space->parts;
1644              
1645             # ['Foo']
1646              
1647             =back
1648              
1649             =over 4
1650              
1651             =item parts example #2
1652              
1653             my $space = Data::Object::Space->new('foo/bar');
1654              
1655             $space->parts;
1656              
1657             # ['Foo', 'Bar']
1658              
1659             =back
1660              
1661             =over 4
1662              
1663             =item parts example #3
1664              
1665             my $space = Data::Object::Space->new('foo_bar');
1666              
1667             $space->parts;
1668              
1669             # ['FooBar']
1670              
1671             =back
1672              
1673             =cut
1674              
1675             =head2 prepend
1676              
1677             prepend(Str @args) : Object
1678              
1679             The prepend method modifies the object by prepending to the package namespace
1680             parts.
1681              
1682             =over 4
1683              
1684             =item prepend example #1
1685              
1686             # given: synopsis
1687              
1688             $space->prepend('etc');
1689              
1690             # 'Etc/Foo/Bar'
1691              
1692             =back
1693              
1694             =over 4
1695              
1696             =item prepend example #2
1697              
1698             # given: synopsis
1699              
1700             $space->prepend('etc', 'tmp');
1701              
1702             # 'Etc/Tmp/Foo/Bar'
1703              
1704             =back
1705              
1706             =cut
1707              
1708             =head2 rebase
1709              
1710             rebase(Str @args) : Object
1711              
1712             The rebase method returns an object by prepending the package namespace
1713             specified to the base of the current object's namespace.
1714              
1715             =over 4
1716              
1717             =item rebase example #1
1718              
1719             # given: synopsis
1720              
1721             $space->rebase('zoo');
1722              
1723             # Zoo/Bar
1724              
1725             =back
1726              
1727             =cut
1728              
1729             =head2 require
1730              
1731             require(Str $target) : Any
1732              
1733             The require method executes a C<require> statement within the package namespace
1734             specified.
1735              
1736             =over 4
1737              
1738             =item require example #1
1739              
1740             # given: synopsis
1741              
1742             $space->require('Moo');
1743              
1744             # 1
1745              
1746             =back
1747              
1748             =cut
1749              
1750             =head2 root
1751              
1752             root() : Str
1753              
1754             The root method returns the root package namespace segments (parts). Sometimes
1755             separating the C<root> from the C<parts> helps identify how subsequent child
1756             objects were derived.
1757              
1758             =over 4
1759              
1760             =item root example #1
1761              
1762             # given: synopsis
1763              
1764             $space->root
1765              
1766             # Foo
1767              
1768             =back
1769              
1770             =cut
1771              
1772             =head2 routine
1773              
1774             routine(Str $arg1) : CodeRef
1775              
1776             The routine method returns the subroutine reference for the given subroutine
1777             name.
1778              
1779             =over 4
1780              
1781             =item routine example #1
1782              
1783             package Foo;
1784              
1785             sub cont {
1786             [@_]
1787             }
1788              
1789             sub abort {
1790             [@_]
1791             }
1792              
1793             package main;
1794              
1795             use Data::Object::Space;
1796              
1797             my $space = Data::Object::Space->new('foo');
1798              
1799             $space->routine('cont')
1800              
1801             # sub { ... }
1802              
1803             =back
1804              
1805             =cut
1806              
1807             =head2 routines
1808              
1809             routines() : ArrayRef
1810              
1811             The routines method searches the package namespace for routines and returns
1812             their names.
1813              
1814             =over 4
1815              
1816             =item routines example #1
1817              
1818             package Foo::Routines;
1819              
1820             sub start {
1821             1
1822             }
1823              
1824             sub abort {
1825             1
1826             }
1827              
1828             package main;
1829              
1830             use Data::Object::Space;
1831              
1832             my $space = Data::Object::Space->new('foo/routines');
1833              
1834             $space->routines
1835              
1836             # ['start', 'abort']
1837              
1838             =back
1839              
1840             =cut
1841              
1842             =head2 scalar
1843              
1844             scalar(Str $arg1) : Any
1845              
1846             The scalar method returns the value for the given package scalar variable name.
1847              
1848             =over 4
1849              
1850             =item scalar example #1
1851              
1852             # given: synopsis
1853              
1854             package Foo::Bar;
1855              
1856             our $root = '/path/to/file';
1857              
1858             package main;
1859              
1860             $space->scalar('root')
1861              
1862             # /path/to/file
1863              
1864             =back
1865              
1866             =cut
1867              
1868             =head2 scalars
1869              
1870             scalars() : ArrayRef
1871              
1872             The scalars method searches the package namespace for scalars and returns their
1873             names.
1874              
1875             =over 4
1876              
1877             =item scalars example #1
1878              
1879             # given: synopsis
1880              
1881             package Foo::Bar;
1882              
1883             our $root = 'root';
1884             our $base = 'path/to';
1885             our $file = 'file';
1886              
1887             package main;
1888              
1889             $space->scalars
1890              
1891             # ['root', 'base', 'file']
1892              
1893             =back
1894              
1895             =cut
1896              
1897             =head2 sibling
1898              
1899             sibling(Str $arg1) : Object
1900              
1901             The sibling method returns a new L<Data::Object::Space> object for the sibling
1902             package namespace.
1903              
1904             =over 4
1905              
1906             =item sibling example #1
1907              
1908             # given: synopsis
1909              
1910             $space->sibling('baz')
1911              
1912             # Foo::Baz
1913              
1914             =back
1915              
1916             =cut
1917              
1918             =head2 siblings
1919              
1920             siblings() : ArrayRef[Object]
1921              
1922             The siblings method searches C<%INC> and C<@INC> and retuns a list of
1923             L<Data::Object::Space> objects for each sibling namespace found (one level
1924             deep).
1925              
1926             =over 4
1927              
1928             =item siblings example #1
1929              
1930             package main;
1931              
1932             use Data::Object::Space;
1933              
1934             my $space = Data::Object::Space->new('encode/m_i_m_e');
1935              
1936             $space->siblings
1937              
1938             # [
1939             # 'Encode/Alias',
1940             # 'Encode/Config'
1941             # ...
1942             # ]
1943              
1944             =back
1945              
1946             =cut
1947              
1948             =head2 tryload
1949              
1950             tryload() : Bool
1951              
1952             The tryload method attempt to C<load> the represented package using the
1953             L</load> method and returns truthy/falsy based on whether the package was
1954             loaded.
1955              
1956             =over 4
1957              
1958             =item tryload example #1
1959              
1960             package main;
1961              
1962             use Data::Object::Space;
1963              
1964             my $space = Data::Object::Space->new('c_p_a_n');
1965              
1966             $space->tryload
1967              
1968             # 1
1969              
1970             =back
1971              
1972             =over 4
1973              
1974             =item tryload example #2
1975              
1976             package main;
1977              
1978             use Data::Object::Space;
1979              
1980             my $space = Data::Object::Space->new('brianne_spinka');
1981              
1982             $space->tryload
1983              
1984             # 0
1985              
1986             =back
1987              
1988             =cut
1989              
1990             =head2 use
1991              
1992             use(Str | Tuple[Str, Str] $target, Any @params) : Object
1993              
1994             The use method executes a C<use> statement within the package namespace
1995             specified.
1996              
1997             =over 4
1998              
1999             =item use example #1
2000              
2001             package main;
2002              
2003             use Data::Object::Space;
2004              
2005             my $space = Data::Object::Space->new('foo/goo');
2006              
2007             $space->use('Moo');
2008              
2009             # $self
2010              
2011             =back
2012              
2013             =over 4
2014              
2015             =item use example #2
2016              
2017             package main;
2018              
2019             use Data::Object::Space;
2020              
2021             my $space = Data::Object::Space->new('foo/hoo');
2022              
2023             $space->use('Moo', 'has');
2024              
2025             # $self
2026              
2027             =back
2028              
2029             =over 4
2030              
2031             =item use example #3
2032              
2033             package main;
2034              
2035             use Data::Object::Space;
2036              
2037             my $space = Data::Object::Space->new('foo/ioo');
2038              
2039             $space->use(['Moo', 9.99], 'has');
2040              
2041             # $self
2042              
2043             =back
2044              
2045             =cut
2046              
2047             =head2 used
2048              
2049             used() : Str
2050              
2051             The used method searches C<%INC> for the package namespace and if found returns
2052             the filepath and complete filepath for the loaded package, otherwise returns
2053             falsy with an empty string.
2054              
2055             =over 4
2056              
2057             =item used example #1
2058              
2059             package main;
2060              
2061             use Data::Object::Space;
2062              
2063             my $space = Data::Object::Space->new('foo/xyz');
2064              
2065             $space->used
2066              
2067             # ''
2068              
2069             =back
2070              
2071             =over 4
2072              
2073             =item used example #2
2074              
2075             package main;
2076              
2077             use Data::Object::Space;
2078              
2079             my $space = Data::Object::Space->new('c_p_a_n');
2080              
2081             $space->load;
2082             $space->used
2083              
2084             # 'CPAN'
2085              
2086             =back
2087              
2088             =over 4
2089              
2090             =item used example #3
2091              
2092             package Foo::Bar;
2093              
2094             sub import;
2095              
2096             package main;
2097              
2098             use Data::Object::Space;
2099              
2100             my $space = Data::Object::Space->new('foo/bar');
2101              
2102             $space->used
2103              
2104             # 'Foo/Bar'
2105              
2106             =back
2107              
2108             =cut
2109              
2110             =head2 variables
2111              
2112             variables() : ArrayRef[Tuple[Str, ArrayRef]]
2113              
2114             The variables method searches the package namespace for variables and returns
2115             their names.
2116              
2117             =over 4
2118              
2119             =item variables example #1
2120              
2121             package Etc;
2122              
2123             our $init = 0;
2124             our $func = 1;
2125              
2126             our @does = (1..4);
2127             our %sets = (1..4);
2128              
2129             package main;
2130              
2131             use Data::Object::Space;
2132              
2133             my $space = Data::Object::Space->new('etc');
2134              
2135             $space->variables
2136              
2137             # [
2138             # ['arrays', ['does']],
2139             # ['hashes', ['sets']],
2140             # ['scalars', ['func', 'init']],
2141             # ]
2142              
2143             =back
2144              
2145             =cut
2146              
2147             =head2 version
2148              
2149             version() : Maybe[Str]
2150              
2151             The version method returns the C<VERSION> declared on the target package, if
2152             any.
2153              
2154             =over 4
2155              
2156             =item version example #1
2157              
2158             package Foo::Boo;
2159              
2160             package main;
2161              
2162             use Data::Object::Space;
2163              
2164             my $space = Data::Object::Space->new('foo/boo');
2165              
2166             $space->version
2167              
2168             # undef
2169              
2170             =back
2171              
2172             =over 4
2173              
2174             =item version example #2
2175              
2176             package Foo::Boo;
2177              
2178             our $VERSION = 0.01;
2179              
2180             package main;
2181              
2182             use Data::Object::Space;
2183              
2184             my $space = Data::Object::Space->new('foo/boo');
2185              
2186             $space->version
2187              
2188             # '0.01'
2189              
2190             =back
2191              
2192             =cut
2193              
2194             =head1 AUTHOR
2195              
2196             Al Newkirk, C<awncorp@cpan.org>
2197              
2198             =head1 LICENSE
2199              
2200             Copyright (C) 2011-2019, Al Newkirk, et al.
2201              
2202             This is free software; you can redistribute it and/or modify it under the terms
2203             of the The Apache License, Version 2.0, as elucidated in the L<"license
2204             file"|https://github.com/iamalnewkirk/data-object-space/blob/master/LICENSE>.
2205              
2206             =head1 PROJECT
2207              
2208             L<Wiki|https://github.com/iamalnewkirk/data-object-space/wiki>
2209              
2210             L<Project|https://github.com/iamalnewkirk/data-object-space>
2211              
2212             L<Initiatives|https://github.com/iamalnewkirk/data-object-space/projects>
2213              
2214             L<Milestones|https://github.com/iamalnewkirk/data-object-space/milestones>
2215              
2216             L<Contributing|https://github.com/iamalnewkirk/data-object-space/blob/master/CONTRIBUTE.md>
2217              
2218             L<Issues|https://github.com/iamalnewkirk/data-object-space/issues>
2219              
2220             =cut