| 1 | package Venus::Space; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 18 | ▶ | use 5.018; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 18 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 18 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 18 | ▶ | use Venus::Class 'base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 18 | base 'Venus::Name'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 18 | state $SERIAL = 0; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # BUILDERS | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | sub build_self { | ||||||||||||||||||||||||||||
| 17 | 578 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
build_self: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 578 | ▶ | $self->{value} = $self->package if !$self->lookslike_a_pragma; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 578 | return $self; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | # METHODS | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | sub all { | ||||||||||||||||||||||||||||
| 27 | 3 | ▶ | my ($self, $name, @args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
all: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 3 | my $result = []; | |||||||||||||||||||||||||||
| 30 | 3 | my $class = $self->class; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 3 | for my $package ($self->package, @{$self->inherits}) { | |||||||||||||||||||||||||||
| 33 | 7 | push @$result, [$package, $class->new($package)->$name(@args)]; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 3 | return $result; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | sub append { | ||||||||||||||||||||||||||||
| 40 | 9 | ▶ | my ($self, @args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
append: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 9 | my $class = $self->class; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 9 | my $path = join '/', | |||||||||||||||||||||||||||
| 45 | $self->path, map $class->new($_)->path, @args; | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 9 | return $class->new($path); | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | sub array { | ||||||||||||||||||||||||||||
| 51 | 11 | ▶ | my ($self, $name, @data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
array: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 18 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 11 | my $class = $self->package; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 18 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 11 | ▶ | @{"${class}::${name}"} = @data if @data; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 11 | return [@{"${class}::${name}"}]; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | sub arrays { | ||||||||||||||||||||||||||||
| 65 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
arrays: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 18 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 2 | my $class = $self->package; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | my $arrays = [ | ||||||||||||||||||||||||||||
| 72 | 6 | sort grep !!@{"${class}::$_"}, | |||||||||||||||||||||||||||
| 73 | 2 | grep /^[_a-zA-Z]\w*$/, keys %{"${class}::"} | |||||||||||||||||||||||||||
| 74 | ]; | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 2 | return $arrays; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | sub attributes { | ||||||||||||||||||||||||||||
| 80 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
attributes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 2 | return $self->meta->local('attrs'); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | sub authority { | ||||||||||||||||||||||||||||
| 86 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
authority: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 2 | return $self->scalar('AUTHORITY'); | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | sub basename { | ||||||||||||||||||||||||||||
| 92 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
basename: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 2 | return $self->parse->[-1]; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | sub blessed { | ||||||||||||||||||||||||||||
| 98 | 7 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
blessed: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 7 | ▶ | $data //= {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$data //= {}
MC/DC100%1/1
$data //= {}
$data
Truth table100%2/2
A
A= $data
| |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 7 | my $class = $self->load; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 7 | return CORE::bless($data, $class); | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | sub build { | ||||||||||||||||||||||||||||
| 108 | 3 | ▶ | my ($self, @args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
build: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 3 | my $class = $self->load; | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 3 | return $self->call('new', $class, @args); | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | sub call { | ||||||||||||||||||||||||||||
| 116 | 42 | ▶ | my ($self, $func, @args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
call: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 42 | my $class = $self->load; | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 42 | ▶ | unless ($func) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | 0 | $self->error({ | |||||||||||||||||||||||||||
| 122 | throw => 'error_on_call_undefined', | ||||||||||||||||||||||||||||
| 123 | package => $class, | ||||||||||||||||||||||||||||
| 124 | routine => $func, | ||||||||||||||||||||||||||||
| 125 | }); | ||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 42 | my $next = $class->can($func); | |||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 42 | ▶ | unless ($next) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | 2 | ▶ | if ($class->can('AUTOLOAD')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | 18 | ▶ | $next = sub { no strict 'refs'; &{"${class}::${func}"}(@args) }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 42 | ▶ | unless ($next) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 1 | $self->error({ | |||||||||||||||||||||||||||
| 138 | throw => 'error_on_call_missing', | ||||||||||||||||||||||||||||
| 139 | package => $class, | ||||||||||||||||||||||||||||
| 140 | routine => $func, | ||||||||||||||||||||||||||||
| 141 | }); | ||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 41 | @_ = @args; goto $next; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | sub chain { | ||||||||||||||||||||||||||||
| 148 | 3 | ▶ | my ($self, @steps) = @_; | ||||||||||||||||||||||||||
|
Subroutine
chain: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 3 | my $result = $self; | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 3 | for my $step (@steps) { | |||||||||||||||||||||||||||
| 153 | 5 | ▶ | my ($name, @args) = (ref($step) eq 'ARRAY') ? @$step : ($step); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 5 | $result = $result->$name(@args); | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 3 | return $result; | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | sub child { | ||||||||||||||||||||||||||||
| 162 | 6 | ▶ | my ($self, @args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
child: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 6 | return $self->append(@args); | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | sub children { | ||||||||||||||||||||||||||||
| 168 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
children: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 1 | my %list; | |||||||||||||||||||||||||||
| 171 | my $path; | ||||||||||||||||||||||||||||
| 172 | 1 | my $type; | |||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 1 | $path = quotemeta $self->path; | |||||||||||||||||||||||||||
| 175 | 1 | $type = 'pm'; | |||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 1 | my $regexp = qr/$path\/[^\/]+\.$type/; | |||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 1 | for my $item (keys %INC) { | |||||||||||||||||||||||||||
| 180 | 188 | ▶ | $list{$item}++ if $item =~ /$regexp$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 1 | my %seen; | |||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 1 | for my $dir (@INC) { | |||||||||||||||||||||||||||
| 186 | 8 | ▶ | next if $seen{$dir}++; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 7 | my $re = quotemeta $dir; | |||||||||||||||||||||||||||
| 189 | 27 | map { s/^$re\///; $list{$_}++ } | |||||||||||||||||||||||||||
| 190 | 7 | grep !$list{$_}, glob "$dir/@{[$self->path]}/*.$type"; | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 1 | my $class = $self->class; | |||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | return [ | ||||||||||||||||||||||||||||
| 196 | map $class->new($_), | ||||||||||||||||||||||||||||
| 197 | 1 | map {s/(.*)\.$type$/$1/r} | |||||||||||||||||||||||||||
| 198 | sort keys %list | ||||||||||||||||||||||||||||
| 199 | ]; | ||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | sub cop { | ||||||||||||||||||||||||||||
| 203 | 2 | ▶ | my ($self, $func, @args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
cop: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 2 | my $class = $self->load; | |||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 2 | ▶ | if (!$func) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | 0 | $self->error({ | |||||||||||||||||||||||||||
| 209 | throw => 'error_on_cop_undefined', | ||||||||||||||||||||||||||||
| 210 | package => $class, | ||||||||||||||||||||||||||||
| 211 | routine => $func, | ||||||||||||||||||||||||||||
| 212 | }); | ||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 2 | my $next = $class->can($func); | |||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 2 | ▶ | unless ($next) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | 1 | $self->error({ | |||||||||||||||||||||||||||
| 219 | throw => 'error_on_cop_missing', | ||||||||||||||||||||||||||||
| 220 | package => $class, | ||||||||||||||||||||||||||||
| 221 | routine => $func, | ||||||||||||||||||||||||||||
| 222 | }); | ||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 1 | ▶ | return sub { $next->(@args ? (@args, @_) : @_) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | sub data { | ||||||||||||||||||||||||||||
| 229 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
data: called CC=2 SCAR=7.9
Pod
documented
| |||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 18 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 1 | my $class = $self->package; | |||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 1 | local $.; | |||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 1 | my $handle = \*{"${class}::DATA"}; | |||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 1 | ▶ | return '' if !fileno $handle; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 0 | seek $handle, 0, 0; | |||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 0 | my $data = join '', <$handle>; | |||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 0 | $data =~ s/^.*\n__DATA__\r?\n/\n/s; | |||||||||||||||||||||||||||
| 246 | 0 | $data =~ s/\n__END__\r?\n.*$/\n/s; | |||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | return $data; | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | sub eval { | ||||||||||||||||||||||||||||
| 252 | 13 | ▶ | my ($self, @args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
eval: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 13 | local $@; | |||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 13 | ▶ | my $result = eval join ' ', map "$_", "package @{[$self->package]};", @args; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 13 | ▶ | if (my $error = $@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 259 | 2 | $self->error({ | |||||||||||||||||||||||||||
| 260 | throw => 'error_on_eval', | ||||||||||||||||||||||||||||
| 261 | package => $self->package, | ||||||||||||||||||||||||||||
| 262 | error => $error, | ||||||||||||||||||||||||||||
| 263 | }); | ||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 11 | return $result; | |||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | sub explain { | ||||||||||||||||||||||||||||
| 270 | 94 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
explain: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 94 | return $self->package; | |||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | sub hash { | ||||||||||||||||||||||||||||
| 276 | 2 | ▶ | my ($self, $name, @data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
hash: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | 18 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 2 | my $class = $self->package; | |||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 18 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 2 | ▶ | %{"${class}::${name}"} = (@data) if @data; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | 2 | return {%{"${class}::${name}"}}; | |||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | sub hashes { | ||||||||||||||||||||||||||||
| 290 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
hashes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | 18 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 2 | my $class = $self->package; | |||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | return [ | ||||||||||||||||||||||||||||
| 297 | 14 | sort grep !!%{"${class}::$_"}, | |||||||||||||||||||||||||||
| 298 | 2 | grep /^[_a-zA-Z]\w*$/, keys %{"${class}::"} | |||||||||||||||||||||||||||
| 299 | ]; | ||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | sub id { | ||||||||||||||||||||||||||||
| 303 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | 2 | return $self->label; | |||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | sub init { | ||||||||||||||||||||||||||||
| 309 | 6 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 6 | $self->tryload; | |||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 6 | ▶ | $self->eval('sub import') if !$self->loaded; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | 6 | return $self->package; | |||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | sub inherits { | ||||||||||||||||||||||||||||
| 319 | 8 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
inherits: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | 8 | return $self->array('ISA'); | |||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | sub included { | ||||||||||||||||||||||||||||
| 325 | 494 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
included: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | 494 | return $INC{$self->format('path', '%s.pm')}; | |||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | sub inject { | ||||||||||||||||||||||||||||
| 331 | 1 | ▶ | my ($self, $name, $coderef) = @_; | ||||||||||||||||||||||||||
|
Subroutine
inject: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | 18 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 334 | 18 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 1 | my $class = $self->package; | |||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | 1 | ▶ | return *{"${class}::${name}"} = $coderef || sub{$class}; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Condition33%1/3
$coderef || sub {
$class;
}
MC/DC0%0/2
$coderef || sub {
$class;
}
$coderef
sub {
$class;
}
Truth table33%1/3
A || B
A= $coderefB= sub {
$class;
}
| |||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | sub integrates { | ||||||||||||||||||||||||||||
| 342 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
integrates: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | 2 | my $roles = $self->meta->roles; | |||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | 2 | ▶ | return $roles || []; | ||||||||||||||||||||||||||
|
Condition50%1/2
$roles || []
MC/DC0%0/1
$roles || []
$roles
Truth table50%1/2
A
A= $roles
| |||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | sub lfile { | ||||||||||||||||||||||||||||
| 350 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
lfile: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | 1 | return $self->format('path', '%s.pm'); | |||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | sub load { | ||||||||||||||||||||||||||||
| 356 | 325 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
load: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 325 | my $class = $self->package; | |||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | 325 | ▶ | return $class if $class eq 'main' || $self->loaded; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$class eq "main" or $self->loaded
MC/DC50%1/2
$class eq "main" or $self->loaded
$class eq "main"
$self->loaded
Truth table66%2/3
A or B
A= $class eq "main"B= $self->loaded
| |||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | 19 | my $error = do{local $@; eval "require $class"; $@}; | |||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | 19 | ▶ | if ($error) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 365 | 6 | ▶ | $self->error({ | ||||||||||||||||||||||||||
|
Condition50%1/2
$error || 'cause unknown'
MC/DC0%0/1
$error || 'cause unknown'
$error
Truth table50%1/2
A
A= $error
| |||||||||||||||||||||||||||||
| 366 | throw => 'error_on_load', | ||||||||||||||||||||||||||||
| 367 | error => $error || 'cause unknown', | ||||||||||||||||||||||||||||
| 368 | package => $class, | ||||||||||||||||||||||||||||
| 369 | }); | ||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | 13 | return $class; | |||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | sub loaded { | ||||||||||||||||||||||||||||
| 376 | 493 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
loaded: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | 493 | ▶ | return ($self->included || @{$self->routines}) ? true : false; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->included or @{$self->routines;}
MC/DC100%2/2
$self->included or @{$self->routines;}
$self->included
@{$self->routines;}
Truth table100%3/3
A or B
A= $self->includedB= @{$self->routines;}
| |||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | sub locate { | ||||||||||||||||||||||||||||
| 382 | 5 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
locate: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | 5 | my $found = ''; | |||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | 5 | my $file = $self->format('path', '%s.pm'); | |||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | 5 | for my $path (@INC) { | |||||||||||||||||||||||||||
| 389 | 20 | ▶ | do { $found = "$path/$file"; last } if -f "$path/$file"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | 5 | return $found; | |||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | sub meta { | ||||||||||||||||||||||||||||
| 396 | 5 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
meta: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | 5 | require Venus::Meta; | |||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | 5 | return Venus::Meta->new(name => $self->package); | |||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | sub mock { | ||||||||||||||||||||||||||||
| 404 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
mock: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | 1 | my $name = sprintf '%s::Mock::%04d::%s', $self->class, ++$SERIAL, $self->package; | |||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | 1 | my $space = $self->class->new($name); | |||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | 1 | ▶ | $space->do('init')->array('ISA', $self->package) if !$space->loaded; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | 1 | return $space; | |||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | sub name { | ||||||||||||||||||||||||||||
| 416 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | 1 | return $self->package; | |||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | sub parent { | ||||||||||||||||||||||||||||
| 422 | 3 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
parent: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | 3 | my @parts = @{$self->parse}; | |||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | 3 | ▶ | pop @parts if @parts > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | 3 | my $class = $self->class; | |||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | 3 | return $class->new(join '/', @parts); | |||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | sub parse { | ||||||||||||||||||||||||||||
| 434 | 18 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
parse: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | return [ | ||||||||||||||||||||||||||||
| 437 | 18 | map ucfirst, | |||||||||||||||||||||||||||
| 438 | map join('', map(ucfirst, split /[-_]/)), | ||||||||||||||||||||||||||||
| 439 | split /[^-_a-zA-Z0-9.]+/, | ||||||||||||||||||||||||||||
| 440 | $self->path | ||||||||||||||||||||||||||||
| 441 | ]; | ||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | sub parts { | ||||||||||||||||||||||||||||
| 445 | 7 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
parts: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||
| 447 | 7 | return $self->parse; | |||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | sub patch { | ||||||||||||||||||||||||||||
| 451 | 9 | ▶ | my ($self, $name, $code) = @_; | ||||||||||||||||||||||||||
|
Subroutine
patch: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | 9 | ▶ | my $patched = $self->{'$patched'} ||= {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"\$patched"} ||= {}
MC/DC0%0/1
$self->{"\$patched"} ||= {}
$self->{"\$patched"}
Truth table50%1/2
A
A= $self->{"\$patched"}
| |||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | 9 | my $orig = $self->swap($name, $code); | |||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | 9 | $patched->{$name} = $orig; | |||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | 9 | return $self; | |||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | sub patched { | ||||||||||||||||||||||||||||
| 463 | 8 | ▶ | my ($self, $name) = @_; | ||||||||||||||||||||||||||
|
Subroutine
patched: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | 8 | my $patched = $self->{'$patched'}; | |||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | 8 | ▶ | return false if !$patched; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||
| 469 | 6 | ▶ | return $name ? ($patched->{$name} ? true : false) : true; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | sub pfile { | ||||||||||||||||||||||||||||
| 473 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
pfile: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | 1 | return $self->format('path', '%s.pod'); | |||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | sub prepend { | ||||||||||||||||||||||||||||
| 479 | 3 | ▶ | my ($self, @args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
prepend: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||
| 481 | 3 | my $class = $self->class; | |||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | 3 | my $path = join '/', | |||||||||||||||||||||||||||
| 484 | (map $class->new($_)->path, @args), $self->path; | ||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||
| 486 | 3 | return $class->new($path); | |||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | sub purge { | ||||||||||||||||||||||||||||
| 490 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
purge: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||
| 492 | 1 | ▶ | return $self if $self->unloaded; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | 1 | my $package = $self->package; | |||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | 18 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | 1 | for my $name (grep !/\A[^:]+::\z/, keys %{"${package}::"}) { | |||||||||||||||||||||||||||
| 499 | 5 | undef *{"${package}::${name}"}; delete ${"${package}::"}{$name}; | |||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||
| 502 | 1 | delete $INC{$self->format('path', '%s.pm')}; | |||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | 1 | return $self; | |||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | sub rebase { | ||||||||||||||||||||||||||||
| 508 | 1 | ▶ | my ($self, @args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
rebase: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | 1 | my $class = $self->class; | |||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||
| 512 | 1 | my $path = join '/', map $class->new($_)->path, @args; | |||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | 1 | return $class->new($self->basename)->prepend($path); | |||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | sub reload { | ||||||||||||||||||||||||||||
| 518 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
reload: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | 2 | $self->unload; | |||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | 2 | return $self->load; | |||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | sub require { | ||||||||||||||||||||||||||||
| 526 | 4 | ▶ | my ($self, $target) = @_; | ||||||||||||||||||||||||||
|
Subroutine
require: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | 4 | ▶ | $target = "'$target'" if -f $target; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||
| 530 | 4 | return $self->eval("require $target"); | |||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | sub root { | ||||||||||||||||||||||||||||
| 534 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
root: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||
| 536 | 1 | return $self->parse->[0]; | |||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||
| 539 | sub routine { | ||||||||||||||||||||||||||||
| 540 | 22 | ▶ | my ($self, $name, $code) = @_; | ||||||||||||||||||||||||||
|
Subroutine
routine: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | 18 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | 22 | my $class = $self->package; | |||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | 18 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | 22 | ▶ | *{"${class}::${name}"} = $code if $code; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||
| 550 | 22 | return *{"${class}::${name}"}{"CODE"}; | |||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||
| 553 | sub routines { | ||||||||||||||||||||||||||||
| 554 | 275 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
routines: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | 18 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | 275 | my $class = $self->package; | |||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | return [ | ||||||||||||||||||||||||||||
| 561 | 10120 | sort grep *{"${class}::$_"}{"CODE"}, | |||||||||||||||||||||||||||
| 562 | 275 | grep /^[_a-zA-Z]\w*$/, keys %{"${class}::"} | |||||||||||||||||||||||||||
| 563 | ]; | ||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | sub scalar { | ||||||||||||||||||||||||||||
| 567 | 7 | ▶ | my ($self, $name, @data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
scalar: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||
| 569 | 18 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||
| 571 | 7 | my $class = $self->package; | |||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||
| 573 | 18 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | 7 | ▶ | ${"${class}::${name}"} = $data[0] if @data; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | 7 | return ${"${class}::${name}"}; | |||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||
| 580 | sub scalars { | ||||||||||||||||||||||||||||
| 581 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
scalars: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||
| 583 | 18 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||
| 585 | 2 | my $class = $self->package; | |||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||
| 587 | return [ | ||||||||||||||||||||||||||||
| 588 | 19 | sort grep defined ${"${class}::$_"}, | |||||||||||||||||||||||||||
| 589 | 2 | grep /^[_a-zA-Z]\w*$/, keys %{"${class}::"} | |||||||||||||||||||||||||||
| 590 | ]; | ||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||
| 593 | sub sibling { | ||||||||||||||||||||||||||||
| 594 | 1 | ▶ | my ($self, @args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
sibling: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||
| 596 | 1 | return $self->parent->append(@args); | |||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||
| 599 | sub siblings { | ||||||||||||||||||||||||||||
| 600 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
siblings: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||
| 602 | 1 | my %list; | |||||||||||||||||||||||||||
| 603 | my $path; | ||||||||||||||||||||||||||||
| 604 | 1 | my $type; | |||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||
| 606 | 1 | $path = quotemeta $self->parent->path; | |||||||||||||||||||||||||||
| 607 | 1 | $type = 'pm'; | |||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||
| 609 | 1 | my $regexp = qr/$path\/[^\/]+\.$type/; | |||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||
| 611 | 1 | for my $item (keys %INC) { | |||||||||||||||||||||||||||
| 612 | 243 | ▶ | $list{$item}++ if $item =~ /$regexp$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||
| 615 | 1 | my %seen; | |||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||
| 617 | 1 | for my $dir (@INC) { | |||||||||||||||||||||||||||
| 618 | 11 | ▶ | next if $seen{$dir}++; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||
| 620 | 8 | my $re = quotemeta $dir; | |||||||||||||||||||||||||||
| 621 | 2 | map { s/^$re\///; $list{$_}++ } | |||||||||||||||||||||||||||
| 622 | 8 | grep !$list{$_}, glob "$dir/@{[$self->path]}/*.$type"; | |||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||
| 625 | 1 | my $class = $self->class; | |||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||
| 627 | return [ | ||||||||||||||||||||||||||||
| 628 | map $class->new($_), | ||||||||||||||||||||||||||||
| 629 | 1 | map {s/(.*)\.$type$/$1/r} | |||||||||||||||||||||||||||
| 630 | sort keys %list | ||||||||||||||||||||||||||||
| 631 | ]; | ||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||
| 634 | sub splice { | ||||||||||||||||||||||||||||
| 635 | 4 | ▶ | my ($self, $offset, $length, @list) = @_; | ||||||||||||||||||||||||||
|
Subroutine
splice: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||
| 637 | 4 | my $class = $self->class; | |||||||||||||||||||||||||||
| 638 | 4 | my $parts = $self->parts; | |||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||
| 640 | 4 | ▶ | if (@list) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 641 | 1 | CORE::splice(@{$parts}, $offset, $length, @list); | |||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||
| 643 | elsif (defined $length) { | ||||||||||||||||||||||||||||
| 644 | 2 | CORE::splice(@{$parts}, $offset, $length); | |||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||
| 646 | elsif (defined $offset) { | ||||||||||||||||||||||||||||
| 647 | 1 | CORE::splice(@{$parts}, $offset); | |||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||
| 650 | 4 | return $class->new(join '/', @$parts); | |||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||
| 653 | sub swap { | ||||||||||||||||||||||||||||
| 654 | 14 | ▶ | my ($self, $name, $code) = @_; | ||||||||||||||||||||||||||
|
Subroutine
swap: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||
| 656 | 14 | my $orig = (my $package = $self->package)->can($name); | |||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||
| 658 | 14 | ▶ | return $orig if !$code; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||
| 660 | 14 | ▶ | if (!$orig) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 661 | 1 | $self->error({ | |||||||||||||||||||||||||||
| 662 | throw => 'error_on_swap', | ||||||||||||||||||||||||||||
| 663 | package => $package, | ||||||||||||||||||||||||||||
| 664 | routine => $name, | ||||||||||||||||||||||||||||
| 665 | }); | ||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||
| 668 | 13 | ▶ | $self->routine($name, sub {$code->($orig, @_)}); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||
| 670 | 13 | return $orig; | |||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||
| 673 | sub tfile { | ||||||||||||||||||||||||||||
| 674 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
tfile: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||
| 676 | 1 | return $self->format('label', '%s.t'); | |||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||
| 679 | sub tryload { | ||||||||||||||||||||||||||||
| 680 | 10 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
tryload: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||
| 682 | 10 | return do { local $@; eval { $self->load }; int!$@ }; | |||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||
| 685 | sub use { | ||||||||||||||||||||||||||||
| 686 | 3 | ▶ | my ($self, $target, @params) = @_; | ||||||||||||||||||||||||||
|
Subroutine
use: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||
| 688 | 3 | my $version; | |||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||
| 690 | 3 | ▶ | ($target, $version) = @$target if ref $target eq 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||
| 692 | 3 | $self->require($target); | |||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||
| 694 | 3 | require Scalar::Util; | |||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||
| 696 | 3 | ▶ | my @statement = ( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 697 | 'no strict "subs";', | ||||||||||||||||||||||||||||
| 698 | ( | ||||||||||||||||||||||||||||
| 699 | Scalar::Util::looks_like_number($version) | ||||||||||||||||||||||||||||
| 700 | ? "${target}->VERSION($version);" : () | ||||||||||||||||||||||||||||
| 701 | ), | ||||||||||||||||||||||||||||
| 702 | 'sub{ my ($target, @params) = @_; $target->import(@params)}' | ||||||||||||||||||||||||||||
| 703 | ); | ||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||
| 705 | 3 | $self->eval(join("\n", @statement))->($target, @params); | |||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||
| 707 | 2 | return $self; | |||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||
| 710 | sub variables { | ||||||||||||||||||||||||||||
| 711 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
variables: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||
| 713 | 1 | return [map [$_, [sort @{$self->$_}]], qw(arrays hashes scalars)]; | |||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||
| 716 | sub version { | ||||||||||||||||||||||||||||
| 717 | 3 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||
| 719 | 3 | return $self->scalar('VERSION'); | |||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||
| 722 | sub unload { | ||||||||||||||||||||||||||||
| 723 | 151 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
unload: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||
| 725 | 151 | ▶ | return $self if $self->unloaded; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||
| 727 | 115 | my $package = $self->package; | |||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||
| 729 | 18 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||
| 731 | 115 | for my $name (grep !/\A[^:]+::\z/, keys %{"${package}::"}) { | |||||||||||||||||||||||||||
| 732 | 5596 | undef *{"${package}::${name}"}; | |||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||
| 735 | 115 | delete $INC{$self->format('path', '%s.pm')}; | |||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||
| 737 | 115 | return $self; | |||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||
| 740 | sub unloaded { | ||||||||||||||||||||||||||||
| 741 | 154 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
unloaded: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||
| 743 | 154 | ▶ | return $self->loaded ? false : true; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||
| 746 | sub unpatch { | ||||||||||||||||||||||||||||
| 747 | 5 | ▶ | my ($self, @names) = @_; | ||||||||||||||||||||||||||
|
Subroutine
unpatch: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||
| 749 | 5 | ▶ | my $patched = $self->{'$patched'} ||= {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"\$patched"} ||= {}
MC/DC0%0/1
$self->{"\$patched"} ||= {}
$self->{"\$patched"}
Truth table50%1/2
A
A= $self->{"\$patched"}
| |||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||
| 751 | 5 | ▶ | @names = keys %{$patched} if !@names; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||
| 753 | 5 | for my $name (@names) { | |||||||||||||||||||||||||||
| 754 | 5 | ▶ | my $orig = delete $patched->{$name} or next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 755 | 4 | $self->routine($name, $orig); | |||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||
| 758 | 5 | ▶ | delete $self->{'$patched'} if !keys %{$patched}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||
| 760 | 5 | return $self; | |||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||
| 763 | sub visible { | ||||||||||||||||||||||||||||
| 764 | 6 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
visible: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||
| 766 | 18 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||
| 768 | 6 | my $package = $self->package; | |||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||
| 770 | 6 | ▶ | return (grep !/\A[^:]+::\z/, keys %{"${package}::"}) ? true : false; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||
| 773 | # ERRORS | ||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||
| 775 | sub error_on_call_missing { | ||||||||||||||||||||||||||||
| 776 | 2 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
error_on_call_missing: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||
| 778 | 2 | my $message = 'Unable to locate class method "{{routine}}" via package "{{package}}"'; | |||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||
| 780 | my $stash = { | ||||||||||||||||||||||||||||
| 781 | package => $data->{package}, | ||||||||||||||||||||||||||||
| 782 | routine => $data->{routine}, | ||||||||||||||||||||||||||||
| 783 | 2 | }; | |||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||
| 785 | 2 | my $result = { | |||||||||||||||||||||||||||
| 786 | name => 'on.call.missing', | ||||||||||||||||||||||||||||
| 787 | raise => true, | ||||||||||||||||||||||||||||
| 788 | stash => $stash, | ||||||||||||||||||||||||||||
| 789 | message => $message, | ||||||||||||||||||||||||||||
| 790 | }; | ||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||
| 792 | 2 | return $result; | |||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||
| 795 | sub error_on_call_undefined { | ||||||||||||||||||||||||||||
| 796 | 1 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
error_on_call_undefined: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||
| 798 | 1 | my $message = join ' ', 'Attempt to call undefined class method', | |||||||||||||||||||||||||||
| 799 | 'in package "{{package}}"'; | ||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||
| 801 | my $stash = { | ||||||||||||||||||||||||||||
| 802 | package => $data->{package}, | ||||||||||||||||||||||||||||
| 803 | routine => $data->{routine}, | ||||||||||||||||||||||||||||
| 804 | 1 | }; | |||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||
| 806 | 1 | my $result = { | |||||||||||||||||||||||||||
| 807 | name => 'on.call.undefined', | ||||||||||||||||||||||||||||
| 808 | raise => true, | ||||||||||||||||||||||||||||
| 809 | stash => $stash, | ||||||||||||||||||||||||||||
| 810 | message => $message, | ||||||||||||||||||||||||||||
| 811 | }; | ||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||
| 813 | 1 | return $result; | |||||||||||||||||||||||||||
| 814 | } | ||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||
| 816 | sub error_on_cop_missing { | ||||||||||||||||||||||||||||
| 817 | 2 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
error_on_cop_missing: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||
| 819 | 2 | my $message = join ' ', 'Unable to locate object method "{{routine}}"', | |||||||||||||||||||||||||||
| 820 | 'via package "{{package}}"'; | ||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||
| 822 | my $stash = { | ||||||||||||||||||||||||||||
| 823 | package => $data->{package}, | ||||||||||||||||||||||||||||
| 824 | routine => $data->{routine}, | ||||||||||||||||||||||||||||
| 825 | 2 | }; | |||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||
| 827 | 2 | my $result = { | |||||||||||||||||||||||||||
| 828 | name => 'on.cop.missing', | ||||||||||||||||||||||||||||
| 829 | raise => true, | ||||||||||||||||||||||||||||
| 830 | stash => $stash, | ||||||||||||||||||||||||||||
| 831 | message => $message, | ||||||||||||||||||||||||||||
| 832 | }; | ||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||
| 834 | 2 | return $result; | |||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||
| 837 | sub error_on_cop_undefined { | ||||||||||||||||||||||||||||
| 838 | 1 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
error_on_cop_undefined: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||
| 840 | 1 | my $message = join ' ', 'Attempt to cop undefined object method', | |||||||||||||||||||||||||||
| 841 | 'from package "{{package}}"'; | ||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||
| 843 | my $stash = { | ||||||||||||||||||||||||||||
| 844 | package => $data->{package}, | ||||||||||||||||||||||||||||
| 845 | routine => $data->{routine}, | ||||||||||||||||||||||||||||
| 846 | 1 | }; | |||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||
| 848 | 1 | my $result = { | |||||||||||||||||||||||||||
| 849 | name => 'on.cop.undefined', | ||||||||||||||||||||||||||||
| 850 | raise => true, | ||||||||||||||||||||||||||||
| 851 | stash => $stash, | ||||||||||||||||||||||||||||
| 852 | message => $message, | ||||||||||||||||||||||||||||
| 853 | }; | ||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||
| 855 | 1 | return $result; | |||||||||||||||||||||||||||
| 856 | } | ||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||
| 858 | sub error_on_eval { | ||||||||||||||||||||||||||||
| 859 | 3 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
error_on_eval: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||
| 861 | 3 | my $message = $data->{error}; | |||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||
| 863 | my $stash = { | ||||||||||||||||||||||||||||
| 864 | error => $message, | ||||||||||||||||||||||||||||
| 865 | package => $data->{package}, | ||||||||||||||||||||||||||||
| 866 | 3 | }; | |||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||
| 868 | 3 | my $result = { | |||||||||||||||||||||||||||
| 869 | name => 'on.eval', | ||||||||||||||||||||||||||||
| 870 | raise => true, | ||||||||||||||||||||||||||||
| 871 | stash => $stash, | ||||||||||||||||||||||||||||
| 872 | message => $message, | ||||||||||||||||||||||||||||
| 873 | }; | ||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||
| 875 | 3 | return $result; | |||||||||||||||||||||||||||
| 876 | } | ||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||
| 878 | sub error_on_load { | ||||||||||||||||||||||||||||
| 879 | 7 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
error_on_load: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||
| 881 | 7 | my $message = 'Error attempting to load {{package}}: "{{error}}"'; | |||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||
| 883 | my $stash = { | ||||||||||||||||||||||||||||
| 884 | error => $data->{error}, | ||||||||||||||||||||||||||||
| 885 | package => $data->{package}, | ||||||||||||||||||||||||||||
| 886 | 7 | }; | |||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||
| 888 | 7 | my $result = { | |||||||||||||||||||||||||||
| 889 | name => 'on.load', | ||||||||||||||||||||||||||||
| 890 | raise => true, | ||||||||||||||||||||||||||||
| 891 | stash => $stash, | ||||||||||||||||||||||||||||
| 892 | message => $message, | ||||||||||||||||||||||||||||
| 893 | }; | ||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||
| 895 | 7 | return $result; | |||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||
| 898 | sub error_on_swap { | ||||||||||||||||||||||||||||
| 899 | 2 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
error_on_swap: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||
| 901 | 2 | my $message = 'Attempt to swap undefined subroutine in package "{{package}}"'; | |||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||
| 903 | my $stash = { | ||||||||||||||||||||||||||||
| 904 | package => $data->{package}, | ||||||||||||||||||||||||||||
| 905 | routine => $data->{routine}, | ||||||||||||||||||||||||||||
| 906 | 2 | }; | |||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||
| 908 | 2 | my $result = { | |||||||||||||||||||||||||||
| 909 | name => 'on.swap', | ||||||||||||||||||||||||||||
| 910 | raise => true, | ||||||||||||||||||||||||||||
| 911 | stash => $stash, | ||||||||||||||||||||||||||||
| 912 | message => $message, | ||||||||||||||||||||||||||||
| 913 | }; | ||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||
| 915 | 2 | return $result; | |||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||
| 918 | 18 | 1; | |||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||
| 922 | =head1 NAME | ||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||
| 924 | Venus::Space - Space Class | ||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||
| 926 | =cut | ||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||
| 928 | =head1 ABSTRACT | ||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||
| 930 | Space Class for Perl 5 | ||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||
| 932 | =cut | ||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||
| 934 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||
| 936 | package main; | ||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||
| 938 | use Venus::Space; | ||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||
| 940 | my $space = Venus::Space->new('foo/bar'); | ||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||
| 942 | # $space->package; # Foo::Bar | ||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||
| 944 | =cut | ||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||
| 946 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||
| 948 | This package provides methods for parsing and manipulating package namespaces. | ||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||
| 950 | =cut | ||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||
| 952 | =head1 INHERITS | ||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||
| 954 | This package inherits behaviors from: | ||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||
| 956 | L<Venus::Name> | ||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||
| 958 | =cut | ||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||
| 960 | =head1 METHODS | ||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||
| 962 | This package provides the following methods: | ||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||
| 964 | =cut | ||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||
| 966 | =head2 all | ||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||
| 968 | all(string $method, any @args) (within[arrayref, tuple[string, any]]) | ||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||
| 970 | The all method executes any available method on the instance and all instances | ||||||||||||||||||||||||||||
| 971 | representing packages inherited by the package represented by the invocant. | ||||||||||||||||||||||||||||
| 972 | This method supports dispatching, i.e. providing a method name and arguments | ||||||||||||||||||||||||||||
| 973 | whose return value will be acted on by this method. | ||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||
| 975 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||
| 977 | =over 4 | ||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||
| 979 | =item all example 1 | ||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||
| 981 | package main; | ||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||
| 983 | use Venus::Space; | ||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||
| 985 | my $space = Venus::Space->new('Venus'); | ||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||
| 987 | my $all = $space->all('id'); | ||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||
| 989 | # [["Venus", "Venus"]] | ||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||
| 991 | =back | ||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||
| 993 | =over 4 | ||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||
| 995 | =item all example 2 | ||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||
| 997 | package main; | ||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||
| 999 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1000 | |||||||||||||||||||||||||||||
| 1001 | my $space = Venus::Space->new('Venus/Space'); | ||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||
| 1003 | my $all = $space->all('inherits'); | ||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||
| 1005 | # [ | ||||||||||||||||||||||||||||
| 1006 | # [ | ||||||||||||||||||||||||||||
| 1007 | # "Venus::Space", ["Venus::Name"] | ||||||||||||||||||||||||||||
| 1008 | # ], | ||||||||||||||||||||||||||||
| 1009 | # [ | ||||||||||||||||||||||||||||
| 1010 | # "Venus::Name", ["Venus::Kind::Utility"] | ||||||||||||||||||||||||||||
| 1011 | # ], | ||||||||||||||||||||||||||||
| 1012 | # ] | ||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||
| 1014 | =back | ||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||
| 1016 | =over 4 | ||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||
| 1018 | =item all example 3 | ||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||
| 1020 | package main; | ||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||
| 1022 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||
| 1024 | my $space = Venus::Space->new('Venus/Space'); | ||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||
| 1026 | my $all = $space->all('locate'); | ||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||
| 1028 | # [ | ||||||||||||||||||||||||||||
| 1029 | # [ | ||||||||||||||||||||||||||||
| 1030 | # "Venus::Space", | ||||||||||||||||||||||||||||
| 1031 | # "/path/to/lib/Venus/Space.pm", | ||||||||||||||||||||||||||||
| 1032 | # ], | ||||||||||||||||||||||||||||
| 1033 | # [ | ||||||||||||||||||||||||||||
| 1034 | # "Venus::Name", | ||||||||||||||||||||||||||||
| 1035 | # "/path/to/lib/Venus/Name.pm", | ||||||||||||||||||||||||||||
| 1036 | # ], | ||||||||||||||||||||||||||||
| 1037 | # ] | ||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||
| 1039 | =back | ||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||
| 1041 | =cut | ||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||
| 1043 | =head2 append | ||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||
| 1045 | append(string @path) (Venus::Space) | ||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||
| 1047 | The append method modifies the object by appending to the package namespace | ||||||||||||||||||||||||||||
| 1048 | parts. | ||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||
| 1050 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||
| 1052 | =over 4 | ||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||
| 1054 | =item append example 1 | ||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||
| 1056 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||
| 1058 | my $append = $space->append('baz'); | ||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||
| 1060 | # bless({ value => "Foo/Bar/Baz" }, "Venus::Space") | ||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||
| 1062 | =back | ||||||||||||||||||||||||||||
| 1063 | |||||||||||||||||||||||||||||
| 1064 | =over 4 | ||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||
| 1066 | =item append example 2 | ||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||
| 1068 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||
| 1070 | my $append = $space->append('baz', 'bax'); | ||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||
| 1072 | # bless({ value => "Foo/Bar/Baz/Bax" }, "Venus::Space") | ||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||
| 1074 | =back | ||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||
| 1076 | =cut | ||||||||||||||||||||||||||||
| 1077 | |||||||||||||||||||||||||||||
| 1078 | =head2 array | ||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||
| 1080 | array(string $name, any @data) (arrayref) | ||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||
| 1082 | The array method gets or sets the value for the given package array variable name. | ||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||
| 1084 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||
| 1086 | =over 4 | ||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||
| 1088 | =item array example 1 | ||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||
| 1090 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||
| 1092 | package Foo::Bar; | ||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||
| 1094 | our @handler = 'start'; | ||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||
| 1096 | package main; | ||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||
| 1098 | my $array = $space->array('handler'); | ||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||
| 1100 | # ["start"] | ||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||
| 1102 | =back | ||||||||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||||||||
| 1104 | =over 4 | ||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||
| 1106 | =item array example 2 | ||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||
| 1108 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||
| 1110 | package Foo::Bar; | ||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||
| 1112 | our @handler = 'start'; | ||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||
| 1114 | package main; | ||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||
| 1116 | my $array = $space->array('handler', 'restart'); | ||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||
| 1118 | # ["restart"] | ||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||
| 1120 | =back | ||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||
| 1122 | =cut | ||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||
| 1124 | =head2 arrays | ||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||
| 1126 | arrays() (arrayref) | ||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||
| 1128 | The arrays method searches the package namespace for arrays and returns their | ||||||||||||||||||||||||||||
| 1129 | names. | ||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||
| 1131 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||
| 1133 | =over 4 | ||||||||||||||||||||||||||||
| 1134 | |||||||||||||||||||||||||||||
| 1135 | =item arrays example 1 | ||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||
| 1137 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||
| 1139 | package Foo::Bar; | ||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||
| 1141 | our @handler = 'start'; | ||||||||||||||||||||||||||||
| 1142 | our @initial = ('next', 'prev'); | ||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||
| 1144 | package main; | ||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||
| 1146 | my $arrays = $space->arrays; | ||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||
| 1148 | # ["handler", "initial"] | ||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||
| 1150 | =back | ||||||||||||||||||||||||||||
| 1151 | |||||||||||||||||||||||||||||
| 1152 | =cut | ||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||
| 1154 | =head2 attributes | ||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||
| 1156 | attributes() (arrayref) | ||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||
| 1158 | The attributes method searches the package namespace for attributes and returns | ||||||||||||||||||||||||||||
| 1159 | their names. This will not include attributes from roles, mixins, or superclasses. | ||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||
| 1161 | I<Since C<1.02>> | ||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||
| 1163 | =over 4 | ||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||
| 1165 | =item attributes example 1 | ||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||
| 1167 | package Foo::Attrs; | ||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||
| 1169 | use Venus::Class 'attr'; | ||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||
| 1171 | attr 'start'; | ||||||||||||||||||||||||||||
| 1172 | attr 'abort'; | ||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||
| 1174 | package main; | ||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||
| 1176 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||||||||
| 1178 | my $space = Venus::Space->new('foo/attrs'); | ||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||
| 1180 | my $attributes = $space->attributes; | ||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||
| 1182 | # ["start", "abort"] | ||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||
| 1184 | =back | ||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||
| 1186 | =over 4 | ||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||
| 1188 | =item attributes example 2 | ||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||
| 1190 | package Foo::Base; | ||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||
| 1192 | use Venus::Class 'attr', 'base'; | ||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||
| 1194 | attr 'start'; | ||||||||||||||||||||||||||||
| 1195 | attr 'abort'; | ||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||
| 1197 | package Foo::Attrs; | ||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||
| 1199 | use Venus::Class 'attr'; | ||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||
| 1201 | attr 'show'; | ||||||||||||||||||||||||||||
| 1202 | attr 'hide'; | ||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||
| 1204 | package main; | ||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||
| 1206 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||
| 1208 | my $space = Venus::Space->new('foo/attrs'); | ||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||
| 1210 | my $attributes = $space->attributes; | ||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||
| 1212 | # ["show", "hide"] | ||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||
| 1214 | =back | ||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||
| 1216 | =cut | ||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||
| 1218 | =head2 authority | ||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||
| 1220 | authority() (maybe[string]) | ||||||||||||||||||||||||||||
| 1221 | |||||||||||||||||||||||||||||
| 1222 | The authority method returns the C<AUTHORITY> declared on the target package, | ||||||||||||||||||||||||||||
| 1223 | if any. | ||||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||
| 1225 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||
| 1227 | =over 4 | ||||||||||||||||||||||||||||
| 1228 | |||||||||||||||||||||||||||||
| 1229 | =item authority example 1 | ||||||||||||||||||||||||||||
| 1230 | |||||||||||||||||||||||||||||
| 1231 | package Foo::Boo; | ||||||||||||||||||||||||||||
| 1232 | |||||||||||||||||||||||||||||
| 1233 | package main; | ||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||
| 1235 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1236 | |||||||||||||||||||||||||||||
| 1237 | my $space = Venus::Space->new('foo/boo'); | ||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||
| 1239 | my $authority = $space->authority; | ||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||
| 1241 | # undef | ||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||
| 1243 | =back | ||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||
| 1245 | =over 4 | ||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||
| 1247 | =item authority example 2 | ||||||||||||||||||||||||||||
| 1248 | |||||||||||||||||||||||||||||
| 1249 | package Foo::Boo; | ||||||||||||||||||||||||||||
| 1250 | |||||||||||||||||||||||||||||
| 1251 | our $AUTHORITY = 'cpan:CPANERY'; | ||||||||||||||||||||||||||||
| 1252 | |||||||||||||||||||||||||||||
| 1253 | package main; | ||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||
| 1255 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||
| 1257 | my $space = Venus::Space->new('foo/boo'); | ||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||
| 1259 | my $authority = $space->authority; | ||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||
| 1261 | # "cpan:CPANERY" | ||||||||||||||||||||||||||||
| 1262 | |||||||||||||||||||||||||||||
| 1263 | =back | ||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||
| 1265 | =cut | ||||||||||||||||||||||||||||
| 1266 | |||||||||||||||||||||||||||||
| 1267 | =head2 basename | ||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||
| 1269 | basename() (string) | ||||||||||||||||||||||||||||
| 1270 | |||||||||||||||||||||||||||||
| 1271 | The basename method returns the last segment of the package namespace parts. | ||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||
| 1273 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||
| 1275 | =over 4 | ||||||||||||||||||||||||||||
| 1276 | |||||||||||||||||||||||||||||
| 1277 | =item basename example 1 | ||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||
| 1279 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||
| 1281 | my $basename = $space->basename; | ||||||||||||||||||||||||||||
| 1282 | |||||||||||||||||||||||||||||
| 1283 | # "Bar" | ||||||||||||||||||||||||||||
| 1284 | |||||||||||||||||||||||||||||
| 1285 | =back | ||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||
| 1287 | =cut | ||||||||||||||||||||||||||||
| 1288 | |||||||||||||||||||||||||||||
| 1289 | =head2 blessed | ||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||
| 1291 | blessed(Ref $data) (Self) | ||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||
| 1293 | The blessed method blesses the given value into the package namespace and | ||||||||||||||||||||||||||||
| 1294 | returns an object. If no value is given, an empty hashref is used. | ||||||||||||||||||||||||||||
| 1295 | |||||||||||||||||||||||||||||
| 1296 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1297 | |||||||||||||||||||||||||||||
| 1298 | =over 4 | ||||||||||||||||||||||||||||
| 1299 | |||||||||||||||||||||||||||||
| 1300 | =item blessed example 1 | ||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||
| 1302 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1303 | |||||||||||||||||||||||||||||
| 1304 | package Foo::Bar; | ||||||||||||||||||||||||||||
| 1305 | |||||||||||||||||||||||||||||
| 1306 | sub import; | ||||||||||||||||||||||||||||
| 1307 | |||||||||||||||||||||||||||||
| 1308 | package main; | ||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||
| 1310 | my $blessed = $space->blessed; | ||||||||||||||||||||||||||||
| 1311 | |||||||||||||||||||||||||||||
| 1312 | # bless({}, "Foo::Bar") | ||||||||||||||||||||||||||||
| 1313 | |||||||||||||||||||||||||||||
| 1314 | =back | ||||||||||||||||||||||||||||
| 1315 | |||||||||||||||||||||||||||||
| 1316 | =over 4 | ||||||||||||||||||||||||||||
| 1317 | |||||||||||||||||||||||||||||
| 1318 | =item blessed example 2 | ||||||||||||||||||||||||||||
| 1319 | |||||||||||||||||||||||||||||
| 1320 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1321 | |||||||||||||||||||||||||||||
| 1322 | package Foo::Bar; | ||||||||||||||||||||||||||||
| 1323 | |||||||||||||||||||||||||||||
| 1324 | sub import; | ||||||||||||||||||||||||||||
| 1325 | |||||||||||||||||||||||||||||
| 1326 | package main; | ||||||||||||||||||||||||||||
| 1327 | |||||||||||||||||||||||||||||
| 1328 | my $blessed = $space->blessed({okay => 1}); | ||||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||
| 1330 | # bless({ okay => 1 }, "Foo::Bar") | ||||||||||||||||||||||||||||
| 1331 | |||||||||||||||||||||||||||||
| 1332 | =back | ||||||||||||||||||||||||||||
| 1333 | |||||||||||||||||||||||||||||
| 1334 | =cut | ||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||
| 1336 | =head2 build | ||||||||||||||||||||||||||||
| 1337 | |||||||||||||||||||||||||||||
| 1338 | build(any @args) (Self) | ||||||||||||||||||||||||||||
| 1339 | |||||||||||||||||||||||||||||
| 1340 | The build method attempts to call C<new> on the package namespace and if | ||||||||||||||||||||||||||||
| 1341 | successful returns the resulting object. | ||||||||||||||||||||||||||||
| 1342 | |||||||||||||||||||||||||||||
| 1343 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||
| 1345 | =over 4 | ||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||
| 1347 | =item build example 1 | ||||||||||||||||||||||||||||
| 1348 | |||||||||||||||||||||||||||||
| 1349 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1350 | |||||||||||||||||||||||||||||
| 1351 | package Foo::Bar::Baz; | ||||||||||||||||||||||||||||
| 1352 | |||||||||||||||||||||||||||||
| 1353 | sub new { | ||||||||||||||||||||||||||||
| 1354 | bless {}, $_[0]; | ||||||||||||||||||||||||||||
| 1355 | } | ||||||||||||||||||||||||||||
| 1356 | |||||||||||||||||||||||||||||
| 1357 | package main; | ||||||||||||||||||||||||||||
| 1358 | |||||||||||||||||||||||||||||
| 1359 | my $build = $space->child('baz')->build; | ||||||||||||||||||||||||||||
| 1360 | |||||||||||||||||||||||||||||
| 1361 | # bless({}, "Foo::Bar::Baz") | ||||||||||||||||||||||||||||
| 1362 | |||||||||||||||||||||||||||||
| 1363 | =back | ||||||||||||||||||||||||||||
| 1364 | |||||||||||||||||||||||||||||
| 1365 | =over 4 | ||||||||||||||||||||||||||||
| 1366 | |||||||||||||||||||||||||||||
| 1367 | =item build example 2 | ||||||||||||||||||||||||||||
| 1368 | |||||||||||||||||||||||||||||
| 1369 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1370 | |||||||||||||||||||||||||||||
| 1371 | package Foo::Bar::Bax; | ||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||
| 1373 | sub new { | ||||||||||||||||||||||||||||
| 1374 | bless $_[1], $_[0]; | ||||||||||||||||||||||||||||
| 1375 | } | ||||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||
| 1377 | package main; | ||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||
| 1379 | my $build = $space->child('bax')->build({okay => 1}); | ||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||
| 1381 | # bless({ okay => 1 }, "Foo::Bar::Bax") | ||||||||||||||||||||||||||||
| 1382 | |||||||||||||||||||||||||||||
| 1383 | =back | ||||||||||||||||||||||||||||
| 1384 | |||||||||||||||||||||||||||||
| 1385 | =over 4 | ||||||||||||||||||||||||||||
| 1386 | |||||||||||||||||||||||||||||
| 1387 | =item build example 3 | ||||||||||||||||||||||||||||
| 1388 | |||||||||||||||||||||||||||||
| 1389 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||
| 1391 | package Foo::Bar::Bay; | ||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||
| 1393 | sub new { | ||||||||||||||||||||||||||||
| 1394 | bless $_[1], $_[0]; | ||||||||||||||||||||||||||||
| 1395 | } | ||||||||||||||||||||||||||||
| 1396 | |||||||||||||||||||||||||||||
| 1397 | package main; | ||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||
| 1399 | my $build = $space->child('bay')->build([okay => 1]); | ||||||||||||||||||||||||||||
| 1400 | |||||||||||||||||||||||||||||
| 1401 | # bless(["okay", 1], "Foo::Bar::Bay") | ||||||||||||||||||||||||||||
| 1402 | |||||||||||||||||||||||||||||
| 1403 | =back | ||||||||||||||||||||||||||||
| 1404 | |||||||||||||||||||||||||||||
| 1405 | =cut | ||||||||||||||||||||||||||||
| 1406 | |||||||||||||||||||||||||||||
| 1407 | =head2 call | ||||||||||||||||||||||||||||
| 1408 | |||||||||||||||||||||||||||||
| 1409 | call(any @args) (any) | ||||||||||||||||||||||||||||
| 1410 | |||||||||||||||||||||||||||||
| 1411 | The call method attempts to call the given subroutine on the package namespace | ||||||||||||||||||||||||||||
| 1412 | and if successful returns the resulting value. | ||||||||||||||||||||||||||||
| 1413 | |||||||||||||||||||||||||||||
| 1414 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||
| 1416 | =over 4 | ||||||||||||||||||||||||||||
| 1417 | |||||||||||||||||||||||||||||
| 1418 | =item call example 1 | ||||||||||||||||||||||||||||
| 1419 | |||||||||||||||||||||||||||||
| 1420 | package Foo; | ||||||||||||||||||||||||||||
| 1421 | |||||||||||||||||||||||||||||
| 1422 | sub import; | ||||||||||||||||||||||||||||
| 1423 | |||||||||||||||||||||||||||||
| 1424 | sub start { | ||||||||||||||||||||||||||||
| 1425 | 'started' | ||||||||||||||||||||||||||||
| 1426 | } | ||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||
| 1428 | package main; | ||||||||||||||||||||||||||||
| 1429 | |||||||||||||||||||||||||||||
| 1430 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||
| 1432 | my $space = Venus::Space->new('foo'); | ||||||||||||||||||||||||||||
| 1433 | |||||||||||||||||||||||||||||
| 1434 | my $result = $space->call('start'); | ||||||||||||||||||||||||||||
| 1435 | |||||||||||||||||||||||||||||
| 1436 | # "started" | ||||||||||||||||||||||||||||
| 1437 | |||||||||||||||||||||||||||||
| 1438 | =back | ||||||||||||||||||||||||||||
| 1439 | |||||||||||||||||||||||||||||
| 1440 | =over 4 | ||||||||||||||||||||||||||||
| 1441 | |||||||||||||||||||||||||||||
| 1442 | =item call example 2 | ||||||||||||||||||||||||||||
| 1443 | |||||||||||||||||||||||||||||
| 1444 | package Zoo; | ||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||
| 1446 | sub import; | ||||||||||||||||||||||||||||
| 1447 | |||||||||||||||||||||||||||||
| 1448 | sub AUTOLOAD { | ||||||||||||||||||||||||||||
| 1449 | bless {}; | ||||||||||||||||||||||||||||
| 1450 | } | ||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||
| 1452 | sub DESTROY { | ||||||||||||||||||||||||||||
| 1453 | ; # noop | ||||||||||||||||||||||||||||
| 1454 | } | ||||||||||||||||||||||||||||
| 1455 | |||||||||||||||||||||||||||||
| 1456 | package main; | ||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||
| 1458 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1459 | |||||||||||||||||||||||||||||
| 1460 | my $space = Venus::Space->new('zoo'); | ||||||||||||||||||||||||||||
| 1461 | |||||||||||||||||||||||||||||
| 1462 | my $result = $space->call('start'); | ||||||||||||||||||||||||||||
| 1463 | |||||||||||||||||||||||||||||
| 1464 | # bless({}, "Zoo") | ||||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||
| 1466 | =back | ||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||
| 1468 | =over 4 | ||||||||||||||||||||||||||||
| 1469 | |||||||||||||||||||||||||||||
| 1470 | =item call example 3 | ||||||||||||||||||||||||||||
| 1471 | |||||||||||||||||||||||||||||
| 1472 | package main; | ||||||||||||||||||||||||||||
| 1473 | |||||||||||||||||||||||||||||
| 1474 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1475 | |||||||||||||||||||||||||||||
| 1476 | my $space = Venus::Space->new('foo'); | ||||||||||||||||||||||||||||
| 1477 | |||||||||||||||||||||||||||||
| 1478 | my $result = $space->call('missing'); | ||||||||||||||||||||||||||||
| 1479 | |||||||||||||||||||||||||||||
| 1480 | # Exception! (isa Venus::Space::Error) (see error_on_call_missing) | ||||||||||||||||||||||||||||
| 1481 | |||||||||||||||||||||||||||||
| 1482 | =back | ||||||||||||||||||||||||||||
| 1483 | |||||||||||||||||||||||||||||
| 1484 | =cut | ||||||||||||||||||||||||||||
| 1485 | |||||||||||||||||||||||||||||
| 1486 | =head2 chain | ||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||
| 1488 | chain(string | tuple[string, any] @steps) (any) | ||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||
| 1490 | The chain method chains one or more method calls and returns the result. | ||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||
| 1492 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1493 | |||||||||||||||||||||||||||||
| 1494 | =over 4 | ||||||||||||||||||||||||||||
| 1495 | |||||||||||||||||||||||||||||
| 1496 | =item chain example 1 | ||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||
| 1498 | package Chu::Chu0; | ||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||
| 1500 | sub import; | ||||||||||||||||||||||||||||
| 1501 | |||||||||||||||||||||||||||||
| 1502 | package main; | ||||||||||||||||||||||||||||
| 1503 | |||||||||||||||||||||||||||||
| 1504 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||
| 1506 | my $space = Venus::Space->new('Chu::Chu0'); | ||||||||||||||||||||||||||||
| 1507 | |||||||||||||||||||||||||||||
| 1508 | my $result = $space->chain('blessed'); | ||||||||||||||||||||||||||||
| 1509 | |||||||||||||||||||||||||||||
| 1510 | # bless({}, "Chu::Chu0") | ||||||||||||||||||||||||||||
| 1511 | |||||||||||||||||||||||||||||
| 1512 | =back | ||||||||||||||||||||||||||||
| 1513 | |||||||||||||||||||||||||||||
| 1514 | =over 4 | ||||||||||||||||||||||||||||
| 1515 | |||||||||||||||||||||||||||||
| 1516 | =item chain example 2 | ||||||||||||||||||||||||||||
| 1517 | |||||||||||||||||||||||||||||
| 1518 | package Chu::Chu1; | ||||||||||||||||||||||||||||
| 1519 | |||||||||||||||||||||||||||||
| 1520 | sub new { | ||||||||||||||||||||||||||||
| 1521 | bless pop; | ||||||||||||||||||||||||||||
| 1522 | } | ||||||||||||||||||||||||||||
| 1523 | |||||||||||||||||||||||||||||
| 1524 | sub frame { | ||||||||||||||||||||||||||||
| 1525 | [@_] | ||||||||||||||||||||||||||||
| 1526 | } | ||||||||||||||||||||||||||||
| 1527 | |||||||||||||||||||||||||||||
| 1528 | package main; | ||||||||||||||||||||||||||||
| 1529 | |||||||||||||||||||||||||||||
| 1530 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1531 | |||||||||||||||||||||||||||||
| 1532 | my $space = Venus::Space->new('Chu::Chu1'); | ||||||||||||||||||||||||||||
| 1533 | |||||||||||||||||||||||||||||
| 1534 | my $result = $space->chain(['blessed', {1..4}], 'frame'); | ||||||||||||||||||||||||||||
| 1535 | |||||||||||||||||||||||||||||
| 1536 | # [bless({ 1 => 2, 3 => 4 }, "Chu::Chu1")] | ||||||||||||||||||||||||||||
| 1537 | |||||||||||||||||||||||||||||
| 1538 | =back | ||||||||||||||||||||||||||||
| 1539 | |||||||||||||||||||||||||||||
| 1540 | =over 4 | ||||||||||||||||||||||||||||
| 1541 | |||||||||||||||||||||||||||||
| 1542 | =item chain example 3 | ||||||||||||||||||||||||||||
| 1543 | |||||||||||||||||||||||||||||
| 1544 | package Chu::Chu2; | ||||||||||||||||||||||||||||
| 1545 | |||||||||||||||||||||||||||||
| 1546 | sub new { | ||||||||||||||||||||||||||||
| 1547 | bless pop; | ||||||||||||||||||||||||||||
| 1548 | } | ||||||||||||||||||||||||||||
| 1549 | |||||||||||||||||||||||||||||
| 1550 | sub frame { | ||||||||||||||||||||||||||||
| 1551 | [@_] | ||||||||||||||||||||||||||||
| 1552 | } | ||||||||||||||||||||||||||||
| 1553 | |||||||||||||||||||||||||||||
| 1554 | package main; | ||||||||||||||||||||||||||||
| 1555 | |||||||||||||||||||||||||||||
| 1556 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1557 | |||||||||||||||||||||||||||||
| 1558 | my $space = Venus::Space->new('Chu::Chu2'); | ||||||||||||||||||||||||||||
| 1559 | |||||||||||||||||||||||||||||
| 1560 | my $chain = $space->chain('blessed', ['frame', {1..4}]); | ||||||||||||||||||||||||||||
| 1561 | |||||||||||||||||||||||||||||
| 1562 | # [bless({}, "Chu::Chu2"), { 1 => 2, 3 => 4 }] | ||||||||||||||||||||||||||||
| 1563 | |||||||||||||||||||||||||||||
| 1564 | =back | ||||||||||||||||||||||||||||
| 1565 | |||||||||||||||||||||||||||||
| 1566 | =cut | ||||||||||||||||||||||||||||
| 1567 | |||||||||||||||||||||||||||||
| 1568 | =head2 child | ||||||||||||||||||||||||||||
| 1569 | |||||||||||||||||||||||||||||
| 1570 | child(string @path) (Venus::Space) | ||||||||||||||||||||||||||||
| 1571 | |||||||||||||||||||||||||||||
| 1572 | The child method returns a new L<Venus::Space> object for the child | ||||||||||||||||||||||||||||
| 1573 | package namespace. | ||||||||||||||||||||||||||||
| 1574 | |||||||||||||||||||||||||||||
| 1575 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1576 | |||||||||||||||||||||||||||||
| 1577 | =over 4 | ||||||||||||||||||||||||||||
| 1578 | |||||||||||||||||||||||||||||
| 1579 | =item child example 1 | ||||||||||||||||||||||||||||
| 1580 | |||||||||||||||||||||||||||||
| 1581 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1582 | |||||||||||||||||||||||||||||
| 1583 | my $child = $space->child('baz'); | ||||||||||||||||||||||||||||
| 1584 | |||||||||||||||||||||||||||||
| 1585 | # bless({ value => "Foo/Bar/Baz" }, "Venus::Space") | ||||||||||||||||||||||||||||
| 1586 | |||||||||||||||||||||||||||||
| 1587 | =back | ||||||||||||||||||||||||||||
| 1588 | |||||||||||||||||||||||||||||
| 1589 | =cut | ||||||||||||||||||||||||||||
| 1590 | |||||||||||||||||||||||||||||
| 1591 | =head2 children | ||||||||||||||||||||||||||||
| 1592 | |||||||||||||||||||||||||||||
| 1593 | children() (within[arrayref, object]) | ||||||||||||||||||||||||||||
| 1594 | |||||||||||||||||||||||||||||
| 1595 | The children method searches C<%INC> and C<@INC> and retuns a list of | ||||||||||||||||||||||||||||
| 1596 | L<Venus::Space> objects for each child namespace found (one level deep). | ||||||||||||||||||||||||||||
| 1597 | |||||||||||||||||||||||||||||
| 1598 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1599 | |||||||||||||||||||||||||||||
| 1600 | =over 4 | ||||||||||||||||||||||||||||
| 1601 | |||||||||||||||||||||||||||||
| 1602 | =item children example 1 | ||||||||||||||||||||||||||||
| 1603 | |||||||||||||||||||||||||||||
| 1604 | package main; | ||||||||||||||||||||||||||||
| 1605 | |||||||||||||||||||||||||||||
| 1606 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1607 | |||||||||||||||||||||||||||||
| 1608 | my $space = Venus::Space->new('c_p_a_n'); | ||||||||||||||||||||||||||||
| 1609 | |||||||||||||||||||||||||||||
| 1610 | my $children = $space->children; | ||||||||||||||||||||||||||||
| 1611 | |||||||||||||||||||||||||||||
| 1612 | # [ | ||||||||||||||||||||||||||||
| 1613 | # bless({ value => "CPAN/Author" }, "Venus::Space"), | ||||||||||||||||||||||||||||
| 1614 | # bless({ value => "CPAN/Bundle" }, "Venus::Space"), | ||||||||||||||||||||||||||||
| 1615 | # bless({ value => "CPAN/CacheMgr" }, "Venus::Space"), | ||||||||||||||||||||||||||||
| 1616 | # ... | ||||||||||||||||||||||||||||
| 1617 | # ] | ||||||||||||||||||||||||||||
| 1618 | |||||||||||||||||||||||||||||
| 1619 | =back | ||||||||||||||||||||||||||||
| 1620 | |||||||||||||||||||||||||||||
| 1621 | =cut | ||||||||||||||||||||||||||||
| 1622 | |||||||||||||||||||||||||||||
| 1623 | =head2 cop | ||||||||||||||||||||||||||||
| 1624 | |||||||||||||||||||||||||||||
| 1625 | cop(string $method, any @args) (coderef) | ||||||||||||||||||||||||||||
| 1626 | |||||||||||||||||||||||||||||
| 1627 | The cop method attempts to curry the given subroutine on the package namespace | ||||||||||||||||||||||||||||
| 1628 | and if successful returns a closure. This method supports dispatching, i.e. | ||||||||||||||||||||||||||||
| 1629 | providing a method name and arguments whose return value will be acted on by | ||||||||||||||||||||||||||||
| 1630 | this method. | ||||||||||||||||||||||||||||
| 1631 | |||||||||||||||||||||||||||||
| 1632 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1633 | |||||||||||||||||||||||||||||
| 1634 | =over 4 | ||||||||||||||||||||||||||||
| 1635 | |||||||||||||||||||||||||||||
| 1636 | =item cop example 1 | ||||||||||||||||||||||||||||
| 1637 | |||||||||||||||||||||||||||||
| 1638 | package Foo::Bar; | ||||||||||||||||||||||||||||
| 1639 | |||||||||||||||||||||||||||||
| 1640 | sub import; | ||||||||||||||||||||||||||||
| 1641 | |||||||||||||||||||||||||||||
| 1642 | sub handler { | ||||||||||||||||||||||||||||
| 1643 | [@_] | ||||||||||||||||||||||||||||
| 1644 | } | ||||||||||||||||||||||||||||
| 1645 | |||||||||||||||||||||||||||||
| 1646 | package main; | ||||||||||||||||||||||||||||
| 1647 | |||||||||||||||||||||||||||||
| 1648 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1649 | |||||||||||||||||||||||||||||
| 1650 | my $space = Venus::Space->new('foo/bar'); | ||||||||||||||||||||||||||||
| 1651 | |||||||||||||||||||||||||||||
| 1652 | my $code = $space->cop('handler', $space->blessed); | ||||||||||||||||||||||||||||
| 1653 | |||||||||||||||||||||||||||||
| 1654 | # sub { Foo::Bar::handler(..., @_) } | ||||||||||||||||||||||||||||
| 1655 | |||||||||||||||||||||||||||||
| 1656 | =back | ||||||||||||||||||||||||||||
| 1657 | |||||||||||||||||||||||||||||
| 1658 | =over 4 | ||||||||||||||||||||||||||||
| 1659 | |||||||||||||||||||||||||||||
| 1660 | =item cop example 2 | ||||||||||||||||||||||||||||
| 1661 | |||||||||||||||||||||||||||||
| 1662 | package main; | ||||||||||||||||||||||||||||
| 1663 | |||||||||||||||||||||||||||||
| 1664 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1665 | |||||||||||||||||||||||||||||
| 1666 | my $space = Venus::Space->new('foo/bar'); | ||||||||||||||||||||||||||||
| 1667 | |||||||||||||||||||||||||||||
| 1668 | my $code = $space->cop('missing', $space->blessed); | ||||||||||||||||||||||||||||
| 1669 | |||||||||||||||||||||||||||||
| 1670 | # Exception! (isa Venus::Space::Error) (see error_on_cop_missing) | ||||||||||||||||||||||||||||
| 1671 | |||||||||||||||||||||||||||||
| 1672 | =back | ||||||||||||||||||||||||||||
| 1673 | |||||||||||||||||||||||||||||
| 1674 | =cut | ||||||||||||||||||||||||||||
| 1675 | |||||||||||||||||||||||||||||
| 1676 | =head2 data | ||||||||||||||||||||||||||||
| 1677 | |||||||||||||||||||||||||||||
| 1678 | data() (string) | ||||||||||||||||||||||||||||
| 1679 | |||||||||||||||||||||||||||||
| 1680 | The data method attempts to read and return any content stored in the C<DATA> | ||||||||||||||||||||||||||||
| 1681 | section of the package namespace. | ||||||||||||||||||||||||||||
| 1682 | |||||||||||||||||||||||||||||
| 1683 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1684 | |||||||||||||||||||||||||||||
| 1685 | =over 4 | ||||||||||||||||||||||||||||
| 1686 | |||||||||||||||||||||||||||||
| 1687 | =item data example 1 | ||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||
| 1689 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1690 | |||||||||||||||||||||||||||||
| 1691 | my $data = $space->data; | ||||||||||||||||||||||||||||
| 1692 | |||||||||||||||||||||||||||||
| 1693 | # "" | ||||||||||||||||||||||||||||
| 1694 | |||||||||||||||||||||||||||||
| 1695 | =back | ||||||||||||||||||||||||||||
| 1696 | |||||||||||||||||||||||||||||
| 1697 | =cut | ||||||||||||||||||||||||||||
| 1698 | |||||||||||||||||||||||||||||
| 1699 | =head2 eval | ||||||||||||||||||||||||||||
| 1700 | |||||||||||||||||||||||||||||
| 1701 | eval(string @data) (any) | ||||||||||||||||||||||||||||
| 1702 | |||||||||||||||||||||||||||||
| 1703 | The eval method takes a list of strings and evaluates them under the namespace | ||||||||||||||||||||||||||||
| 1704 | represented by the instance. | ||||||||||||||||||||||||||||
| 1705 | |||||||||||||||||||||||||||||
| 1706 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1707 | |||||||||||||||||||||||||||||
| 1708 | =over 4 | ||||||||||||||||||||||||||||
| 1709 | |||||||||||||||||||||||||||||
| 1710 | =item eval example 1 | ||||||||||||||||||||||||||||
| 1711 | |||||||||||||||||||||||||||||
| 1712 | package main; | ||||||||||||||||||||||||||||
| 1713 | |||||||||||||||||||||||||||||
| 1714 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1715 | |||||||||||||||||||||||||||||
| 1716 | my $space = Venus::Space->new('foo'); | ||||||||||||||||||||||||||||
| 1717 | |||||||||||||||||||||||||||||
| 1718 | my $eval = $space->eval('our $VERSION = 0.01'); | ||||||||||||||||||||||||||||
| 1719 | |||||||||||||||||||||||||||||
| 1720 | # 0.01 | ||||||||||||||||||||||||||||
| 1721 | |||||||||||||||||||||||||||||
| 1722 | =back | ||||||||||||||||||||||||||||
| 1723 | |||||||||||||||||||||||||||||
| 1724 | =over 4 | ||||||||||||||||||||||||||||
| 1725 | |||||||||||||||||||||||||||||
| 1726 | =item eval example 2 | ||||||||||||||||||||||||||||
| 1727 | |||||||||||||||||||||||||||||
| 1728 | package main; | ||||||||||||||||||||||||||||
| 1729 | |||||||||||||||||||||||||||||
| 1730 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1731 | |||||||||||||||||||||||||||||
| 1732 | my $space = Venus::Space->new('foo'); | ||||||||||||||||||||||||||||
| 1733 | |||||||||||||||||||||||||||||
| 1734 | my $eval = $space->eval('die'); | ||||||||||||||||||||||||||||
| 1735 | |||||||||||||||||||||||||||||
| 1736 | # Exception! (isa Venus::Space::Error) (see error_on_eval) | ||||||||||||||||||||||||||||
| 1737 | |||||||||||||||||||||||||||||
| 1738 | =back | ||||||||||||||||||||||||||||
| 1739 | |||||||||||||||||||||||||||||
| 1740 | =cut | ||||||||||||||||||||||||||||
| 1741 | |||||||||||||||||||||||||||||
| 1742 | =head2 explain | ||||||||||||||||||||||||||||
| 1743 | |||||||||||||||||||||||||||||
| 1744 | explain() (string) | ||||||||||||||||||||||||||||
| 1745 | |||||||||||||||||||||||||||||
| 1746 | The explain method returns the package name and is used in stringification | ||||||||||||||||||||||||||||
| 1747 | operations. | ||||||||||||||||||||||||||||
| 1748 | |||||||||||||||||||||||||||||
| 1749 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1750 | |||||||||||||||||||||||||||||
| 1751 | =over 4 | ||||||||||||||||||||||||||||
| 1752 | |||||||||||||||||||||||||||||
| 1753 | =item explain example 1 | ||||||||||||||||||||||||||||
| 1754 | |||||||||||||||||||||||||||||
| 1755 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1756 | |||||||||||||||||||||||||||||
| 1757 | my $explain = $space->explain; | ||||||||||||||||||||||||||||
| 1758 | |||||||||||||||||||||||||||||
| 1759 | # "Foo::Bar" | ||||||||||||||||||||||||||||
| 1760 | |||||||||||||||||||||||||||||
| 1761 | =back | ||||||||||||||||||||||||||||
| 1762 | |||||||||||||||||||||||||||||
| 1763 | =cut | ||||||||||||||||||||||||||||
| 1764 | |||||||||||||||||||||||||||||
| 1765 | =head2 hash | ||||||||||||||||||||||||||||
| 1766 | |||||||||||||||||||||||||||||
| 1767 | hash(string $name, any @data) (hashref) | ||||||||||||||||||||||||||||
| 1768 | |||||||||||||||||||||||||||||
| 1769 | The hash method gets or sets the value for the given package hash variable name. | ||||||||||||||||||||||||||||
| 1770 | |||||||||||||||||||||||||||||
| 1771 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1772 | |||||||||||||||||||||||||||||
| 1773 | =over 4 | ||||||||||||||||||||||||||||
| 1774 | |||||||||||||||||||||||||||||
| 1775 | =item hash example 1 | ||||||||||||||||||||||||||||
| 1776 | |||||||||||||||||||||||||||||
| 1777 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1778 | |||||||||||||||||||||||||||||
| 1779 | package Foo::Bar; | ||||||||||||||||||||||||||||
| 1780 | |||||||||||||||||||||||||||||
| 1781 | our %settings = ( | ||||||||||||||||||||||||||||
| 1782 | active => 1 | ||||||||||||||||||||||||||||
| 1783 | ); | ||||||||||||||||||||||||||||
| 1784 | |||||||||||||||||||||||||||||
| 1785 | package main; | ||||||||||||||||||||||||||||
| 1786 | |||||||||||||||||||||||||||||
| 1787 | my $hash = $space->hash('settings'); | ||||||||||||||||||||||||||||
| 1788 | |||||||||||||||||||||||||||||
| 1789 | # { active => 1 } | ||||||||||||||||||||||||||||
| 1790 | |||||||||||||||||||||||||||||
| 1791 | =back | ||||||||||||||||||||||||||||
| 1792 | |||||||||||||||||||||||||||||
| 1793 | =over 4 | ||||||||||||||||||||||||||||
| 1794 | |||||||||||||||||||||||||||||
| 1795 | =item hash example 2 | ||||||||||||||||||||||||||||
| 1796 | |||||||||||||||||||||||||||||
| 1797 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1798 | |||||||||||||||||||||||||||||
| 1799 | package Foo::Bar; | ||||||||||||||||||||||||||||
| 1800 | |||||||||||||||||||||||||||||
| 1801 | our %settings = ( | ||||||||||||||||||||||||||||
| 1802 | active => 1 | ||||||||||||||||||||||||||||
| 1803 | ); | ||||||||||||||||||||||||||||
| 1804 | |||||||||||||||||||||||||||||
| 1805 | package main; | ||||||||||||||||||||||||||||
| 1806 | |||||||||||||||||||||||||||||
| 1807 | my $hash = $space->hash('settings', inactive => 1); | ||||||||||||||||||||||||||||
| 1808 | |||||||||||||||||||||||||||||
| 1809 | # { inactive => 1 } | ||||||||||||||||||||||||||||
| 1810 | |||||||||||||||||||||||||||||
| 1811 | =back | ||||||||||||||||||||||||||||
| 1812 | |||||||||||||||||||||||||||||
| 1813 | =cut | ||||||||||||||||||||||||||||
| 1814 | |||||||||||||||||||||||||||||
| 1815 | =head2 hashes | ||||||||||||||||||||||||||||
| 1816 | |||||||||||||||||||||||||||||
| 1817 | hashes() (arrayref) | ||||||||||||||||||||||||||||
| 1818 | |||||||||||||||||||||||||||||
| 1819 | The hashes method searches the package namespace for hashes and returns their | ||||||||||||||||||||||||||||
| 1820 | names. | ||||||||||||||||||||||||||||
| 1821 | |||||||||||||||||||||||||||||
| 1822 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1823 | |||||||||||||||||||||||||||||
| 1824 | =over 4 | ||||||||||||||||||||||||||||
| 1825 | |||||||||||||||||||||||||||||
| 1826 | =item hashes example 1 | ||||||||||||||||||||||||||||
| 1827 | |||||||||||||||||||||||||||||
| 1828 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1829 | |||||||||||||||||||||||||||||
| 1830 | package Foo::Bar; | ||||||||||||||||||||||||||||
| 1831 | |||||||||||||||||||||||||||||
| 1832 | our %defaults = ( | ||||||||||||||||||||||||||||
| 1833 | active => 0 | ||||||||||||||||||||||||||||
| 1834 | ); | ||||||||||||||||||||||||||||
| 1835 | |||||||||||||||||||||||||||||
| 1836 | our %settings = ( | ||||||||||||||||||||||||||||
| 1837 | active => 1 | ||||||||||||||||||||||||||||
| 1838 | ); | ||||||||||||||||||||||||||||
| 1839 | |||||||||||||||||||||||||||||
| 1840 | package main; | ||||||||||||||||||||||||||||
| 1841 | |||||||||||||||||||||||||||||
| 1842 | my $hashes = $space->hashes; | ||||||||||||||||||||||||||||
| 1843 | |||||||||||||||||||||||||||||
| 1844 | # ["defaults", "settings"] | ||||||||||||||||||||||||||||
| 1845 | |||||||||||||||||||||||||||||
| 1846 | =back | ||||||||||||||||||||||||||||
| 1847 | |||||||||||||||||||||||||||||
| 1848 | =cut | ||||||||||||||||||||||||||||
| 1849 | |||||||||||||||||||||||||||||
| 1850 | =head2 id | ||||||||||||||||||||||||||||
| 1851 | |||||||||||||||||||||||||||||
| 1852 | id() (string) | ||||||||||||||||||||||||||||
| 1853 | |||||||||||||||||||||||||||||
| 1854 | The id method returns the fully-qualified package name as a label. | ||||||||||||||||||||||||||||
| 1855 | |||||||||||||||||||||||||||||
| 1856 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1857 | |||||||||||||||||||||||||||||
| 1858 | =over 4 | ||||||||||||||||||||||||||||
| 1859 | |||||||||||||||||||||||||||||
| 1860 | =item id example 1 | ||||||||||||||||||||||||||||
| 1861 | |||||||||||||||||||||||||||||
| 1862 | # given: synopsis; | ||||||||||||||||||||||||||||
| 1863 | |||||||||||||||||||||||||||||
| 1864 | my $id = $space->id; | ||||||||||||||||||||||||||||
| 1865 | |||||||||||||||||||||||||||||
| 1866 | # "Foo_Bar" | ||||||||||||||||||||||||||||
| 1867 | |||||||||||||||||||||||||||||
| 1868 | =back | ||||||||||||||||||||||||||||
| 1869 | |||||||||||||||||||||||||||||
| 1870 | =cut | ||||||||||||||||||||||||||||
| 1871 | |||||||||||||||||||||||||||||
| 1872 | =head2 included | ||||||||||||||||||||||||||||
| 1873 | |||||||||||||||||||||||||||||
| 1874 | included() (string | undef) | ||||||||||||||||||||||||||||
| 1875 | |||||||||||||||||||||||||||||
| 1876 | The included method returns the path of the namespace if it exists in C<%INC>. | ||||||||||||||||||||||||||||
| 1877 | |||||||||||||||||||||||||||||
| 1878 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1879 | |||||||||||||||||||||||||||||
| 1880 | =over 4 | ||||||||||||||||||||||||||||
| 1881 | |||||||||||||||||||||||||||||
| 1882 | =item included example 1 | ||||||||||||||||||||||||||||
| 1883 | |||||||||||||||||||||||||||||
| 1884 | package main; | ||||||||||||||||||||||||||||
| 1885 | |||||||||||||||||||||||||||||
| 1886 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1887 | |||||||||||||||||||||||||||||
| 1888 | my $space = Venus::Space->new('Venus/Space'); | ||||||||||||||||||||||||||||
| 1889 | |||||||||||||||||||||||||||||
| 1890 | my $included = $space->included; | ||||||||||||||||||||||||||||
| 1891 | |||||||||||||||||||||||||||||
| 1892 | # "/path/to/lib/Venus/Space.pm" | ||||||||||||||||||||||||||||
| 1893 | |||||||||||||||||||||||||||||
| 1894 | =back | ||||||||||||||||||||||||||||
| 1895 | |||||||||||||||||||||||||||||
| 1896 | =cut | ||||||||||||||||||||||||||||
| 1897 | |||||||||||||||||||||||||||||
| 1898 | =head2 inherits | ||||||||||||||||||||||||||||
| 1899 | |||||||||||||||||||||||||||||
| 1900 | inherits() (arrayref) | ||||||||||||||||||||||||||||
| 1901 | |||||||||||||||||||||||||||||
| 1902 | The inherits method returns the list of superclasses the target package is | ||||||||||||||||||||||||||||
| 1903 | derived from. | ||||||||||||||||||||||||||||
| 1904 | |||||||||||||||||||||||||||||
| 1905 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1906 | |||||||||||||||||||||||||||||
| 1907 | =over 4 | ||||||||||||||||||||||||||||
| 1908 | |||||||||||||||||||||||||||||
| 1909 | =item inherits example 1 | ||||||||||||||||||||||||||||
| 1910 | |||||||||||||||||||||||||||||
| 1911 | package Bar; | ||||||||||||||||||||||||||||
| 1912 | |||||||||||||||||||||||||||||
| 1913 | package main; | ||||||||||||||||||||||||||||
| 1914 | |||||||||||||||||||||||||||||
| 1915 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1916 | |||||||||||||||||||||||||||||
| 1917 | my $space = Venus::Space->new('bar'); | ||||||||||||||||||||||||||||
| 1918 | |||||||||||||||||||||||||||||
| 1919 | my $inherits = $space->inherits; | ||||||||||||||||||||||||||||
| 1920 | |||||||||||||||||||||||||||||
| 1921 | # [] | ||||||||||||||||||||||||||||
| 1922 | |||||||||||||||||||||||||||||
| 1923 | =back | ||||||||||||||||||||||||||||
| 1924 | |||||||||||||||||||||||||||||
| 1925 | =over 4 | ||||||||||||||||||||||||||||
| 1926 | |||||||||||||||||||||||||||||
| 1927 | =item inherits example 2 | ||||||||||||||||||||||||||||
| 1928 | |||||||||||||||||||||||||||||
| 1929 | package Foo; | ||||||||||||||||||||||||||||
| 1930 | |||||||||||||||||||||||||||||
| 1931 | sub import; | ||||||||||||||||||||||||||||
| 1932 | |||||||||||||||||||||||||||||
| 1933 | package Bar; | ||||||||||||||||||||||||||||
| 1934 | |||||||||||||||||||||||||||||
| 1935 | use base 'Foo'; | ||||||||||||||||||||||||||||
| 1936 | |||||||||||||||||||||||||||||
| 1937 | package main; | ||||||||||||||||||||||||||||
| 1938 | |||||||||||||||||||||||||||||
| 1939 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1940 | |||||||||||||||||||||||||||||
| 1941 | my $space = Venus::Space->new('bar'); | ||||||||||||||||||||||||||||
| 1942 | |||||||||||||||||||||||||||||
| 1943 | my $inherits = $space->inherits; | ||||||||||||||||||||||||||||
| 1944 | |||||||||||||||||||||||||||||
| 1945 | # ["Foo"] | ||||||||||||||||||||||||||||
| 1946 | |||||||||||||||||||||||||||||
| 1947 | =back | ||||||||||||||||||||||||||||
| 1948 | |||||||||||||||||||||||||||||
| 1949 | =cut | ||||||||||||||||||||||||||||
| 1950 | |||||||||||||||||||||||||||||
| 1951 | =head2 init | ||||||||||||||||||||||||||||
| 1952 | |||||||||||||||||||||||||||||
| 1953 | init() (string) | ||||||||||||||||||||||||||||
| 1954 | |||||||||||||||||||||||||||||
| 1955 | The init method ensures that the package namespace is loaded and, whether | ||||||||||||||||||||||||||||
| 1956 | created in-memory or on-disk, is flagged as being loaded and loadable. | ||||||||||||||||||||||||||||
| 1957 | |||||||||||||||||||||||||||||
| 1958 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1959 | |||||||||||||||||||||||||||||
| 1960 | =over 4 | ||||||||||||||||||||||||||||
| 1961 | |||||||||||||||||||||||||||||
| 1962 | =item init example 1 | ||||||||||||||||||||||||||||
| 1963 | |||||||||||||||||||||||||||||
| 1964 | package main; | ||||||||||||||||||||||||||||
| 1965 | |||||||||||||||||||||||||||||
| 1966 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1967 | |||||||||||||||||||||||||||||
| 1968 | my $space = Venus::Space->new('kit'); | ||||||||||||||||||||||||||||
| 1969 | |||||||||||||||||||||||||||||
| 1970 | my $init = $space->init; | ||||||||||||||||||||||||||||
| 1971 | |||||||||||||||||||||||||||||
| 1972 | # "Kit" | ||||||||||||||||||||||||||||
| 1973 | |||||||||||||||||||||||||||||
| 1974 | =back | ||||||||||||||||||||||||||||
| 1975 | |||||||||||||||||||||||||||||
| 1976 | =cut | ||||||||||||||||||||||||||||
| 1977 | |||||||||||||||||||||||||||||
| 1978 | =head2 inject | ||||||||||||||||||||||||||||
| 1979 | |||||||||||||||||||||||||||||
| 1980 | inject(string $name, maybe[coderef] $coderef) (any) | ||||||||||||||||||||||||||||
| 1981 | |||||||||||||||||||||||||||||
| 1982 | The inject method monkey-patches the package namespace, installing a named | ||||||||||||||||||||||||||||
| 1983 | subroutine into the package which can then be called normally, returning the | ||||||||||||||||||||||||||||
| 1984 | fully-qualified subroutine name. | ||||||||||||||||||||||||||||
| 1985 | |||||||||||||||||||||||||||||
| 1986 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 1987 | |||||||||||||||||||||||||||||
| 1988 | =over 4 | ||||||||||||||||||||||||||||
| 1989 | |||||||||||||||||||||||||||||
| 1990 | =item inject example 1 | ||||||||||||||||||||||||||||
| 1991 | |||||||||||||||||||||||||||||
| 1992 | package main; | ||||||||||||||||||||||||||||
| 1993 | |||||||||||||||||||||||||||||
| 1994 | use Venus::Space; | ||||||||||||||||||||||||||||
| 1995 | |||||||||||||||||||||||||||||
| 1996 | my $space = Venus::Space->new('kit'); | ||||||||||||||||||||||||||||
| 1997 | |||||||||||||||||||||||||||||
| 1998 | my $inject = $space->inject('build', sub { 'finished' }); | ||||||||||||||||||||||||||||
| 1999 | |||||||||||||||||||||||||||||
| 2000 | # *Kit::build | ||||||||||||||||||||||||||||
| 2001 | |||||||||||||||||||||||||||||
| 2002 | =back | ||||||||||||||||||||||||||||
| 2003 | |||||||||||||||||||||||||||||
| 2004 | =cut | ||||||||||||||||||||||||||||
| 2005 | |||||||||||||||||||||||||||||
| 2006 | =head2 integrates | ||||||||||||||||||||||||||||
| 2007 | |||||||||||||||||||||||||||||
| 2008 | integrates() (arrayref) | ||||||||||||||||||||||||||||
| 2009 | |||||||||||||||||||||||||||||
| 2010 | The integrates method returns the list of roles integrated into the target | ||||||||||||||||||||||||||||
| 2011 | package. | ||||||||||||||||||||||||||||
| 2012 | |||||||||||||||||||||||||||||
| 2013 | I<Since C<1.30>> | ||||||||||||||||||||||||||||
| 2014 | |||||||||||||||||||||||||||||
| 2015 | =over 4 | ||||||||||||||||||||||||||||
| 2016 | |||||||||||||||||||||||||||||
| 2017 | =item integrates example 1 | ||||||||||||||||||||||||||||
| 2018 | |||||||||||||||||||||||||||||
| 2019 | # given: synopsis | ||||||||||||||||||||||||||||
| 2020 | |||||||||||||||||||||||||||||
| 2021 | package main; | ||||||||||||||||||||||||||||
| 2022 | |||||||||||||||||||||||||||||
| 2023 | my $integrates = $space->integrates; | ||||||||||||||||||||||||||||
| 2024 | |||||||||||||||||||||||||||||
| 2025 | # [] | ||||||||||||||||||||||||||||
| 2026 | |||||||||||||||||||||||||||||
| 2027 | =back | ||||||||||||||||||||||||||||
| 2028 | |||||||||||||||||||||||||||||
| 2029 | =over 4 | ||||||||||||||||||||||||||||
| 2030 | |||||||||||||||||||||||||||||
| 2031 | =item integrates example 2 | ||||||||||||||||||||||||||||
| 2032 | |||||||||||||||||||||||||||||
| 2033 | package main; | ||||||||||||||||||||||||||||
| 2034 | |||||||||||||||||||||||||||||
| 2035 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2036 | |||||||||||||||||||||||||||||
| 2037 | my $space = Venus::Space->new('Venus::Test'); | ||||||||||||||||||||||||||||
| 2038 | |||||||||||||||||||||||||||||
| 2039 | my $integrates = $space->integrates; | ||||||||||||||||||||||||||||
| 2040 | |||||||||||||||||||||||||||||
| 2041 | # [...] | ||||||||||||||||||||||||||||
| 2042 | |||||||||||||||||||||||||||||
| 2043 | =back | ||||||||||||||||||||||||||||
| 2044 | |||||||||||||||||||||||||||||
| 2045 | =cut | ||||||||||||||||||||||||||||
| 2046 | |||||||||||||||||||||||||||||
| 2047 | =head2 lfile | ||||||||||||||||||||||||||||
| 2048 | |||||||||||||||||||||||||||||
| 2049 | lfile() (string) | ||||||||||||||||||||||||||||
| 2050 | |||||||||||||||||||||||||||||
| 2051 | The lfile method returns a C<.pm> file path for the underlying package. | ||||||||||||||||||||||||||||
| 2052 | |||||||||||||||||||||||||||||
| 2053 | I<Since C<1.30>> | ||||||||||||||||||||||||||||
| 2054 | |||||||||||||||||||||||||||||
| 2055 | =over 4 | ||||||||||||||||||||||||||||
| 2056 | |||||||||||||||||||||||||||||
| 2057 | =item lfile example 1 | ||||||||||||||||||||||||||||
| 2058 | |||||||||||||||||||||||||||||
| 2059 | # given: synopsis | ||||||||||||||||||||||||||||
| 2060 | |||||||||||||||||||||||||||||
| 2061 | package main; | ||||||||||||||||||||||||||||
| 2062 | |||||||||||||||||||||||||||||
| 2063 | my $lfile = $space->lfile; | ||||||||||||||||||||||||||||
| 2064 | |||||||||||||||||||||||||||||
| 2065 | # "Foo/Bar.pm" | ||||||||||||||||||||||||||||
| 2066 | |||||||||||||||||||||||||||||
| 2067 | =back | ||||||||||||||||||||||||||||
| 2068 | |||||||||||||||||||||||||||||
| 2069 | =cut | ||||||||||||||||||||||||||||
| 2070 | |||||||||||||||||||||||||||||
| 2071 | =head2 load | ||||||||||||||||||||||||||||
| 2072 | |||||||||||||||||||||||||||||
| 2073 | load() (string) | ||||||||||||||||||||||||||||
| 2074 | |||||||||||||||||||||||||||||
| 2075 | The load method checks whether the package namespace is already loaded and if | ||||||||||||||||||||||||||||
| 2076 | not attempts to load the package. If the package is not loaded and is not | ||||||||||||||||||||||||||||
| 2077 | loadable, this method will throw an exception using confess. If the package is | ||||||||||||||||||||||||||||
| 2078 | loadable, this method returns truthy with the package name. As a workaround for | ||||||||||||||||||||||||||||
| 2079 | packages that only exist in-memory, if the package contains a C<new>, C<with>, | ||||||||||||||||||||||||||||
| 2080 | C<meta>, or C<import> routine it will be recognized as having been loaded. | ||||||||||||||||||||||||||||
| 2081 | |||||||||||||||||||||||||||||
| 2082 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2083 | |||||||||||||||||||||||||||||
| 2084 | =over 4 | ||||||||||||||||||||||||||||
| 2085 | |||||||||||||||||||||||||||||
| 2086 | =item load example 1 | ||||||||||||||||||||||||||||
| 2087 | |||||||||||||||||||||||||||||
| 2088 | package main; | ||||||||||||||||||||||||||||
| 2089 | |||||||||||||||||||||||||||||
| 2090 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2091 | |||||||||||||||||||||||||||||
| 2092 | my $space = Venus::Space->new('c_p_a_n'); | ||||||||||||||||||||||||||||
| 2093 | |||||||||||||||||||||||||||||
| 2094 | my $load = $space->load; | ||||||||||||||||||||||||||||
| 2095 | |||||||||||||||||||||||||||||
| 2096 | # "CPAN" | ||||||||||||||||||||||||||||
| 2097 | |||||||||||||||||||||||||||||
| 2098 | =back | ||||||||||||||||||||||||||||
| 2099 | |||||||||||||||||||||||||||||
| 2100 | =over 4 | ||||||||||||||||||||||||||||
| 2101 | |||||||||||||||||||||||||||||
| 2102 | =item load example 2 | ||||||||||||||||||||||||||||
| 2103 | |||||||||||||||||||||||||||||
| 2104 | package main; | ||||||||||||||||||||||||||||
| 2105 | |||||||||||||||||||||||||||||
| 2106 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2107 | |||||||||||||||||||||||||||||
| 2108 | my $space = Venus::Space->new('no/thing'); | ||||||||||||||||||||||||||||
| 2109 | |||||||||||||||||||||||||||||
| 2110 | my $load = $space->load; | ||||||||||||||||||||||||||||
| 2111 | |||||||||||||||||||||||||||||
| 2112 | # Exception! (isa Venus::Space::Error) (see error_on_load) | ||||||||||||||||||||||||||||
| 2113 | |||||||||||||||||||||||||||||
| 2114 | =back | ||||||||||||||||||||||||||||
| 2115 | |||||||||||||||||||||||||||||
| 2116 | =cut | ||||||||||||||||||||||||||||
| 2117 | |||||||||||||||||||||||||||||
| 2118 | =head2 loaded | ||||||||||||||||||||||||||||
| 2119 | |||||||||||||||||||||||||||||
| 2120 | loaded() (boolean) | ||||||||||||||||||||||||||||
| 2121 | |||||||||||||||||||||||||||||
| 2122 | The loaded method checks whether the package namespace is already loaded and | ||||||||||||||||||||||||||||
| 2123 | returns truthy or falsy. | ||||||||||||||||||||||||||||
| 2124 | |||||||||||||||||||||||||||||
| 2125 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2126 | |||||||||||||||||||||||||||||
| 2127 | =over 4 | ||||||||||||||||||||||||||||
| 2128 | |||||||||||||||||||||||||||||
| 2129 | =item loaded example 1 | ||||||||||||||||||||||||||||
| 2130 | |||||||||||||||||||||||||||||
| 2131 | package main; | ||||||||||||||||||||||||||||
| 2132 | |||||||||||||||||||||||||||||
| 2133 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2134 | |||||||||||||||||||||||||||||
| 2135 | my $space = Venus::Space->new('Kit'); | ||||||||||||||||||||||||||||
| 2136 | |||||||||||||||||||||||||||||
| 2137 | $space->init; | ||||||||||||||||||||||||||||
| 2138 | |||||||||||||||||||||||||||||
| 2139 | $space->unload; | ||||||||||||||||||||||||||||
| 2140 | |||||||||||||||||||||||||||||
| 2141 | my $loaded = $space->loaded; | ||||||||||||||||||||||||||||
| 2142 | |||||||||||||||||||||||||||||
| 2143 | # 0 | ||||||||||||||||||||||||||||
| 2144 | |||||||||||||||||||||||||||||
| 2145 | =back | ||||||||||||||||||||||||||||
| 2146 | |||||||||||||||||||||||||||||
| 2147 | =over 4 | ||||||||||||||||||||||||||||
| 2148 | |||||||||||||||||||||||||||||
| 2149 | =item loaded example 2 | ||||||||||||||||||||||||||||
| 2150 | |||||||||||||||||||||||||||||
| 2151 | package main; | ||||||||||||||||||||||||||||
| 2152 | |||||||||||||||||||||||||||||
| 2153 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2154 | |||||||||||||||||||||||||||||
| 2155 | my $space = Venus::Space->new('Kit'); | ||||||||||||||||||||||||||||
| 2156 | |||||||||||||||||||||||||||||
| 2157 | $space->init; | ||||||||||||||||||||||||||||
| 2158 | |||||||||||||||||||||||||||||
| 2159 | my $loaded = $space->loaded; | ||||||||||||||||||||||||||||
| 2160 | |||||||||||||||||||||||||||||
| 2161 | # 1 | ||||||||||||||||||||||||||||
| 2162 | |||||||||||||||||||||||||||||
| 2163 | =back | ||||||||||||||||||||||||||||
| 2164 | |||||||||||||||||||||||||||||
| 2165 | =cut | ||||||||||||||||||||||||||||
| 2166 | |||||||||||||||||||||||||||||
| 2167 | =head2 locate | ||||||||||||||||||||||||||||
| 2168 | |||||||||||||||||||||||||||||
| 2169 | locate() (string) | ||||||||||||||||||||||||||||
| 2170 | |||||||||||||||||||||||||||||
| 2171 | The locate method checks whether the package namespace is available in | ||||||||||||||||||||||||||||
| 2172 | C<@INC>, i.e. on disk. This method returns the file if found or an empty | ||||||||||||||||||||||||||||
| 2173 | string. | ||||||||||||||||||||||||||||
| 2174 | |||||||||||||||||||||||||||||
| 2175 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2176 | |||||||||||||||||||||||||||||
| 2177 | =over 4 | ||||||||||||||||||||||||||||
| 2178 | |||||||||||||||||||||||||||||
| 2179 | =item locate example 1 | ||||||||||||||||||||||||||||
| 2180 | |||||||||||||||||||||||||||||
| 2181 | package main; | ||||||||||||||||||||||||||||
| 2182 | |||||||||||||||||||||||||||||
| 2183 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2184 | |||||||||||||||||||||||||||||
| 2185 | my $space = Venus::Space->new('xyz'); | ||||||||||||||||||||||||||||
| 2186 | |||||||||||||||||||||||||||||
| 2187 | my $locate = $space->locate; | ||||||||||||||||||||||||||||
| 2188 | |||||||||||||||||||||||||||||
| 2189 | # "" | ||||||||||||||||||||||||||||
| 2190 | |||||||||||||||||||||||||||||
| 2191 | =back | ||||||||||||||||||||||||||||
| 2192 | |||||||||||||||||||||||||||||
| 2193 | =over 4 | ||||||||||||||||||||||||||||
| 2194 | |||||||||||||||||||||||||||||
| 2195 | =item locate example 2 | ||||||||||||||||||||||||||||
| 2196 | |||||||||||||||||||||||||||||
| 2197 | package main; | ||||||||||||||||||||||||||||
| 2198 | |||||||||||||||||||||||||||||
| 2199 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2200 | |||||||||||||||||||||||||||||
| 2201 | my $space = Venus::Space->new('data/dumper'); | ||||||||||||||||||||||||||||
| 2202 | |||||||||||||||||||||||||||||
| 2203 | $space->load; | ||||||||||||||||||||||||||||
| 2204 | |||||||||||||||||||||||||||||
| 2205 | my $locate = $space->locate; | ||||||||||||||||||||||||||||
| 2206 | |||||||||||||||||||||||||||||
| 2207 | # "/path/to/lib/Data/Dumper.pm" | ||||||||||||||||||||||||||||
| 2208 | |||||||||||||||||||||||||||||
| 2209 | =back | ||||||||||||||||||||||||||||
| 2210 | |||||||||||||||||||||||||||||
| 2211 | =cut | ||||||||||||||||||||||||||||
| 2212 | |||||||||||||||||||||||||||||
| 2213 | =head2 meta | ||||||||||||||||||||||||||||
| 2214 | |||||||||||||||||||||||||||||
| 2215 | meta() (Venus::Meta) | ||||||||||||||||||||||||||||
| 2216 | |||||||||||||||||||||||||||||
| 2217 | The meta method returns a L<Venus::Meta> object representing the underlying | ||||||||||||||||||||||||||||
| 2218 | package namespace. To access the meta object for the instance itself, use the | ||||||||||||||||||||||||||||
| 2219 | superclass' L<Venus::Core/META> method. | ||||||||||||||||||||||||||||
| 2220 | |||||||||||||||||||||||||||||
| 2221 | I<Since C<1.02>> | ||||||||||||||||||||||||||||
| 2222 | |||||||||||||||||||||||||||||
| 2223 | =over 4 | ||||||||||||||||||||||||||||
| 2224 | |||||||||||||||||||||||||||||
| 2225 | =item meta example 1 | ||||||||||||||||||||||||||||
| 2226 | |||||||||||||||||||||||||||||
| 2227 | # given: synopsis | ||||||||||||||||||||||||||||
| 2228 | |||||||||||||||||||||||||||||
| 2229 | package main; | ||||||||||||||||||||||||||||
| 2230 | |||||||||||||||||||||||||||||
| 2231 | my $meta = $space->meta; | ||||||||||||||||||||||||||||
| 2232 | |||||||||||||||||||||||||||||
| 2233 | # bless({'name' => 'Foo::Bar'}, 'Venus::Meta') | ||||||||||||||||||||||||||||
| 2234 | |||||||||||||||||||||||||||||
| 2235 | =back | ||||||||||||||||||||||||||||
| 2236 | |||||||||||||||||||||||||||||
| 2237 | =over 4 | ||||||||||||||||||||||||||||
| 2238 | |||||||||||||||||||||||||||||
| 2239 | =item meta example 2 | ||||||||||||||||||||||||||||
| 2240 | |||||||||||||||||||||||||||||
| 2241 | # given: synopsis | ||||||||||||||||||||||||||||
| 2242 | |||||||||||||||||||||||||||||
| 2243 | package main; | ||||||||||||||||||||||||||||
| 2244 | |||||||||||||||||||||||||||||
| 2245 | my $meta = $space->META; | ||||||||||||||||||||||||||||
| 2246 | |||||||||||||||||||||||||||||
| 2247 | # bless({'name' => 'Venus::Space'}, 'Venus::Meta') | ||||||||||||||||||||||||||||
| 2248 | |||||||||||||||||||||||||||||
| 2249 | =back | ||||||||||||||||||||||||||||
| 2250 | |||||||||||||||||||||||||||||
| 2251 | =cut | ||||||||||||||||||||||||||||
| 2252 | |||||||||||||||||||||||||||||
| 2253 | =head2 mock | ||||||||||||||||||||||||||||
| 2254 | |||||||||||||||||||||||||||||
| 2255 | mock() (Venus::Space) | ||||||||||||||||||||||||||||
| 2256 | |||||||||||||||||||||||||||||
| 2257 | The mock method returns a L<Venus::Space> object representing an anonymous | ||||||||||||||||||||||||||||
| 2258 | package that derives from the invoking package. | ||||||||||||||||||||||||||||
| 2259 | |||||||||||||||||||||||||||||
| 2260 | I<Since C<1.50>> | ||||||||||||||||||||||||||||
| 2261 | |||||||||||||||||||||||||||||
| 2262 | =over 4 | ||||||||||||||||||||||||||||
| 2263 | |||||||||||||||||||||||||||||
| 2264 | =item mock example 1 | ||||||||||||||||||||||||||||
| 2265 | |||||||||||||||||||||||||||||
| 2266 | # given: synopsis | ||||||||||||||||||||||||||||
| 2267 | |||||||||||||||||||||||||||||
| 2268 | package main; | ||||||||||||||||||||||||||||
| 2269 | |||||||||||||||||||||||||||||
| 2270 | my $mock = $space->mock; | ||||||||||||||||||||||||||||
| 2271 | |||||||||||||||||||||||||||||
| 2272 | # bless({'name' => 'Venus::Space::Mock::0001::Foo::Bar'}, 'Venus::Space') | ||||||||||||||||||||||||||||
| 2273 | |||||||||||||||||||||||||||||
| 2274 | # $mock->isa('Foo::Bar') # true | ||||||||||||||||||||||||||||
| 2275 | |||||||||||||||||||||||||||||
| 2276 | =back | ||||||||||||||||||||||||||||
| 2277 | |||||||||||||||||||||||||||||
| 2278 | =cut | ||||||||||||||||||||||||||||
| 2279 | |||||||||||||||||||||||||||||
| 2280 | =head2 name | ||||||||||||||||||||||||||||
| 2281 | |||||||||||||||||||||||||||||
| 2282 | name() (string) | ||||||||||||||||||||||||||||
| 2283 | |||||||||||||||||||||||||||||
| 2284 | The name method returns the fully-qualified package name. | ||||||||||||||||||||||||||||
| 2285 | |||||||||||||||||||||||||||||
| 2286 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2287 | |||||||||||||||||||||||||||||
| 2288 | =over 4 | ||||||||||||||||||||||||||||
| 2289 | |||||||||||||||||||||||||||||
| 2290 | =item name example 1 | ||||||||||||||||||||||||||||
| 2291 | |||||||||||||||||||||||||||||
| 2292 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2293 | |||||||||||||||||||||||||||||
| 2294 | my $name = $space->name; | ||||||||||||||||||||||||||||
| 2295 | |||||||||||||||||||||||||||||
| 2296 | # "Foo::Bar" | ||||||||||||||||||||||||||||
| 2297 | |||||||||||||||||||||||||||||
| 2298 | =back | ||||||||||||||||||||||||||||
| 2299 | |||||||||||||||||||||||||||||
| 2300 | =cut | ||||||||||||||||||||||||||||
| 2301 | |||||||||||||||||||||||||||||
| 2302 | =head2 parent | ||||||||||||||||||||||||||||
| 2303 | |||||||||||||||||||||||||||||
| 2304 | parent() (Venus::Space) | ||||||||||||||||||||||||||||
| 2305 | |||||||||||||||||||||||||||||
| 2306 | The parent method returns a new L<Venus::Space> object for the parent package | ||||||||||||||||||||||||||||
| 2307 | namespace. | ||||||||||||||||||||||||||||
| 2308 | |||||||||||||||||||||||||||||
| 2309 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2310 | |||||||||||||||||||||||||||||
| 2311 | =over 4 | ||||||||||||||||||||||||||||
| 2312 | |||||||||||||||||||||||||||||
| 2313 | =item parent example 1 | ||||||||||||||||||||||||||||
| 2314 | |||||||||||||||||||||||||||||
| 2315 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2316 | |||||||||||||||||||||||||||||
| 2317 | my $parent = $space->parent; | ||||||||||||||||||||||||||||
| 2318 | |||||||||||||||||||||||||||||
| 2319 | # bless({ value => "Foo" }, "Venus::Space") | ||||||||||||||||||||||||||||
| 2320 | |||||||||||||||||||||||||||||
| 2321 | =back | ||||||||||||||||||||||||||||
| 2322 | |||||||||||||||||||||||||||||
| 2323 | =cut | ||||||||||||||||||||||||||||
| 2324 | |||||||||||||||||||||||||||||
| 2325 | =head2 parse | ||||||||||||||||||||||||||||
| 2326 | |||||||||||||||||||||||||||||
| 2327 | parse() (arrayref) | ||||||||||||||||||||||||||||
| 2328 | |||||||||||||||||||||||||||||
| 2329 | The parse method parses the string argument and returns an arrayref of package | ||||||||||||||||||||||||||||
| 2330 | namespace segments (parts). | ||||||||||||||||||||||||||||
| 2331 | |||||||||||||||||||||||||||||
| 2332 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2333 | |||||||||||||||||||||||||||||
| 2334 | =over 4 | ||||||||||||||||||||||||||||
| 2335 | |||||||||||||||||||||||||||||
| 2336 | =item parse example 1 | ||||||||||||||||||||||||||||
| 2337 | |||||||||||||||||||||||||||||
| 2338 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2339 | |||||||||||||||||||||||||||||
| 2340 | my $parse = $space->parse; | ||||||||||||||||||||||||||||
| 2341 | |||||||||||||||||||||||||||||
| 2342 | # ["Foo", "Bar"] | ||||||||||||||||||||||||||||
| 2343 | |||||||||||||||||||||||||||||
| 2344 | =back | ||||||||||||||||||||||||||||
| 2345 | |||||||||||||||||||||||||||||
| 2346 | =over 4 | ||||||||||||||||||||||||||||
| 2347 | |||||||||||||||||||||||||||||
| 2348 | =item parse example 2 | ||||||||||||||||||||||||||||
| 2349 | |||||||||||||||||||||||||||||
| 2350 | package main; | ||||||||||||||||||||||||||||
| 2351 | |||||||||||||||||||||||||||||
| 2352 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2353 | |||||||||||||||||||||||||||||
| 2354 | my $space = Venus::Space->new('Foo/Bar'); | ||||||||||||||||||||||||||||
| 2355 | |||||||||||||||||||||||||||||
| 2356 | my $parse = $space->parse; | ||||||||||||||||||||||||||||
| 2357 | |||||||||||||||||||||||||||||
| 2358 | # ["Foo", "Bar"] | ||||||||||||||||||||||||||||
| 2359 | |||||||||||||||||||||||||||||
| 2360 | =back | ||||||||||||||||||||||||||||
| 2361 | |||||||||||||||||||||||||||||
| 2362 | =over 4 | ||||||||||||||||||||||||||||
| 2363 | |||||||||||||||||||||||||||||
| 2364 | =item parse example 3 | ||||||||||||||||||||||||||||
| 2365 | |||||||||||||||||||||||||||||
| 2366 | package main; | ||||||||||||||||||||||||||||
| 2367 | |||||||||||||||||||||||||||||
| 2368 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2369 | |||||||||||||||||||||||||||||
| 2370 | my $space = Venus::Space->new('Foo\Bar'); | ||||||||||||||||||||||||||||
| 2371 | |||||||||||||||||||||||||||||
| 2372 | my $parse = $space->parse; | ||||||||||||||||||||||||||||
| 2373 | |||||||||||||||||||||||||||||
| 2374 | # ["Foo", "Bar"] | ||||||||||||||||||||||||||||
| 2375 | |||||||||||||||||||||||||||||
| 2376 | =back | ||||||||||||||||||||||||||||
| 2377 | |||||||||||||||||||||||||||||
| 2378 | =over 4 | ||||||||||||||||||||||||||||
| 2379 | |||||||||||||||||||||||||||||
| 2380 | =item parse example 4 | ||||||||||||||||||||||||||||
| 2381 | |||||||||||||||||||||||||||||
| 2382 | package main; | ||||||||||||||||||||||||||||
| 2383 | |||||||||||||||||||||||||||||
| 2384 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2385 | |||||||||||||||||||||||||||||
| 2386 | my $space = Venus::Space->new('Foo-Bar'); | ||||||||||||||||||||||||||||
| 2387 | |||||||||||||||||||||||||||||
| 2388 | my $parse = $space->parse; | ||||||||||||||||||||||||||||
| 2389 | |||||||||||||||||||||||||||||
| 2390 | # ["FooBar"] | ||||||||||||||||||||||||||||
| 2391 | |||||||||||||||||||||||||||||
| 2392 | =back | ||||||||||||||||||||||||||||
| 2393 | |||||||||||||||||||||||||||||
| 2394 | =over 4 | ||||||||||||||||||||||||||||
| 2395 | |||||||||||||||||||||||||||||
| 2396 | =item parse example 5 | ||||||||||||||||||||||||||||
| 2397 | |||||||||||||||||||||||||||||
| 2398 | package main; | ||||||||||||||||||||||||||||
| 2399 | |||||||||||||||||||||||||||||
| 2400 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2401 | |||||||||||||||||||||||||||||
| 2402 | my $space = Venus::Space->new('Foo_Bar'); | ||||||||||||||||||||||||||||
| 2403 | |||||||||||||||||||||||||||||
| 2404 | my $parse = $space->parse; | ||||||||||||||||||||||||||||
| 2405 | |||||||||||||||||||||||||||||
| 2406 | # ["FooBar"] | ||||||||||||||||||||||||||||
| 2407 | |||||||||||||||||||||||||||||
| 2408 | =back | ||||||||||||||||||||||||||||
| 2409 | |||||||||||||||||||||||||||||
| 2410 | =cut | ||||||||||||||||||||||||||||
| 2411 | |||||||||||||||||||||||||||||
| 2412 | =head2 parts | ||||||||||||||||||||||||||||
| 2413 | |||||||||||||||||||||||||||||
| 2414 | parts() (arrayref) | ||||||||||||||||||||||||||||
| 2415 | |||||||||||||||||||||||||||||
| 2416 | The parts method returns an arrayref of package namespace segments (parts). | ||||||||||||||||||||||||||||
| 2417 | |||||||||||||||||||||||||||||
| 2418 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2419 | |||||||||||||||||||||||||||||
| 2420 | =over 4 | ||||||||||||||||||||||||||||
| 2421 | |||||||||||||||||||||||||||||
| 2422 | =item parts example 1 | ||||||||||||||||||||||||||||
| 2423 | |||||||||||||||||||||||||||||
| 2424 | package main; | ||||||||||||||||||||||||||||
| 2425 | |||||||||||||||||||||||||||||
| 2426 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2427 | |||||||||||||||||||||||||||||
| 2428 | my $space = Venus::Space->new('Foo'); | ||||||||||||||||||||||||||||
| 2429 | |||||||||||||||||||||||||||||
| 2430 | my $parts = $space->parts; | ||||||||||||||||||||||||||||
| 2431 | |||||||||||||||||||||||||||||
| 2432 | # ["Foo"] | ||||||||||||||||||||||||||||
| 2433 | |||||||||||||||||||||||||||||
| 2434 | =back | ||||||||||||||||||||||||||||
| 2435 | |||||||||||||||||||||||||||||
| 2436 | =over 4 | ||||||||||||||||||||||||||||
| 2437 | |||||||||||||||||||||||||||||
| 2438 | =item parts example 2 | ||||||||||||||||||||||||||||
| 2439 | |||||||||||||||||||||||||||||
| 2440 | package main; | ||||||||||||||||||||||||||||
| 2441 | |||||||||||||||||||||||||||||
| 2442 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2443 | |||||||||||||||||||||||||||||
| 2444 | my $space = Venus::Space->new('Foo/Bar'); | ||||||||||||||||||||||||||||
| 2445 | |||||||||||||||||||||||||||||
| 2446 | my $parts = $space->parts; | ||||||||||||||||||||||||||||
| 2447 | |||||||||||||||||||||||||||||
| 2448 | # ["Foo", "Bar"] | ||||||||||||||||||||||||||||
| 2449 | |||||||||||||||||||||||||||||
| 2450 | =back | ||||||||||||||||||||||||||||
| 2451 | |||||||||||||||||||||||||||||
| 2452 | =over 4 | ||||||||||||||||||||||||||||
| 2453 | |||||||||||||||||||||||||||||
| 2454 | =item parts example 3 | ||||||||||||||||||||||||||||
| 2455 | |||||||||||||||||||||||||||||
| 2456 | package main; | ||||||||||||||||||||||||||||
| 2457 | |||||||||||||||||||||||||||||
| 2458 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2459 | |||||||||||||||||||||||||||||
| 2460 | my $space = Venus::Space->new('Foo_Bar'); | ||||||||||||||||||||||||||||
| 2461 | |||||||||||||||||||||||||||||
| 2462 | my $parts = $space->parts; | ||||||||||||||||||||||||||||
| 2463 | |||||||||||||||||||||||||||||
| 2464 | # ["FooBar"] | ||||||||||||||||||||||||||||
| 2465 | |||||||||||||||||||||||||||||
| 2466 | =back | ||||||||||||||||||||||||||||
| 2467 | |||||||||||||||||||||||||||||
| 2468 | =cut | ||||||||||||||||||||||||||||
| 2469 | |||||||||||||||||||||||||||||
| 2470 | =head2 patch | ||||||||||||||||||||||||||||
| 2471 | |||||||||||||||||||||||||||||
| 2472 | patch(string $name, coderef $code) (Venus::Space) | ||||||||||||||||||||||||||||
| 2473 | |||||||||||||||||||||||||||||
| 2474 | The patch method overwrites the named subroutine in the underlying package | ||||||||||||||||||||||||||||
| 2475 | using the L</swap> operation, stashing the original subroutine reference to be | ||||||||||||||||||||||||||||
| 2476 | reset later using L</unpatch>. | ||||||||||||||||||||||||||||
| 2477 | |||||||||||||||||||||||||||||
| 2478 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2479 | |||||||||||||||||||||||||||||
| 2480 | =over 4 | ||||||||||||||||||||||||||||
| 2481 | |||||||||||||||||||||||||||||
| 2482 | =item patch example 1 | ||||||||||||||||||||||||||||
| 2483 | |||||||||||||||||||||||||||||
| 2484 | package Foo::Far; | ||||||||||||||||||||||||||||
| 2485 | |||||||||||||||||||||||||||||
| 2486 | use Venus::Class; | ||||||||||||||||||||||||||||
| 2487 | |||||||||||||||||||||||||||||
| 2488 | sub execute { | ||||||||||||||||||||||||||||
| 2489 | 1 | ||||||||||||||||||||||||||||
| 2490 | } | ||||||||||||||||||||||||||||
| 2491 | |||||||||||||||||||||||||||||
| 2492 | package main; | ||||||||||||||||||||||||||||
| 2493 | |||||||||||||||||||||||||||||
| 2494 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2495 | |||||||||||||||||||||||||||||
| 2496 | my $space = Venus::Space->new('foo/far'); | ||||||||||||||||||||||||||||
| 2497 | |||||||||||||||||||||||||||||
| 2498 | my $patch = $space->patch('execute', sub { | ||||||||||||||||||||||||||||
| 2499 | $_[0]->() + 1 | ||||||||||||||||||||||||||||
| 2500 | }); | ||||||||||||||||||||||||||||
| 2501 | |||||||||||||||||||||||||||||
| 2502 | # bless(..., "Venus::Space") | ||||||||||||||||||||||||||||
| 2503 | |||||||||||||||||||||||||||||
| 2504 | # $patch->patched; | ||||||||||||||||||||||||||||
| 2505 | |||||||||||||||||||||||||||||
| 2506 | # true | ||||||||||||||||||||||||||||
| 2507 | |||||||||||||||||||||||||||||
| 2508 | # Foo::Far->new->execute; | ||||||||||||||||||||||||||||
| 2509 | |||||||||||||||||||||||||||||
| 2510 | # 2 | ||||||||||||||||||||||||||||
| 2511 | |||||||||||||||||||||||||||||
| 2512 | =back | ||||||||||||||||||||||||||||
| 2513 | |||||||||||||||||||||||||||||
| 2514 | =cut | ||||||||||||||||||||||||||||
| 2515 | |||||||||||||||||||||||||||||
| 2516 | =head2 patched | ||||||||||||||||||||||||||||
| 2517 | |||||||||||||||||||||||||||||
| 2518 | patched(string $name) (boolean) | ||||||||||||||||||||||||||||
| 2519 | |||||||||||||||||||||||||||||
| 2520 | The patched method confirms whether a subroutine in the underlying namespace | ||||||||||||||||||||||||||||
| 2521 | has been patched using the L</patch> operation. If no name is provided, this | ||||||||||||||||||||||||||||
| 2522 | method will return true if any subroutines have been patched. If a name is | ||||||||||||||||||||||||||||
| 2523 | provided, this method will return true only if the named subroutine has been | ||||||||||||||||||||||||||||
| 2524 | patched, and otherwise returns false. | ||||||||||||||||||||||||||||
| 2525 | |||||||||||||||||||||||||||||
| 2526 | I<Since C<3.55>> | ||||||||||||||||||||||||||||
| 2527 | |||||||||||||||||||||||||||||
| 2528 | =over 4 | ||||||||||||||||||||||||||||
| 2529 | |||||||||||||||||||||||||||||
| 2530 | =item patched example 1 | ||||||||||||||||||||||||||||
| 2531 | |||||||||||||||||||||||||||||
| 2532 | package Foo::Far; | ||||||||||||||||||||||||||||
| 2533 | |||||||||||||||||||||||||||||
| 2534 | use Venus::Class; | ||||||||||||||||||||||||||||
| 2535 | |||||||||||||||||||||||||||||
| 2536 | sub execute { | ||||||||||||||||||||||||||||
| 2537 | 1 | ||||||||||||||||||||||||||||
| 2538 | } | ||||||||||||||||||||||||||||
| 2539 | |||||||||||||||||||||||||||||
| 2540 | package main; | ||||||||||||||||||||||||||||
| 2541 | |||||||||||||||||||||||||||||
| 2542 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2543 | |||||||||||||||||||||||||||||
| 2544 | my $space = Venus::Space->new('foo/far'); | ||||||||||||||||||||||||||||
| 2545 | |||||||||||||||||||||||||||||
| 2546 | $space->patch('execute', sub { | ||||||||||||||||||||||||||||
| 2547 | $_[0]->() + 1 | ||||||||||||||||||||||||||||
| 2548 | }); | ||||||||||||||||||||||||||||
| 2549 | |||||||||||||||||||||||||||||
| 2550 | my $patched = $space->patched; | ||||||||||||||||||||||||||||
| 2551 | |||||||||||||||||||||||||||||
| 2552 | # true | ||||||||||||||||||||||||||||
| 2553 | |||||||||||||||||||||||||||||
| 2554 | =back | ||||||||||||||||||||||||||||
| 2555 | |||||||||||||||||||||||||||||
| 2556 | =over 4 | ||||||||||||||||||||||||||||
| 2557 | |||||||||||||||||||||||||||||
| 2558 | =item patched example 2 | ||||||||||||||||||||||||||||
| 2559 | |||||||||||||||||||||||||||||
| 2560 | package Foo::Far; | ||||||||||||||||||||||||||||
| 2561 | |||||||||||||||||||||||||||||
| 2562 | use Venus::Class; | ||||||||||||||||||||||||||||
| 2563 | |||||||||||||||||||||||||||||
| 2564 | sub execute { | ||||||||||||||||||||||||||||
| 2565 | 1 | ||||||||||||||||||||||||||||
| 2566 | } | ||||||||||||||||||||||||||||
| 2567 | |||||||||||||||||||||||||||||
| 2568 | package main; | ||||||||||||||||||||||||||||
| 2569 | |||||||||||||||||||||||||||||
| 2570 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2571 | |||||||||||||||||||||||||||||
| 2572 | my $space = Venus::Space->new('foo/far'); | ||||||||||||||||||||||||||||
| 2573 | |||||||||||||||||||||||||||||
| 2574 | $space->patch('execute', sub { | ||||||||||||||||||||||||||||
| 2575 | $_[0]->() + 1 | ||||||||||||||||||||||||||||
| 2576 | }); | ||||||||||||||||||||||||||||
| 2577 | |||||||||||||||||||||||||||||
| 2578 | my $patched = $space->patched('execute'); | ||||||||||||||||||||||||||||
| 2579 | |||||||||||||||||||||||||||||
| 2580 | # true | ||||||||||||||||||||||||||||
| 2581 | |||||||||||||||||||||||||||||
| 2582 | =back | ||||||||||||||||||||||||||||
| 2583 | |||||||||||||||||||||||||||||
| 2584 | =over 4 | ||||||||||||||||||||||||||||
| 2585 | |||||||||||||||||||||||||||||
| 2586 | =item patched example 3 | ||||||||||||||||||||||||||||
| 2587 | |||||||||||||||||||||||||||||
| 2588 | package Foo::Far; | ||||||||||||||||||||||||||||
| 2589 | |||||||||||||||||||||||||||||
| 2590 | use Venus::Class; | ||||||||||||||||||||||||||||
| 2591 | |||||||||||||||||||||||||||||
| 2592 | sub execute { | ||||||||||||||||||||||||||||
| 2593 | 1 | ||||||||||||||||||||||||||||
| 2594 | } | ||||||||||||||||||||||||||||
| 2595 | |||||||||||||||||||||||||||||
| 2596 | package main; | ||||||||||||||||||||||||||||
| 2597 | |||||||||||||||||||||||||||||
| 2598 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2599 | |||||||||||||||||||||||||||||
| 2600 | my $space = Venus::Space->new('foo/far'); | ||||||||||||||||||||||||||||
| 2601 | |||||||||||||||||||||||||||||
| 2602 | $space->patch('execute', sub { | ||||||||||||||||||||||||||||
| 2603 | $_[0]->() + 1 | ||||||||||||||||||||||||||||
| 2604 | }); | ||||||||||||||||||||||||||||
| 2605 | |||||||||||||||||||||||||||||
| 2606 | my $patched = $space->patched('prepare'); | ||||||||||||||||||||||||||||
| 2607 | |||||||||||||||||||||||||||||
| 2608 | # false | ||||||||||||||||||||||||||||
| 2609 | |||||||||||||||||||||||||||||
| 2610 | =back | ||||||||||||||||||||||||||||
| 2611 | |||||||||||||||||||||||||||||
| 2612 | =cut | ||||||||||||||||||||||||||||
| 2613 | |||||||||||||||||||||||||||||
| 2614 | =head2 pfile | ||||||||||||||||||||||||||||
| 2615 | |||||||||||||||||||||||||||||
| 2616 | pfile() (string) | ||||||||||||||||||||||||||||
| 2617 | |||||||||||||||||||||||||||||
| 2618 | The pfile method returns a C<.pod> file path for the underlying package. | ||||||||||||||||||||||||||||
| 2619 | |||||||||||||||||||||||||||||
| 2620 | I<Since C<1.30>> | ||||||||||||||||||||||||||||
| 2621 | |||||||||||||||||||||||||||||
| 2622 | =over 4 | ||||||||||||||||||||||||||||
| 2623 | |||||||||||||||||||||||||||||
| 2624 | =item pfile example 1 | ||||||||||||||||||||||||||||
| 2625 | |||||||||||||||||||||||||||||
| 2626 | # given: synopsis | ||||||||||||||||||||||||||||
| 2627 | |||||||||||||||||||||||||||||
| 2628 | package main; | ||||||||||||||||||||||||||||
| 2629 | |||||||||||||||||||||||||||||
| 2630 | my $pfile = $space->pfile; | ||||||||||||||||||||||||||||
| 2631 | |||||||||||||||||||||||||||||
| 2632 | # "Foo/Bar.pod" | ||||||||||||||||||||||||||||
| 2633 | |||||||||||||||||||||||||||||
| 2634 | =back | ||||||||||||||||||||||||||||
| 2635 | |||||||||||||||||||||||||||||
| 2636 | =cut | ||||||||||||||||||||||||||||
| 2637 | |||||||||||||||||||||||||||||
| 2638 | =head2 prepend | ||||||||||||||||||||||||||||
| 2639 | |||||||||||||||||||||||||||||
| 2640 | prepend(string @path) (Venus::Space) | ||||||||||||||||||||||||||||
| 2641 | |||||||||||||||||||||||||||||
| 2642 | The prepend method modifies the object by prepending to the package namespace | ||||||||||||||||||||||||||||
| 2643 | parts. | ||||||||||||||||||||||||||||
| 2644 | |||||||||||||||||||||||||||||
| 2645 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2646 | |||||||||||||||||||||||||||||
| 2647 | =over 4 | ||||||||||||||||||||||||||||
| 2648 | |||||||||||||||||||||||||||||
| 2649 | =item prepend example 1 | ||||||||||||||||||||||||||||
| 2650 | |||||||||||||||||||||||||||||
| 2651 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2652 | |||||||||||||||||||||||||||||
| 2653 | my $prepend = $space->prepend('etc'); | ||||||||||||||||||||||||||||
| 2654 | |||||||||||||||||||||||||||||
| 2655 | # bless({ value => "Etc/Foo/Bar" }, "Venus::Space") | ||||||||||||||||||||||||||||
| 2656 | |||||||||||||||||||||||||||||
| 2657 | =back | ||||||||||||||||||||||||||||
| 2658 | |||||||||||||||||||||||||||||
| 2659 | =over 4 | ||||||||||||||||||||||||||||
| 2660 | |||||||||||||||||||||||||||||
| 2661 | =item prepend example 2 | ||||||||||||||||||||||||||||
| 2662 | |||||||||||||||||||||||||||||
| 2663 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2664 | |||||||||||||||||||||||||||||
| 2665 | my $prepend = $space->prepend('etc', 'tmp'); | ||||||||||||||||||||||||||||
| 2666 | |||||||||||||||||||||||||||||
| 2667 | # bless({ value => "Etc/Tmp/Foo/Bar" }, "Venus::Space") | ||||||||||||||||||||||||||||
| 2668 | |||||||||||||||||||||||||||||
| 2669 | =back | ||||||||||||||||||||||||||||
| 2670 | |||||||||||||||||||||||||||||
| 2671 | =cut | ||||||||||||||||||||||||||||
| 2672 | |||||||||||||||||||||||||||||
| 2673 | =head2 purge | ||||||||||||||||||||||||||||
| 2674 | |||||||||||||||||||||||||||||
| 2675 | purge() (Self) | ||||||||||||||||||||||||||||
| 2676 | |||||||||||||||||||||||||||||
| 2677 | The purge method purges a package space by expunging its symbol table and | ||||||||||||||||||||||||||||
| 2678 | removing it from C<%INC>. | ||||||||||||||||||||||||||||
| 2679 | |||||||||||||||||||||||||||||
| 2680 | I<Since C<1.02>> | ||||||||||||||||||||||||||||
| 2681 | |||||||||||||||||||||||||||||
| 2682 | =over 4 | ||||||||||||||||||||||||||||
| 2683 | |||||||||||||||||||||||||||||
| 2684 | =item purge example 1 | ||||||||||||||||||||||||||||
| 2685 | |||||||||||||||||||||||||||||
| 2686 | package main; | ||||||||||||||||||||||||||||
| 2687 | |||||||||||||||||||||||||||||
| 2688 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2689 | |||||||||||||||||||||||||||||
| 2690 | # Bar::Gen is generated with $VERSION as 0.01 | ||||||||||||||||||||||||||||
| 2691 | |||||||||||||||||||||||||||||
| 2692 | my $space = Venus::Space->new('Bar/Gen'); | ||||||||||||||||||||||||||||
| 2693 | |||||||||||||||||||||||||||||
| 2694 | $space->load; | ||||||||||||||||||||||||||||
| 2695 | |||||||||||||||||||||||||||||
| 2696 | my $purge = $space->purge; | ||||||||||||||||||||||||||||
| 2697 | |||||||||||||||||||||||||||||
| 2698 | # bless({ value => "Bar::Gen" }, "Venus::Space") | ||||||||||||||||||||||||||||
| 2699 | |||||||||||||||||||||||||||||
| 2700 | # Bar::Gen->VERSION was 0.01, now undef | ||||||||||||||||||||||||||||
| 2701 | |||||||||||||||||||||||||||||
| 2702 | # Symbol table is gone, $space->visible is 0 | ||||||||||||||||||||||||||||
| 2703 | |||||||||||||||||||||||||||||
| 2704 | =back | ||||||||||||||||||||||||||||
| 2705 | |||||||||||||||||||||||||||||
| 2706 | =cut | ||||||||||||||||||||||||||||
| 2707 | |||||||||||||||||||||||||||||
| 2708 | =head2 rebase | ||||||||||||||||||||||||||||
| 2709 | |||||||||||||||||||||||||||||
| 2710 | rebase(string @path) (Venus::Space) | ||||||||||||||||||||||||||||
| 2711 | |||||||||||||||||||||||||||||
| 2712 | The rebase method returns an object by prepending the package namespace | ||||||||||||||||||||||||||||
| 2713 | specified to the base of the current object's namespace. | ||||||||||||||||||||||||||||
| 2714 | |||||||||||||||||||||||||||||
| 2715 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2716 | |||||||||||||||||||||||||||||
| 2717 | =over 4 | ||||||||||||||||||||||||||||
| 2718 | |||||||||||||||||||||||||||||
| 2719 | =item rebase example 1 | ||||||||||||||||||||||||||||
| 2720 | |||||||||||||||||||||||||||||
| 2721 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2722 | |||||||||||||||||||||||||||||
| 2723 | my $rebase = $space->rebase('zoo'); | ||||||||||||||||||||||||||||
| 2724 | |||||||||||||||||||||||||||||
| 2725 | # bless({ value => "Zoo/Bar" }, "Venus::Space") | ||||||||||||||||||||||||||||
| 2726 | |||||||||||||||||||||||||||||
| 2727 | =back | ||||||||||||||||||||||||||||
| 2728 | |||||||||||||||||||||||||||||
| 2729 | =cut | ||||||||||||||||||||||||||||
| 2730 | |||||||||||||||||||||||||||||
| 2731 | =head2 reload | ||||||||||||||||||||||||||||
| 2732 | |||||||||||||||||||||||||||||
| 2733 | reload() (string) | ||||||||||||||||||||||||||||
| 2734 | |||||||||||||||||||||||||||||
| 2735 | The reload method attempts to delete and reload the package namespace using the | ||||||||||||||||||||||||||||
| 2736 | L</load> method. B<Note:> Reloading is additive and will overwrite existing | ||||||||||||||||||||||||||||
| 2737 | symbols but does not remove symbols. | ||||||||||||||||||||||||||||
| 2738 | |||||||||||||||||||||||||||||
| 2739 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2740 | |||||||||||||||||||||||||||||
| 2741 | =over 4 | ||||||||||||||||||||||||||||
| 2742 | |||||||||||||||||||||||||||||
| 2743 | =item reload example 1 | ||||||||||||||||||||||||||||
| 2744 | |||||||||||||||||||||||||||||
| 2745 | package main; | ||||||||||||||||||||||||||||
| 2746 | |||||||||||||||||||||||||||||
| 2747 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2748 | |||||||||||||||||||||||||||||
| 2749 | # Foo::Gen is generated with $VERSION as 0.01 | ||||||||||||||||||||||||||||
| 2750 | |||||||||||||||||||||||||||||
| 2751 | my $space = Venus::Space->new('Foo/Gen'); | ||||||||||||||||||||||||||||
| 2752 | |||||||||||||||||||||||||||||
| 2753 | my $reload = $space->reload; | ||||||||||||||||||||||||||||
| 2754 | |||||||||||||||||||||||||||||
| 2755 | # Foo::Gen | ||||||||||||||||||||||||||||
| 2756 | # Foo::Gen->VERSION is 0.01 | ||||||||||||||||||||||||||||
| 2757 | |||||||||||||||||||||||||||||
| 2758 | =back | ||||||||||||||||||||||||||||
| 2759 | |||||||||||||||||||||||||||||
| 2760 | =over 4 | ||||||||||||||||||||||||||||
| 2761 | |||||||||||||||||||||||||||||
| 2762 | =item reload example 2 | ||||||||||||||||||||||||||||
| 2763 | |||||||||||||||||||||||||||||
| 2764 | package main; | ||||||||||||||||||||||||||||
| 2765 | |||||||||||||||||||||||||||||
| 2766 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2767 | |||||||||||||||||||||||||||||
| 2768 | # Foo::Gen is generated with $VERSION as 0.02 | ||||||||||||||||||||||||||||
| 2769 | |||||||||||||||||||||||||||||
| 2770 | my $space = Venus::Space->new('Foo/Gen'); | ||||||||||||||||||||||||||||
| 2771 | |||||||||||||||||||||||||||||
| 2772 | my $reload = $space->reload; | ||||||||||||||||||||||||||||
| 2773 | |||||||||||||||||||||||||||||
| 2774 | # Foo::Gen | ||||||||||||||||||||||||||||
| 2775 | # Foo::Gen->VERSION is 0.02 | ||||||||||||||||||||||||||||
| 2776 | |||||||||||||||||||||||||||||
| 2777 | =back | ||||||||||||||||||||||||||||
| 2778 | |||||||||||||||||||||||||||||
| 2779 | =cut | ||||||||||||||||||||||||||||
| 2780 | |||||||||||||||||||||||||||||
| 2781 | =head2 require | ||||||||||||||||||||||||||||
| 2782 | |||||||||||||||||||||||||||||
| 2783 | require(string $target) (any) | ||||||||||||||||||||||||||||
| 2784 | |||||||||||||||||||||||||||||
| 2785 | The require method executes a C<require> statement within the package namespace | ||||||||||||||||||||||||||||
| 2786 | specified. | ||||||||||||||||||||||||||||
| 2787 | |||||||||||||||||||||||||||||
| 2788 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2789 | |||||||||||||||||||||||||||||
| 2790 | =over 4 | ||||||||||||||||||||||||||||
| 2791 | |||||||||||||||||||||||||||||
| 2792 | =item require example 1 | ||||||||||||||||||||||||||||
| 2793 | |||||||||||||||||||||||||||||
| 2794 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2795 | |||||||||||||||||||||||||||||
| 2796 | my $require = $space->require('Venus'); | ||||||||||||||||||||||||||||
| 2797 | |||||||||||||||||||||||||||||
| 2798 | # 1 | ||||||||||||||||||||||||||||
| 2799 | |||||||||||||||||||||||||||||
| 2800 | =back | ||||||||||||||||||||||||||||
| 2801 | |||||||||||||||||||||||||||||
| 2802 | =cut | ||||||||||||||||||||||||||||
| 2803 | |||||||||||||||||||||||||||||
| 2804 | =head2 root | ||||||||||||||||||||||||||||
| 2805 | |||||||||||||||||||||||||||||
| 2806 | root() (string) | ||||||||||||||||||||||||||||
| 2807 | |||||||||||||||||||||||||||||
| 2808 | The root method returns the root package namespace segments (parts). Sometimes | ||||||||||||||||||||||||||||
| 2809 | separating the C<root> from the C<parts> helps identify how subsequent child | ||||||||||||||||||||||||||||
| 2810 | objects were derived. | ||||||||||||||||||||||||||||
| 2811 | |||||||||||||||||||||||||||||
| 2812 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2813 | |||||||||||||||||||||||||||||
| 2814 | =over 4 | ||||||||||||||||||||||||||||
| 2815 | |||||||||||||||||||||||||||||
| 2816 | =item root example 1 | ||||||||||||||||||||||||||||
| 2817 | |||||||||||||||||||||||||||||
| 2818 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2819 | |||||||||||||||||||||||||||||
| 2820 | my $root = $space->root; | ||||||||||||||||||||||||||||
| 2821 | |||||||||||||||||||||||||||||
| 2822 | # "Foo" | ||||||||||||||||||||||||||||
| 2823 | |||||||||||||||||||||||||||||
| 2824 | =back | ||||||||||||||||||||||||||||
| 2825 | |||||||||||||||||||||||||||||
| 2826 | =cut | ||||||||||||||||||||||||||||
| 2827 | |||||||||||||||||||||||||||||
| 2828 | =head2 routine | ||||||||||||||||||||||||||||
| 2829 | |||||||||||||||||||||||||||||
| 2830 | routine(string $name, coderef $code) (coderef) | ||||||||||||||||||||||||||||
| 2831 | |||||||||||||||||||||||||||||
| 2832 | The routine method gets or sets the subroutine reference for the given subroutine | ||||||||||||||||||||||||||||
| 2833 | name. | ||||||||||||||||||||||||||||
| 2834 | |||||||||||||||||||||||||||||
| 2835 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2836 | |||||||||||||||||||||||||||||
| 2837 | =over 4 | ||||||||||||||||||||||||||||
| 2838 | |||||||||||||||||||||||||||||
| 2839 | =item routine example 1 | ||||||||||||||||||||||||||||
| 2840 | |||||||||||||||||||||||||||||
| 2841 | package Foo; | ||||||||||||||||||||||||||||
| 2842 | |||||||||||||||||||||||||||||
| 2843 | sub cont { | ||||||||||||||||||||||||||||
| 2844 | [@_] | ||||||||||||||||||||||||||||
| 2845 | } | ||||||||||||||||||||||||||||
| 2846 | |||||||||||||||||||||||||||||
| 2847 | sub abort { | ||||||||||||||||||||||||||||
| 2848 | [@_] | ||||||||||||||||||||||||||||
| 2849 | } | ||||||||||||||||||||||||||||
| 2850 | |||||||||||||||||||||||||||||
| 2851 | package main; | ||||||||||||||||||||||||||||
| 2852 | |||||||||||||||||||||||||||||
| 2853 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2854 | |||||||||||||||||||||||||||||
| 2855 | my $space = Venus::Space->new('foo'); | ||||||||||||||||||||||||||||
| 2856 | |||||||||||||||||||||||||||||
| 2857 | my $routine = $space->routine('cont'); | ||||||||||||||||||||||||||||
| 2858 | |||||||||||||||||||||||||||||
| 2859 | # sub { ... } | ||||||||||||||||||||||||||||
| 2860 | |||||||||||||||||||||||||||||
| 2861 | =back | ||||||||||||||||||||||||||||
| 2862 | |||||||||||||||||||||||||||||
| 2863 | =over 4 | ||||||||||||||||||||||||||||
| 2864 | |||||||||||||||||||||||||||||
| 2865 | =item routine example 2 | ||||||||||||||||||||||||||||
| 2866 | |||||||||||||||||||||||||||||
| 2867 | package Foo; | ||||||||||||||||||||||||||||
| 2868 | |||||||||||||||||||||||||||||
| 2869 | sub cont { | ||||||||||||||||||||||||||||
| 2870 | [@_] | ||||||||||||||||||||||||||||
| 2871 | } | ||||||||||||||||||||||||||||
| 2872 | |||||||||||||||||||||||||||||
| 2873 | sub abort { | ||||||||||||||||||||||||||||
| 2874 | [@_] | ||||||||||||||||||||||||||||
| 2875 | } | ||||||||||||||||||||||||||||
| 2876 | |||||||||||||||||||||||||||||
| 2877 | package main; | ||||||||||||||||||||||||||||
| 2878 | |||||||||||||||||||||||||||||
| 2879 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2880 | |||||||||||||||||||||||||||||
| 2881 | my $space = Venus::Space->new('foo'); | ||||||||||||||||||||||||||||
| 2882 | |||||||||||||||||||||||||||||
| 2883 | my $routine = $space->routine('report', sub{[@_]}); | ||||||||||||||||||||||||||||
| 2884 | |||||||||||||||||||||||||||||
| 2885 | # sub { ... } | ||||||||||||||||||||||||||||
| 2886 | |||||||||||||||||||||||||||||
| 2887 | =back | ||||||||||||||||||||||||||||
| 2888 | |||||||||||||||||||||||||||||
| 2889 | =cut | ||||||||||||||||||||||||||||
| 2890 | |||||||||||||||||||||||||||||
| 2891 | =head2 routines | ||||||||||||||||||||||||||||
| 2892 | |||||||||||||||||||||||||||||
| 2893 | routines() (arrayref) | ||||||||||||||||||||||||||||
| 2894 | |||||||||||||||||||||||||||||
| 2895 | The routines method searches the package namespace for routines and returns | ||||||||||||||||||||||||||||
| 2896 | their names. | ||||||||||||||||||||||||||||
| 2897 | |||||||||||||||||||||||||||||
| 2898 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2899 | |||||||||||||||||||||||||||||
| 2900 | =over 4 | ||||||||||||||||||||||||||||
| 2901 | |||||||||||||||||||||||||||||
| 2902 | =item routines example 1 | ||||||||||||||||||||||||||||
| 2903 | |||||||||||||||||||||||||||||
| 2904 | package Foo::Subs; | ||||||||||||||||||||||||||||
| 2905 | |||||||||||||||||||||||||||||
| 2906 | sub start { | ||||||||||||||||||||||||||||
| 2907 | 1 | ||||||||||||||||||||||||||||
| 2908 | } | ||||||||||||||||||||||||||||
| 2909 | |||||||||||||||||||||||||||||
| 2910 | sub abort { | ||||||||||||||||||||||||||||
| 2911 | 1 | ||||||||||||||||||||||||||||
| 2912 | } | ||||||||||||||||||||||||||||
| 2913 | |||||||||||||||||||||||||||||
| 2914 | package main; | ||||||||||||||||||||||||||||
| 2915 | |||||||||||||||||||||||||||||
| 2916 | use Venus::Space; | ||||||||||||||||||||||||||||
| 2917 | |||||||||||||||||||||||||||||
| 2918 | my $space = Venus::Space->new('foo/subs'); | ||||||||||||||||||||||||||||
| 2919 | |||||||||||||||||||||||||||||
| 2920 | my $routines = $space->routines; | ||||||||||||||||||||||||||||
| 2921 | |||||||||||||||||||||||||||||
| 2922 | # ["abort", "start"] | ||||||||||||||||||||||||||||
| 2923 | |||||||||||||||||||||||||||||
| 2924 | =back | ||||||||||||||||||||||||||||
| 2925 | |||||||||||||||||||||||||||||
| 2926 | =cut | ||||||||||||||||||||||||||||
| 2927 | |||||||||||||||||||||||||||||
| 2928 | =head2 scalar | ||||||||||||||||||||||||||||
| 2929 | |||||||||||||||||||||||||||||
| 2930 | scalar(string $name, any @data) (any) | ||||||||||||||||||||||||||||
| 2931 | |||||||||||||||||||||||||||||
| 2932 | The scalar method gets or sets the value for the given package scalar variable name. | ||||||||||||||||||||||||||||
| 2933 | |||||||||||||||||||||||||||||
| 2934 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2935 | |||||||||||||||||||||||||||||
| 2936 | =over 4 | ||||||||||||||||||||||||||||
| 2937 | |||||||||||||||||||||||||||||
| 2938 | =item scalar example 1 | ||||||||||||||||||||||||||||
| 2939 | |||||||||||||||||||||||||||||
| 2940 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2941 | |||||||||||||||||||||||||||||
| 2942 | package Foo::Bar; | ||||||||||||||||||||||||||||
| 2943 | |||||||||||||||||||||||||||||
| 2944 | our $root = '/path/to/file'; | ||||||||||||||||||||||||||||
| 2945 | |||||||||||||||||||||||||||||
| 2946 | package main; | ||||||||||||||||||||||||||||
| 2947 | |||||||||||||||||||||||||||||
| 2948 | my $scalar = $space->scalar('root'); | ||||||||||||||||||||||||||||
| 2949 | |||||||||||||||||||||||||||||
| 2950 | # "/path/to/file" | ||||||||||||||||||||||||||||
| 2951 | |||||||||||||||||||||||||||||
| 2952 | =back | ||||||||||||||||||||||||||||
| 2953 | |||||||||||||||||||||||||||||
| 2954 | =over 4 | ||||||||||||||||||||||||||||
| 2955 | |||||||||||||||||||||||||||||
| 2956 | =item scalar example 2 | ||||||||||||||||||||||||||||
| 2957 | |||||||||||||||||||||||||||||
| 2958 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2959 | |||||||||||||||||||||||||||||
| 2960 | package Foo::Bar; | ||||||||||||||||||||||||||||
| 2961 | |||||||||||||||||||||||||||||
| 2962 | our $root = '/path/to/file'; | ||||||||||||||||||||||||||||
| 2963 | |||||||||||||||||||||||||||||
| 2964 | package main; | ||||||||||||||||||||||||||||
| 2965 | |||||||||||||||||||||||||||||
| 2966 | my $scalar = $space->scalar('root', '/tmp/path/to/file'); | ||||||||||||||||||||||||||||
| 2967 | |||||||||||||||||||||||||||||
| 2968 | # "/tmp/path/to/file" | ||||||||||||||||||||||||||||
| 2969 | |||||||||||||||||||||||||||||
| 2970 | =back | ||||||||||||||||||||||||||||
| 2971 | |||||||||||||||||||||||||||||
| 2972 | =cut | ||||||||||||||||||||||||||||
| 2973 | |||||||||||||||||||||||||||||
| 2974 | =head2 scalars | ||||||||||||||||||||||||||||
| 2975 | |||||||||||||||||||||||||||||
| 2976 | scalars() (arrayref) | ||||||||||||||||||||||||||||
| 2977 | |||||||||||||||||||||||||||||
| 2978 | The scalars method searches the package namespace for scalars and returns their | ||||||||||||||||||||||||||||
| 2979 | names. | ||||||||||||||||||||||||||||
| 2980 | |||||||||||||||||||||||||||||
| 2981 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 2982 | |||||||||||||||||||||||||||||
| 2983 | =over 4 | ||||||||||||||||||||||||||||
| 2984 | |||||||||||||||||||||||||||||
| 2985 | =item scalars example 1 | ||||||||||||||||||||||||||||
| 2986 | |||||||||||||||||||||||||||||
| 2987 | # given: synopsis; | ||||||||||||||||||||||||||||
| 2988 | |||||||||||||||||||||||||||||
| 2989 | package Foo::Bar; | ||||||||||||||||||||||||||||
| 2990 | |||||||||||||||||||||||||||||
| 2991 | our $root = 'root'; | ||||||||||||||||||||||||||||
| 2992 | our $base = 'path/to'; | ||||||||||||||||||||||||||||
| 2993 | our $file = 'file'; | ||||||||||||||||||||||||||||
| 2994 | |||||||||||||||||||||||||||||
| 2995 | package main; | ||||||||||||||||||||||||||||
| 2996 | |||||||||||||||||||||||||||||
| 2997 | my $scalars = $space->scalars; | ||||||||||||||||||||||||||||
| 2998 | |||||||||||||||||||||||||||||
| 2999 | # ["base", "file", "root"] | ||||||||||||||||||||||||||||
| 3000 | |||||||||||||||||||||||||||||
| 3001 | =back | ||||||||||||||||||||||||||||
| 3002 | |||||||||||||||||||||||||||||
| 3003 | =cut | ||||||||||||||||||||||||||||
| 3004 | |||||||||||||||||||||||||||||
| 3005 | =head2 sibling | ||||||||||||||||||||||||||||
| 3006 | |||||||||||||||||||||||||||||
| 3007 | sibling(string $path) (Venus::Space) | ||||||||||||||||||||||||||||
| 3008 | |||||||||||||||||||||||||||||
| 3009 | The sibling method returns a new L<Venus::Space> object for the sibling package | ||||||||||||||||||||||||||||
| 3010 | namespace. | ||||||||||||||||||||||||||||
| 3011 | |||||||||||||||||||||||||||||
| 3012 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 3013 | |||||||||||||||||||||||||||||
| 3014 | =over 4 | ||||||||||||||||||||||||||||
| 3015 | |||||||||||||||||||||||||||||
| 3016 | =item sibling example 1 | ||||||||||||||||||||||||||||
| 3017 | |||||||||||||||||||||||||||||
| 3018 | # given: synopsis; | ||||||||||||||||||||||||||||
| 3019 | |||||||||||||||||||||||||||||
| 3020 | my $sibling = $space->sibling('baz'); | ||||||||||||||||||||||||||||
| 3021 | |||||||||||||||||||||||||||||
| 3022 | # bless({ value => "Foo/Baz" }, "Venus::Space") | ||||||||||||||||||||||||||||
| 3023 | |||||||||||||||||||||||||||||
| 3024 | =back | ||||||||||||||||||||||||||||
| 3025 | |||||||||||||||||||||||||||||
| 3026 | =cut | ||||||||||||||||||||||||||||
| 3027 | |||||||||||||||||||||||||||||
| 3028 | =head2 siblings | ||||||||||||||||||||||||||||
| 3029 | |||||||||||||||||||||||||||||
| 3030 | siblings() (within[arrayref, object]) | ||||||||||||||||||||||||||||
| 3031 | |||||||||||||||||||||||||||||
| 3032 | The siblings method searches C<%INC> and C<@INC> and retuns a list of | ||||||||||||||||||||||||||||
| 3033 | L<Venus::Space> objects for each sibling namespace found (one level deep). | ||||||||||||||||||||||||||||
| 3034 | |||||||||||||||||||||||||||||
| 3035 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 3036 | |||||||||||||||||||||||||||||
| 3037 | =over 4 | ||||||||||||||||||||||||||||
| 3038 | |||||||||||||||||||||||||||||
| 3039 | =item siblings example 1 | ||||||||||||||||||||||||||||
| 3040 | |||||||||||||||||||||||||||||
| 3041 | package main; | ||||||||||||||||||||||||||||
| 3042 | |||||||||||||||||||||||||||||
| 3043 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3044 | |||||||||||||||||||||||||||||
| 3045 | my $space = Venus::Space->new('encode/m_i_m_e'); | ||||||||||||||||||||||||||||
| 3046 | |||||||||||||||||||||||||||||
| 3047 | my $siblings = $space->siblings; | ||||||||||||||||||||||||||||
| 3048 | |||||||||||||||||||||||||||||
| 3049 | # [ | ||||||||||||||||||||||||||||
| 3050 | # bless({ value => "Encode/MIME/Header" }, "Venus::Space"), | ||||||||||||||||||||||||||||
| 3051 | # bless({ value => "Encode/MIME/Name" }, "Venus::Space"), | ||||||||||||||||||||||||||||
| 3052 | # ... | ||||||||||||||||||||||||||||
| 3053 | # ] | ||||||||||||||||||||||||||||
| 3054 | |||||||||||||||||||||||||||||
| 3055 | =back | ||||||||||||||||||||||||||||
| 3056 | |||||||||||||||||||||||||||||
| 3057 | =cut | ||||||||||||||||||||||||||||
| 3058 | |||||||||||||||||||||||||||||
| 3059 | =head2 splice | ||||||||||||||||||||||||||||
| 3060 | |||||||||||||||||||||||||||||
| 3061 | splice(number $offset, number $length, any @list) (Venus::Space) | ||||||||||||||||||||||||||||
| 3062 | |||||||||||||||||||||||||||||
| 3063 | The splice method perform a Perl L<perlfunc/splice> operation on the package | ||||||||||||||||||||||||||||
| 3064 | namespace. | ||||||||||||||||||||||||||||
| 3065 | |||||||||||||||||||||||||||||
| 3066 | I<Since C<0.09>> | ||||||||||||||||||||||||||||
| 3067 | |||||||||||||||||||||||||||||
| 3068 | =over 4 | ||||||||||||||||||||||||||||
| 3069 | |||||||||||||||||||||||||||||
| 3070 | =item splice example 1 | ||||||||||||||||||||||||||||
| 3071 | |||||||||||||||||||||||||||||
| 3072 | package main; | ||||||||||||||||||||||||||||
| 3073 | |||||||||||||||||||||||||||||
| 3074 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3075 | |||||||||||||||||||||||||||||
| 3076 | my $space = Venus::Space->new('foo/baz'); | ||||||||||||||||||||||||||||
| 3077 | |||||||||||||||||||||||||||||
| 3078 | my $splice = $space->splice(1, 0, 'bar'); | ||||||||||||||||||||||||||||
| 3079 | |||||||||||||||||||||||||||||
| 3080 | # bless({ value => "Foo/Bar/Baz" }, "Venus::Space") | ||||||||||||||||||||||||||||
| 3081 | |||||||||||||||||||||||||||||
| 3082 | =back | ||||||||||||||||||||||||||||
| 3083 | |||||||||||||||||||||||||||||
| 3084 | =over 4 | ||||||||||||||||||||||||||||
| 3085 | |||||||||||||||||||||||||||||
| 3086 | =item splice example 2 | ||||||||||||||||||||||||||||
| 3087 | |||||||||||||||||||||||||||||
| 3088 | package main; | ||||||||||||||||||||||||||||
| 3089 | |||||||||||||||||||||||||||||
| 3090 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3091 | |||||||||||||||||||||||||||||
| 3092 | my $space = Venus::Space->new('foo/baz'); | ||||||||||||||||||||||||||||
| 3093 | |||||||||||||||||||||||||||||
| 3094 | my $splice = $space->splice(1, 1); | ||||||||||||||||||||||||||||
| 3095 | |||||||||||||||||||||||||||||
| 3096 | # bless({ value => "Foo" }, "Venus::Space") | ||||||||||||||||||||||||||||
| 3097 | |||||||||||||||||||||||||||||
| 3098 | =back | ||||||||||||||||||||||||||||
| 3099 | |||||||||||||||||||||||||||||
| 3100 | =over 4 | ||||||||||||||||||||||||||||
| 3101 | |||||||||||||||||||||||||||||
| 3102 | =item splice example 3 | ||||||||||||||||||||||||||||
| 3103 | |||||||||||||||||||||||||||||
| 3104 | package main; | ||||||||||||||||||||||||||||
| 3105 | |||||||||||||||||||||||||||||
| 3106 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3107 | |||||||||||||||||||||||||||||
| 3108 | my $space = Venus::Space->new('foo/baz'); | ||||||||||||||||||||||||||||
| 3109 | |||||||||||||||||||||||||||||
| 3110 | my $splice = $space->splice(-2, 1); | ||||||||||||||||||||||||||||
| 3111 | |||||||||||||||||||||||||||||
| 3112 | # bless({ value => "Baz" }, "Venus::Space") | ||||||||||||||||||||||||||||
| 3113 | |||||||||||||||||||||||||||||
| 3114 | =back | ||||||||||||||||||||||||||||
| 3115 | |||||||||||||||||||||||||||||
| 3116 | =over 4 | ||||||||||||||||||||||||||||
| 3117 | |||||||||||||||||||||||||||||
| 3118 | =item splice example 4 | ||||||||||||||||||||||||||||
| 3119 | |||||||||||||||||||||||||||||
| 3120 | package main; | ||||||||||||||||||||||||||||
| 3121 | |||||||||||||||||||||||||||||
| 3122 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3123 | |||||||||||||||||||||||||||||
| 3124 | my $space = Venus::Space->new('foo/baz'); | ||||||||||||||||||||||||||||
| 3125 | |||||||||||||||||||||||||||||
| 3126 | my $splice = $space->splice(1); | ||||||||||||||||||||||||||||
| 3127 | |||||||||||||||||||||||||||||
| 3128 | # bless({ value => "Foo" }, "Venus::Space") | ||||||||||||||||||||||||||||
| 3129 | |||||||||||||||||||||||||||||
| 3130 | =back | ||||||||||||||||||||||||||||
| 3131 | |||||||||||||||||||||||||||||
| 3132 | =cut | ||||||||||||||||||||||||||||
| 3133 | |||||||||||||||||||||||||||||
| 3134 | =head2 swap | ||||||||||||||||||||||||||||
| 3135 | |||||||||||||||||||||||||||||
| 3136 | swap(string $name, coderef $code) (coderef) | ||||||||||||||||||||||||||||
| 3137 | |||||||||||||||||||||||||||||
| 3138 | The swap method overwrites the named subroutine in the underlying package with | ||||||||||||||||||||||||||||
| 3139 | the code reference provided and returns the original subroutine as a code | ||||||||||||||||||||||||||||
| 3140 | reference. The code provided will be passed a reference to the original | ||||||||||||||||||||||||||||
| 3141 | subroutine as its first argument. | ||||||||||||||||||||||||||||
| 3142 | |||||||||||||||||||||||||||||
| 3143 | I<Since C<1.95>> | ||||||||||||||||||||||||||||
| 3144 | |||||||||||||||||||||||||||||
| 3145 | =over 4 | ||||||||||||||||||||||||||||
| 3146 | |||||||||||||||||||||||||||||
| 3147 | =item swap example 1 | ||||||||||||||||||||||||||||
| 3148 | |||||||||||||||||||||||||||||
| 3149 | package Foo::Swap; | ||||||||||||||||||||||||||||
| 3150 | |||||||||||||||||||||||||||||
| 3151 | use Venus::Class; | ||||||||||||||||||||||||||||
| 3152 | |||||||||||||||||||||||||||||
| 3153 | package main; | ||||||||||||||||||||||||||||
| 3154 | |||||||||||||||||||||||||||||
| 3155 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3156 | |||||||||||||||||||||||||||||
| 3157 | my $space = Venus::Space->new('foo/swap'); | ||||||||||||||||||||||||||||
| 3158 | |||||||||||||||||||||||||||||
| 3159 | my $subroutine = $space->swap('new', sub { | ||||||||||||||||||||||||||||
| 3160 | my ($next, @args) = @_; | ||||||||||||||||||||||||||||
| 3161 | my $self = $next->(@args); | ||||||||||||||||||||||||||||
| 3162 | $self->{swapped} = 1; | ||||||||||||||||||||||||||||
| 3163 | return $self; | ||||||||||||||||||||||||||||
| 3164 | }); | ||||||||||||||||||||||||||||
| 3165 | |||||||||||||||||||||||||||||
| 3166 | # sub { ... } | ||||||||||||||||||||||||||||
| 3167 | |||||||||||||||||||||||||||||
| 3168 | =back | ||||||||||||||||||||||||||||
| 3169 | |||||||||||||||||||||||||||||
| 3170 | =over 4 | ||||||||||||||||||||||||||||
| 3171 | |||||||||||||||||||||||||||||
| 3172 | =item swap example 2 | ||||||||||||||||||||||||||||
| 3173 | |||||||||||||||||||||||||||||
| 3174 | package Foo::Swap; | ||||||||||||||||||||||||||||
| 3175 | |||||||||||||||||||||||||||||
| 3176 | use Venus::Class; | ||||||||||||||||||||||||||||
| 3177 | |||||||||||||||||||||||||||||
| 3178 | package main; | ||||||||||||||||||||||||||||
| 3179 | |||||||||||||||||||||||||||||
| 3180 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3181 | |||||||||||||||||||||||||||||
| 3182 | my $space = Venus::Space->new('foo/swap'); | ||||||||||||||||||||||||||||
| 3183 | |||||||||||||||||||||||||||||
| 3184 | my $subroutine = $space->swap('something', sub { | ||||||||||||||||||||||||||||
| 3185 | my ($next, @args) = @_; | ||||||||||||||||||||||||||||
| 3186 | my $self = $next->(@args); | ||||||||||||||||||||||||||||
| 3187 | $self->{swapped} = 1; | ||||||||||||||||||||||||||||
| 3188 | return $self; | ||||||||||||||||||||||||||||
| 3189 | }); | ||||||||||||||||||||||||||||
| 3190 | |||||||||||||||||||||||||||||
| 3191 | # Exception! (isa Venus::Space::Error) (see error_on_swap) | ||||||||||||||||||||||||||||
| 3192 | |||||||||||||||||||||||||||||
| 3193 | =back | ||||||||||||||||||||||||||||
| 3194 | |||||||||||||||||||||||||||||
| 3195 | =cut | ||||||||||||||||||||||||||||
| 3196 | |||||||||||||||||||||||||||||
| 3197 | =head2 tfile | ||||||||||||||||||||||||||||
| 3198 | |||||||||||||||||||||||||||||
| 3199 | tfile() (string) | ||||||||||||||||||||||||||||
| 3200 | |||||||||||||||||||||||||||||
| 3201 | The tfile method returns a C<.t> file path for the underlying package. | ||||||||||||||||||||||||||||
| 3202 | |||||||||||||||||||||||||||||
| 3203 | I<Since C<1.30>> | ||||||||||||||||||||||||||||
| 3204 | |||||||||||||||||||||||||||||
| 3205 | =over 4 | ||||||||||||||||||||||||||||
| 3206 | |||||||||||||||||||||||||||||
| 3207 | =item tfile example 1 | ||||||||||||||||||||||||||||
| 3208 | |||||||||||||||||||||||||||||
| 3209 | # given: synopsis | ||||||||||||||||||||||||||||
| 3210 | |||||||||||||||||||||||||||||
| 3211 | package main; | ||||||||||||||||||||||||||||
| 3212 | |||||||||||||||||||||||||||||
| 3213 | my $tfile = $space->tfile; | ||||||||||||||||||||||||||||
| 3214 | |||||||||||||||||||||||||||||
| 3215 | # "Foo_Bar.t" | ||||||||||||||||||||||||||||
| 3216 | |||||||||||||||||||||||||||||
| 3217 | =back | ||||||||||||||||||||||||||||
| 3218 | |||||||||||||||||||||||||||||
| 3219 | =cut | ||||||||||||||||||||||||||||
| 3220 | |||||||||||||||||||||||||||||
| 3221 | =head2 tryload | ||||||||||||||||||||||||||||
| 3222 | |||||||||||||||||||||||||||||
| 3223 | tryload() (boolean) | ||||||||||||||||||||||||||||
| 3224 | |||||||||||||||||||||||||||||
| 3225 | The tryload method attempt to C<load> the represented package using the | ||||||||||||||||||||||||||||
| 3226 | L</load> method and returns truthy/falsy based on whether the package was | ||||||||||||||||||||||||||||
| 3227 | loaded. | ||||||||||||||||||||||||||||
| 3228 | |||||||||||||||||||||||||||||
| 3229 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 3230 | |||||||||||||||||||||||||||||
| 3231 | =over 4 | ||||||||||||||||||||||||||||
| 3232 | |||||||||||||||||||||||||||||
| 3233 | =item tryload example 1 | ||||||||||||||||||||||||||||
| 3234 | |||||||||||||||||||||||||||||
| 3235 | package main; | ||||||||||||||||||||||||||||
| 3236 | |||||||||||||||||||||||||||||
| 3237 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3238 | |||||||||||||||||||||||||||||
| 3239 | my $space = Venus::Space->new('c_p_a_n'); | ||||||||||||||||||||||||||||
| 3240 | |||||||||||||||||||||||||||||
| 3241 | my $tryload = $space->tryload; | ||||||||||||||||||||||||||||
| 3242 | |||||||||||||||||||||||||||||
| 3243 | # 1 | ||||||||||||||||||||||||||||
| 3244 | |||||||||||||||||||||||||||||
| 3245 | =back | ||||||||||||||||||||||||||||
| 3246 | |||||||||||||||||||||||||||||
| 3247 | =over 4 | ||||||||||||||||||||||||||||
| 3248 | |||||||||||||||||||||||||||||
| 3249 | =item tryload example 2 | ||||||||||||||||||||||||||||
| 3250 | |||||||||||||||||||||||||||||
| 3251 | package main; | ||||||||||||||||||||||||||||
| 3252 | |||||||||||||||||||||||||||||
| 3253 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3254 | |||||||||||||||||||||||||||||
| 3255 | my $space = Venus::Space->new('n_a_p_c'); | ||||||||||||||||||||||||||||
| 3256 | |||||||||||||||||||||||||||||
| 3257 | my $tryload = $space->tryload; | ||||||||||||||||||||||||||||
| 3258 | |||||||||||||||||||||||||||||
| 3259 | # 0 | ||||||||||||||||||||||||||||
| 3260 | |||||||||||||||||||||||||||||
| 3261 | =back | ||||||||||||||||||||||||||||
| 3262 | |||||||||||||||||||||||||||||
| 3263 | =cut | ||||||||||||||||||||||||||||
| 3264 | |||||||||||||||||||||||||||||
| 3265 | =head2 unload | ||||||||||||||||||||||||||||
| 3266 | |||||||||||||||||||||||||||||
| 3267 | unload() (Self) | ||||||||||||||||||||||||||||
| 3268 | |||||||||||||||||||||||||||||
| 3269 | The unload method unloads a package space by nullifying its symbol table and | ||||||||||||||||||||||||||||
| 3270 | removing it from C<%INC>. | ||||||||||||||||||||||||||||
| 3271 | |||||||||||||||||||||||||||||
| 3272 | I<Since C<1.02>> | ||||||||||||||||||||||||||||
| 3273 | |||||||||||||||||||||||||||||
| 3274 | =over 4 | ||||||||||||||||||||||||||||
| 3275 | |||||||||||||||||||||||||||||
| 3276 | =item unload example 1 | ||||||||||||||||||||||||||||
| 3277 | |||||||||||||||||||||||||||||
| 3278 | package main; | ||||||||||||||||||||||||||||
| 3279 | |||||||||||||||||||||||||||||
| 3280 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3281 | |||||||||||||||||||||||||||||
| 3282 | # Bar::Gen is generated with $VERSION as 0.01 | ||||||||||||||||||||||||||||
| 3283 | |||||||||||||||||||||||||||||
| 3284 | my $space = Venus::Space->new('Bar/Gen'); | ||||||||||||||||||||||||||||
| 3285 | |||||||||||||||||||||||||||||
| 3286 | $space->load; | ||||||||||||||||||||||||||||
| 3287 | |||||||||||||||||||||||||||||
| 3288 | my $unload = $space->unload; | ||||||||||||||||||||||||||||
| 3289 | |||||||||||||||||||||||||||||
| 3290 | # bless({ value => "Bar::Gen" }, "Venus::Space") | ||||||||||||||||||||||||||||
| 3291 | |||||||||||||||||||||||||||||
| 3292 | # Bar::Gen->VERSION was 0.01, now undef | ||||||||||||||||||||||||||||
| 3293 | |||||||||||||||||||||||||||||
| 3294 | # Symbol table remains, $space->visible is 1 | ||||||||||||||||||||||||||||
| 3295 | |||||||||||||||||||||||||||||
| 3296 | =back | ||||||||||||||||||||||||||||
| 3297 | |||||||||||||||||||||||||||||
| 3298 | =cut | ||||||||||||||||||||||||||||
| 3299 | |||||||||||||||||||||||||||||
| 3300 | =head2 unloaded | ||||||||||||||||||||||||||||
| 3301 | |||||||||||||||||||||||||||||
| 3302 | unloaded() (boolean) | ||||||||||||||||||||||||||||
| 3303 | |||||||||||||||||||||||||||||
| 3304 | The unloaded method checks whether the package namespace is not loaded and | ||||||||||||||||||||||||||||
| 3305 | returns truthy or falsy. | ||||||||||||||||||||||||||||
| 3306 | |||||||||||||||||||||||||||||
| 3307 | I<Since C<1.02>> | ||||||||||||||||||||||||||||
| 3308 | |||||||||||||||||||||||||||||
| 3309 | =over 4 | ||||||||||||||||||||||||||||
| 3310 | |||||||||||||||||||||||||||||
| 3311 | =item unloaded example 1 | ||||||||||||||||||||||||||||
| 3312 | |||||||||||||||||||||||||||||
| 3313 | package main; | ||||||||||||||||||||||||||||
| 3314 | |||||||||||||||||||||||||||||
| 3315 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3316 | |||||||||||||||||||||||||||||
| 3317 | my $space = Venus::Space->new('Kit'); | ||||||||||||||||||||||||||||
| 3318 | |||||||||||||||||||||||||||||
| 3319 | $space->init; | ||||||||||||||||||||||||||||
| 3320 | |||||||||||||||||||||||||||||
| 3321 | $space->unload; | ||||||||||||||||||||||||||||
| 3322 | |||||||||||||||||||||||||||||
| 3323 | my $unloaded = $space->unloaded; | ||||||||||||||||||||||||||||
| 3324 | |||||||||||||||||||||||||||||
| 3325 | # 1 | ||||||||||||||||||||||||||||
| 3326 | |||||||||||||||||||||||||||||
| 3327 | =back | ||||||||||||||||||||||||||||
| 3328 | |||||||||||||||||||||||||||||
| 3329 | =over 4 | ||||||||||||||||||||||||||||
| 3330 | |||||||||||||||||||||||||||||
| 3331 | =item unloaded example 2 | ||||||||||||||||||||||||||||
| 3332 | |||||||||||||||||||||||||||||
| 3333 | package main; | ||||||||||||||||||||||||||||
| 3334 | |||||||||||||||||||||||||||||
| 3335 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3336 | |||||||||||||||||||||||||||||
| 3337 | my $space = Venus::Space->new('Kit'); | ||||||||||||||||||||||||||||
| 3338 | |||||||||||||||||||||||||||||
| 3339 | $space->init; | ||||||||||||||||||||||||||||
| 3340 | |||||||||||||||||||||||||||||
| 3341 | my $unloaded = $space->unloaded; | ||||||||||||||||||||||||||||
| 3342 | |||||||||||||||||||||||||||||
| 3343 | # 0 | ||||||||||||||||||||||||||||
| 3344 | |||||||||||||||||||||||||||||
| 3345 | =back | ||||||||||||||||||||||||||||
| 3346 | |||||||||||||||||||||||||||||
| 3347 | =cut | ||||||||||||||||||||||||||||
| 3348 | |||||||||||||||||||||||||||||
| 3349 | =head2 unpatch | ||||||||||||||||||||||||||||
| 3350 | |||||||||||||||||||||||||||||
| 3351 | unpatch(string @names) (Venus::Space) | ||||||||||||||||||||||||||||
| 3352 | |||||||||||||||||||||||||||||
| 3353 | The unpatch method restores a subroutine which has been patched using the | ||||||||||||||||||||||||||||
| 3354 | L</patch> operation to its original subroutine reference. If no name is | ||||||||||||||||||||||||||||
| 3355 | provided, this method will restore all subroutines have been patched. If a name | ||||||||||||||||||||||||||||
| 3356 | is provided, this method will only restore the named subroutine has been | ||||||||||||||||||||||||||||
| 3357 | patched. | ||||||||||||||||||||||||||||
| 3358 | |||||||||||||||||||||||||||||
| 3359 | I<Since C<3.55>> | ||||||||||||||||||||||||||||
| 3360 | |||||||||||||||||||||||||||||
| 3361 | =over 4 | ||||||||||||||||||||||||||||
| 3362 | |||||||||||||||||||||||||||||
| 3363 | =item unpatch example 1 | ||||||||||||||||||||||||||||
| 3364 | |||||||||||||||||||||||||||||
| 3365 | package Foo::Far; | ||||||||||||||||||||||||||||
| 3366 | |||||||||||||||||||||||||||||
| 3367 | use Venus::Class; | ||||||||||||||||||||||||||||
| 3368 | |||||||||||||||||||||||||||||
| 3369 | sub execute { | ||||||||||||||||||||||||||||
| 3370 | 1 | ||||||||||||||||||||||||||||
| 3371 | } | ||||||||||||||||||||||||||||
| 3372 | |||||||||||||||||||||||||||||
| 3373 | package main; | ||||||||||||||||||||||||||||
| 3374 | |||||||||||||||||||||||||||||
| 3375 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3376 | |||||||||||||||||||||||||||||
| 3377 | my $space = Venus::Space->new('foo/far'); | ||||||||||||||||||||||||||||
| 3378 | |||||||||||||||||||||||||||||
| 3379 | $space->patch('execute', sub { | ||||||||||||||||||||||||||||
| 3380 | $_[0]->() + 1 | ||||||||||||||||||||||||||||
| 3381 | }); | ||||||||||||||||||||||||||||
| 3382 | |||||||||||||||||||||||||||||
| 3383 | my $unpatch = $space->unpatch; | ||||||||||||||||||||||||||||
| 3384 | |||||||||||||||||||||||||||||
| 3385 | # bless(..., "Venus::Space") | ||||||||||||||||||||||||||||
| 3386 | |||||||||||||||||||||||||||||
| 3387 | =back | ||||||||||||||||||||||||||||
| 3388 | |||||||||||||||||||||||||||||
| 3389 | =over 4 | ||||||||||||||||||||||||||||
| 3390 | |||||||||||||||||||||||||||||
| 3391 | =item unpatch example 2 | ||||||||||||||||||||||||||||
| 3392 | |||||||||||||||||||||||||||||
| 3393 | package Foo::Far; | ||||||||||||||||||||||||||||
| 3394 | |||||||||||||||||||||||||||||
| 3395 | use Venus::Class; | ||||||||||||||||||||||||||||
| 3396 | |||||||||||||||||||||||||||||
| 3397 | sub execute { | ||||||||||||||||||||||||||||
| 3398 | 1 | ||||||||||||||||||||||||||||
| 3399 | } | ||||||||||||||||||||||||||||
| 3400 | |||||||||||||||||||||||||||||
| 3401 | package main; | ||||||||||||||||||||||||||||
| 3402 | |||||||||||||||||||||||||||||
| 3403 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3404 | |||||||||||||||||||||||||||||
| 3405 | my $space = Venus::Space->new('foo/far'); | ||||||||||||||||||||||||||||
| 3406 | |||||||||||||||||||||||||||||
| 3407 | $space->patch('execute', sub { | ||||||||||||||||||||||||||||
| 3408 | $_[0]->() + 1 | ||||||||||||||||||||||||||||
| 3409 | }); | ||||||||||||||||||||||||||||
| 3410 | |||||||||||||||||||||||||||||
| 3411 | my $unpatch = $space->unpatch('execute'); | ||||||||||||||||||||||||||||
| 3412 | |||||||||||||||||||||||||||||
| 3413 | # bless(..., "Venus::Space") | ||||||||||||||||||||||||||||
| 3414 | |||||||||||||||||||||||||||||
| 3415 | =back | ||||||||||||||||||||||||||||
| 3416 | |||||||||||||||||||||||||||||
| 3417 | =over 4 | ||||||||||||||||||||||||||||
| 3418 | |||||||||||||||||||||||||||||
| 3419 | =item unpatch example 3 | ||||||||||||||||||||||||||||
| 3420 | |||||||||||||||||||||||||||||
| 3421 | package Foo::Far; | ||||||||||||||||||||||||||||
| 3422 | |||||||||||||||||||||||||||||
| 3423 | use Venus::Class; | ||||||||||||||||||||||||||||
| 3424 | |||||||||||||||||||||||||||||
| 3425 | sub execute { | ||||||||||||||||||||||||||||
| 3426 | 1 | ||||||||||||||||||||||||||||
| 3427 | } | ||||||||||||||||||||||||||||
| 3428 | |||||||||||||||||||||||||||||
| 3429 | package main; | ||||||||||||||||||||||||||||
| 3430 | |||||||||||||||||||||||||||||
| 3431 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3432 | |||||||||||||||||||||||||||||
| 3433 | my $space = Venus::Space->new('foo/far'); | ||||||||||||||||||||||||||||
| 3434 | |||||||||||||||||||||||||||||
| 3435 | $space->patch('execute', sub { | ||||||||||||||||||||||||||||
| 3436 | $_[0]->() + 1 | ||||||||||||||||||||||||||||
| 3437 | }); | ||||||||||||||||||||||||||||
| 3438 | |||||||||||||||||||||||||||||
| 3439 | my $unpatch = $space->unpatch('prepare'); | ||||||||||||||||||||||||||||
| 3440 | |||||||||||||||||||||||||||||
| 3441 | # bless(..., "Venus::Space") | ||||||||||||||||||||||||||||
| 3442 | |||||||||||||||||||||||||||||
| 3443 | =back | ||||||||||||||||||||||||||||
| 3444 | |||||||||||||||||||||||||||||
| 3445 | =cut | ||||||||||||||||||||||||||||
| 3446 | |||||||||||||||||||||||||||||
| 3447 | =head2 use | ||||||||||||||||||||||||||||
| 3448 | |||||||||||||||||||||||||||||
| 3449 | use(string | tuple[string, string] $target, any @params) (Venus::Space) | ||||||||||||||||||||||||||||
| 3450 | |||||||||||||||||||||||||||||
| 3451 | The use method executes a C<use> statement within the package namespace | ||||||||||||||||||||||||||||
| 3452 | specified. | ||||||||||||||||||||||||||||
| 3453 | |||||||||||||||||||||||||||||
| 3454 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 3455 | |||||||||||||||||||||||||||||
| 3456 | =over 4 | ||||||||||||||||||||||||||||
| 3457 | |||||||||||||||||||||||||||||
| 3458 | =item use example 1 | ||||||||||||||||||||||||||||
| 3459 | |||||||||||||||||||||||||||||
| 3460 | package main; | ||||||||||||||||||||||||||||
| 3461 | |||||||||||||||||||||||||||||
| 3462 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3463 | |||||||||||||||||||||||||||||
| 3464 | my $space = Venus::Space->new('foo/goo'); | ||||||||||||||||||||||||||||
| 3465 | |||||||||||||||||||||||||||||
| 3466 | my $use = $space->use('Venus'); | ||||||||||||||||||||||||||||
| 3467 | |||||||||||||||||||||||||||||
| 3468 | # bless({ value => "foo/goo" }, "Venus::Space") | ||||||||||||||||||||||||||||
| 3469 | |||||||||||||||||||||||||||||
| 3470 | =back | ||||||||||||||||||||||||||||
| 3471 | |||||||||||||||||||||||||||||
| 3472 | =over 4 | ||||||||||||||||||||||||||||
| 3473 | |||||||||||||||||||||||||||||
| 3474 | =item use example 2 | ||||||||||||||||||||||||||||
| 3475 | |||||||||||||||||||||||||||||
| 3476 | package main; | ||||||||||||||||||||||||||||
| 3477 | |||||||||||||||||||||||||||||
| 3478 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3479 | |||||||||||||||||||||||||||||
| 3480 | my $space = Venus::Space->new('foo/hoo'); | ||||||||||||||||||||||||||||
| 3481 | |||||||||||||||||||||||||||||
| 3482 | my $use = $space->use('Venus', 'error'); | ||||||||||||||||||||||||||||
| 3483 | |||||||||||||||||||||||||||||
| 3484 | # bless({ value => "foo/hoo" }, "Venus::Space") | ||||||||||||||||||||||||||||
| 3485 | |||||||||||||||||||||||||||||
| 3486 | =back | ||||||||||||||||||||||||||||
| 3487 | |||||||||||||||||||||||||||||
| 3488 | =over 4 | ||||||||||||||||||||||||||||
| 3489 | |||||||||||||||||||||||||||||
| 3490 | =item use example 3 | ||||||||||||||||||||||||||||
| 3491 | |||||||||||||||||||||||||||||
| 3492 | package main; | ||||||||||||||||||||||||||||
| 3493 | |||||||||||||||||||||||||||||
| 3494 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3495 | |||||||||||||||||||||||||||||
| 3496 | my $space = Venus::Space->new('foo/foo'); | ||||||||||||||||||||||||||||
| 3497 | |||||||||||||||||||||||||||||
| 3498 | my $use = $space->use(['Venus', 9.99], 'error'); | ||||||||||||||||||||||||||||
| 3499 | |||||||||||||||||||||||||||||
| 3500 | =back | ||||||||||||||||||||||||||||
| 3501 | |||||||||||||||||||||||||||||
| 3502 | =cut | ||||||||||||||||||||||||||||
| 3503 | |||||||||||||||||||||||||||||
| 3504 | =head2 variables | ||||||||||||||||||||||||||||
| 3505 | |||||||||||||||||||||||||||||
| 3506 | variables() (within[arrayref, tuple[string, arrayref]]) | ||||||||||||||||||||||||||||
| 3507 | |||||||||||||||||||||||||||||
| 3508 | The variables method searches the package namespace for variables and returns | ||||||||||||||||||||||||||||
| 3509 | their names. | ||||||||||||||||||||||||||||
| 3510 | |||||||||||||||||||||||||||||
| 3511 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 3512 | |||||||||||||||||||||||||||||
| 3513 | =over 4 | ||||||||||||||||||||||||||||
| 3514 | |||||||||||||||||||||||||||||
| 3515 | =item variables example 1 | ||||||||||||||||||||||||||||
| 3516 | |||||||||||||||||||||||||||||
| 3517 | package Etc; | ||||||||||||||||||||||||||||
| 3518 | |||||||||||||||||||||||||||||
| 3519 | our $init = 0; | ||||||||||||||||||||||||||||
| 3520 | our $func = 1; | ||||||||||||||||||||||||||||
| 3521 | |||||||||||||||||||||||||||||
| 3522 | our @does = (1..4); | ||||||||||||||||||||||||||||
| 3523 | our %sets = (1..4); | ||||||||||||||||||||||||||||
| 3524 | |||||||||||||||||||||||||||||
| 3525 | package main; | ||||||||||||||||||||||||||||
| 3526 | |||||||||||||||||||||||||||||
| 3527 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3528 | |||||||||||||||||||||||||||||
| 3529 | my $space = Venus::Space->new('etc'); | ||||||||||||||||||||||||||||
| 3530 | |||||||||||||||||||||||||||||
| 3531 | my $variables = $space->variables; | ||||||||||||||||||||||||||||
| 3532 | |||||||||||||||||||||||||||||
| 3533 | # [ | ||||||||||||||||||||||||||||
| 3534 | # ["arrays", ["does"]], | ||||||||||||||||||||||||||||
| 3535 | # ["hashes", ["sets"]], | ||||||||||||||||||||||||||||
| 3536 | # ["scalars", ["func", "init"]], | ||||||||||||||||||||||||||||
| 3537 | # ] | ||||||||||||||||||||||||||||
| 3538 | |||||||||||||||||||||||||||||
| 3539 | =back | ||||||||||||||||||||||||||||
| 3540 | |||||||||||||||||||||||||||||
| 3541 | =cut | ||||||||||||||||||||||||||||
| 3542 | |||||||||||||||||||||||||||||
| 3543 | =head2 version | ||||||||||||||||||||||||||||
| 3544 | |||||||||||||||||||||||||||||
| 3545 | version() (maybe[string]) | ||||||||||||||||||||||||||||
| 3546 | |||||||||||||||||||||||||||||
| 3547 | The version method returns the C<VERSION> declared on the target package, if | ||||||||||||||||||||||||||||
| 3548 | any. | ||||||||||||||||||||||||||||
| 3549 | |||||||||||||||||||||||||||||
| 3550 | I<Since C<0.01>> | ||||||||||||||||||||||||||||
| 3551 | |||||||||||||||||||||||||||||
| 3552 | =over 4 | ||||||||||||||||||||||||||||
| 3553 | |||||||||||||||||||||||||||||
| 3554 | =item version example 1 | ||||||||||||||||||||||||||||
| 3555 | |||||||||||||||||||||||||||||
| 3556 | package Foo::Boo; | ||||||||||||||||||||||||||||
| 3557 | |||||||||||||||||||||||||||||
| 3558 | sub import; | ||||||||||||||||||||||||||||
| 3559 | |||||||||||||||||||||||||||||
| 3560 | package main; | ||||||||||||||||||||||||||||
| 3561 | |||||||||||||||||||||||||||||
| 3562 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3563 | |||||||||||||||||||||||||||||
| 3564 | my $space = Venus::Space->new('foo/boo'); | ||||||||||||||||||||||||||||
| 3565 | |||||||||||||||||||||||||||||
| 3566 | my $version = $space->version; | ||||||||||||||||||||||||||||
| 3567 | |||||||||||||||||||||||||||||
| 3568 | # undef | ||||||||||||||||||||||||||||
| 3569 | |||||||||||||||||||||||||||||
| 3570 | =back | ||||||||||||||||||||||||||||
| 3571 | |||||||||||||||||||||||||||||
| 3572 | =over 4 | ||||||||||||||||||||||||||||
| 3573 | |||||||||||||||||||||||||||||
| 3574 | =item version example 2 | ||||||||||||||||||||||||||||
| 3575 | |||||||||||||||||||||||||||||
| 3576 | package Foo::Boo; | ||||||||||||||||||||||||||||
| 3577 | |||||||||||||||||||||||||||||
| 3578 | our $VERSION = 0.01; | ||||||||||||||||||||||||||||
| 3579 | |||||||||||||||||||||||||||||
| 3580 | package main; | ||||||||||||||||||||||||||||
| 3581 | |||||||||||||||||||||||||||||
| 3582 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3583 | |||||||||||||||||||||||||||||
| 3584 | my $space = Venus::Space->new('foo/boo'); | ||||||||||||||||||||||||||||
| 3585 | |||||||||||||||||||||||||||||
| 3586 | my $version = $space->version; | ||||||||||||||||||||||||||||
| 3587 | |||||||||||||||||||||||||||||
| 3588 | # 0.01 | ||||||||||||||||||||||||||||
| 3589 | |||||||||||||||||||||||||||||
| 3590 | =back | ||||||||||||||||||||||||||||
| 3591 | |||||||||||||||||||||||||||||
| 3592 | =cut | ||||||||||||||||||||||||||||
| 3593 | |||||||||||||||||||||||||||||
| 3594 | =head2 visible | ||||||||||||||||||||||||||||
| 3595 | |||||||||||||||||||||||||||||
| 3596 | visible() (boolean) | ||||||||||||||||||||||||||||
| 3597 | |||||||||||||||||||||||||||||
| 3598 | The visible method returns truthy is the package namespace is visible, i.e. has | ||||||||||||||||||||||||||||
| 3599 | symbols defined. | ||||||||||||||||||||||||||||
| 3600 | |||||||||||||||||||||||||||||
| 3601 | I<Since C<1.02>> | ||||||||||||||||||||||||||||
| 3602 | |||||||||||||||||||||||||||||
| 3603 | =over 4 | ||||||||||||||||||||||||||||
| 3604 | |||||||||||||||||||||||||||||
| 3605 | =item visible example 1 | ||||||||||||||||||||||||||||
| 3606 | |||||||||||||||||||||||||||||
| 3607 | # given: synopsis | ||||||||||||||||||||||||||||
| 3608 | |||||||||||||||||||||||||||||
| 3609 | package main; | ||||||||||||||||||||||||||||
| 3610 | |||||||||||||||||||||||||||||
| 3611 | my $visible = $space->visible; | ||||||||||||||||||||||||||||
| 3612 | |||||||||||||||||||||||||||||
| 3613 | # 1 | ||||||||||||||||||||||||||||
| 3614 | |||||||||||||||||||||||||||||
| 3615 | =back | ||||||||||||||||||||||||||||
| 3616 | |||||||||||||||||||||||||||||
| 3617 | =over 4 | ||||||||||||||||||||||||||||
| 3618 | |||||||||||||||||||||||||||||
| 3619 | =item visible example 2 | ||||||||||||||||||||||||||||
| 3620 | |||||||||||||||||||||||||||||
| 3621 | package Foo::Fe; | ||||||||||||||||||||||||||||
| 3622 | |||||||||||||||||||||||||||||
| 3623 | package main; | ||||||||||||||||||||||||||||
| 3624 | |||||||||||||||||||||||||||||
| 3625 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3626 | |||||||||||||||||||||||||||||
| 3627 | my $space = Venus::Space->new('foo/fe'); | ||||||||||||||||||||||||||||
| 3628 | |||||||||||||||||||||||||||||
| 3629 | my $visible = $space->visible; | ||||||||||||||||||||||||||||
| 3630 | |||||||||||||||||||||||||||||
| 3631 | # 0 | ||||||||||||||||||||||||||||
| 3632 | |||||||||||||||||||||||||||||
| 3633 | =back | ||||||||||||||||||||||||||||
| 3634 | |||||||||||||||||||||||||||||
| 3635 | =over 4 | ||||||||||||||||||||||||||||
| 3636 | |||||||||||||||||||||||||||||
| 3637 | =item visible example 3 | ||||||||||||||||||||||||||||
| 3638 | |||||||||||||||||||||||||||||
| 3639 | package Foo::Fe; | ||||||||||||||||||||||||||||
| 3640 | |||||||||||||||||||||||||||||
| 3641 | our $VERSION = 0.01; | ||||||||||||||||||||||||||||
| 3642 | |||||||||||||||||||||||||||||
| 3643 | package main; | ||||||||||||||||||||||||||||
| 3644 | |||||||||||||||||||||||||||||
| 3645 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3646 | |||||||||||||||||||||||||||||
| 3647 | my $space = Venus::Space->new('foo/fe'); | ||||||||||||||||||||||||||||
| 3648 | |||||||||||||||||||||||||||||
| 3649 | my $visible = $space->visible; | ||||||||||||||||||||||||||||
| 3650 | |||||||||||||||||||||||||||||
| 3651 | # 1 | ||||||||||||||||||||||||||||
| 3652 | |||||||||||||||||||||||||||||
| 3653 | =back | ||||||||||||||||||||||||||||
| 3654 | |||||||||||||||||||||||||||||
| 3655 | =over 4 | ||||||||||||||||||||||||||||
| 3656 | |||||||||||||||||||||||||||||
| 3657 | =item visible example 4 | ||||||||||||||||||||||||||||
| 3658 | |||||||||||||||||||||||||||||
| 3659 | package Foo::Fi; | ||||||||||||||||||||||||||||
| 3660 | |||||||||||||||||||||||||||||
| 3661 | sub import; | ||||||||||||||||||||||||||||
| 3662 | |||||||||||||||||||||||||||||
| 3663 | package main; | ||||||||||||||||||||||||||||
| 3664 | |||||||||||||||||||||||||||||
| 3665 | use Venus::Space; | ||||||||||||||||||||||||||||
| 3666 | |||||||||||||||||||||||||||||
| 3667 | my $space = Venus::Space->new('foo/fi'); | ||||||||||||||||||||||||||||
| 3668 | |||||||||||||||||||||||||||||
| 3669 | my $visible = $space->visible; | ||||||||||||||||||||||||||||
| 3670 | |||||||||||||||||||||||||||||
| 3671 | # 1 | ||||||||||||||||||||||||||||
| 3672 | |||||||||||||||||||||||||||||
| 3673 | =back | ||||||||||||||||||||||||||||
| 3674 | |||||||||||||||||||||||||||||
| 3675 | =cut | ||||||||||||||||||||||||||||
| 3676 | |||||||||||||||||||||||||||||
| 3677 | =head1 ERRORS | ||||||||||||||||||||||||||||
| 3678 | |||||||||||||||||||||||||||||
| 3679 | This package may raise the following errors: | ||||||||||||||||||||||||||||
| 3680 | |||||||||||||||||||||||||||||
| 3681 | =cut | ||||||||||||||||||||||||||||
| 3682 | |||||||||||||||||||||||||||||
| 3683 | =over 4 | ||||||||||||||||||||||||||||
| 3684 | |||||||||||||||||||||||||||||
| 3685 | =item error: C<error_on_call_missing> | ||||||||||||||||||||||||||||
| 3686 | |||||||||||||||||||||||||||||
| 3687 | This package may raise an error_on_call_missing exception. | ||||||||||||||||||||||||||||
| 3688 | |||||||||||||||||||||||||||||
| 3689 | B<example 1> | ||||||||||||||||||||||||||||
| 3690 | |||||||||||||||||||||||||||||
| 3691 | # given: synopsis; | ||||||||||||||||||||||||||||
| 3692 | |||||||||||||||||||||||||||||
| 3693 | my $input = { | ||||||||||||||||||||||||||||
| 3694 | throw => 'error_on_call_missing', | ||||||||||||||||||||||||||||
| 3695 | package => 'Example', | ||||||||||||||||||||||||||||
| 3696 | routine => 'execute', | ||||||||||||||||||||||||||||
| 3697 | }; | ||||||||||||||||||||||||||||
| 3698 | |||||||||||||||||||||||||||||
| 3699 | my $error = $space->catch('error', $input); | ||||||||||||||||||||||||||||
| 3700 | |||||||||||||||||||||||||||||
| 3701 | # my $name = $error->name; | ||||||||||||||||||||||||||||
| 3702 | |||||||||||||||||||||||||||||
| 3703 | # "on_call_missing" | ||||||||||||||||||||||||||||
| 3704 | |||||||||||||||||||||||||||||
| 3705 | # my $message = $error->render; | ||||||||||||||||||||||||||||
| 3706 | |||||||||||||||||||||||||||||
| 3707 | # "Unable to locate class method \"execute\" via package \"Example\"" | ||||||||||||||||||||||||||||
| 3708 | |||||||||||||||||||||||||||||
| 3709 | # my $package = $error->stash('package'); | ||||||||||||||||||||||||||||
| 3710 | |||||||||||||||||||||||||||||
| 3711 | # "Example" | ||||||||||||||||||||||||||||
| 3712 | |||||||||||||||||||||||||||||
| 3713 | # my $routine = $error->stash('routine'); | ||||||||||||||||||||||||||||
| 3714 | |||||||||||||||||||||||||||||
| 3715 | # "execute" | ||||||||||||||||||||||||||||
| 3716 | |||||||||||||||||||||||||||||
| 3717 | =back | ||||||||||||||||||||||||||||
| 3718 | |||||||||||||||||||||||||||||
| 3719 | =over 4 | ||||||||||||||||||||||||||||
| 3720 | |||||||||||||||||||||||||||||
| 3721 | =item error: C<error_on_call_undefined> | ||||||||||||||||||||||||||||
| 3722 | |||||||||||||||||||||||||||||
| 3723 | This package may raise an error_on_call_undefined exception. | ||||||||||||||||||||||||||||
| 3724 | |||||||||||||||||||||||||||||
| 3725 | B<example 1> | ||||||||||||||||||||||||||||
| 3726 | |||||||||||||||||||||||||||||
| 3727 | # given: synopsis; | ||||||||||||||||||||||||||||
| 3728 | |||||||||||||||||||||||||||||
| 3729 | my $input = { | ||||||||||||||||||||||||||||
| 3730 | throw => 'error_on_call_undefined', | ||||||||||||||||||||||||||||
| 3731 | package => 'Example', | ||||||||||||||||||||||||||||
| 3732 | routine => 'execute', | ||||||||||||||||||||||||||||
| 3733 | }; | ||||||||||||||||||||||||||||
| 3734 | |||||||||||||||||||||||||||||
| 3735 | my $error = $space->catch('error', $input); | ||||||||||||||||||||||||||||
| 3736 | |||||||||||||||||||||||||||||
| 3737 | # my $name = $error->name; | ||||||||||||||||||||||||||||
| 3738 | |||||||||||||||||||||||||||||
| 3739 | # "on_call_undefined" | ||||||||||||||||||||||||||||
| 3740 | |||||||||||||||||||||||||||||
| 3741 | # my $message = $error->render; | ||||||||||||||||||||||||||||
| 3742 | |||||||||||||||||||||||||||||
| 3743 | # "Attempt to call undefined class method in package \"Example\"" | ||||||||||||||||||||||||||||
| 3744 | |||||||||||||||||||||||||||||
| 3745 | # my $package = $error->stash('package'); | ||||||||||||||||||||||||||||
| 3746 | |||||||||||||||||||||||||||||
| 3747 | # "Example" | ||||||||||||||||||||||||||||
| 3748 | |||||||||||||||||||||||||||||
| 3749 | # my $routine = $error->stash('routine'); | ||||||||||||||||||||||||||||
| 3750 | |||||||||||||||||||||||||||||
| 3751 | # "execute" | ||||||||||||||||||||||||||||
| 3752 | |||||||||||||||||||||||||||||
| 3753 | =back | ||||||||||||||||||||||||||||
| 3754 | |||||||||||||||||||||||||||||
| 3755 | =over 4 | ||||||||||||||||||||||||||||
| 3756 | |||||||||||||||||||||||||||||
| 3757 | =item error: C<error_on_cop_missing> | ||||||||||||||||||||||||||||
| 3758 | |||||||||||||||||||||||||||||
| 3759 | This package may raise an error_on_cop_missing exception. | ||||||||||||||||||||||||||||
| 3760 | |||||||||||||||||||||||||||||
| 3761 | B<example 1> | ||||||||||||||||||||||||||||
| 3762 | |||||||||||||||||||||||||||||
| 3763 | # given: synopsis; | ||||||||||||||||||||||||||||
| 3764 | |||||||||||||||||||||||||||||
| 3765 | my $input = { | ||||||||||||||||||||||||||||
| 3766 | throw => 'error_on_cop_missing', | ||||||||||||||||||||||||||||
| 3767 | package => 'Example', | ||||||||||||||||||||||||||||
| 3768 | routine => 'execute', | ||||||||||||||||||||||||||||
| 3769 | }; | ||||||||||||||||||||||||||||
| 3770 | |||||||||||||||||||||||||||||
| 3771 | my $error = $space->catch('error', $input); | ||||||||||||||||||||||||||||
| 3772 | |||||||||||||||||||||||||||||
| 3773 | # my $name = $error->name; | ||||||||||||||||||||||||||||
| 3774 | |||||||||||||||||||||||||||||
| 3775 | # "on_cop_missing" | ||||||||||||||||||||||||||||
| 3776 | |||||||||||||||||||||||||||||
| 3777 | # my $message = $error->render; | ||||||||||||||||||||||||||||
| 3778 | |||||||||||||||||||||||||||||
| 3779 | # "Unable to locate object method \"execute\" via package \"Example\"" | ||||||||||||||||||||||||||||
| 3780 | |||||||||||||||||||||||||||||
| 3781 | # my $package = $error->stash('package'); | ||||||||||||||||||||||||||||
| 3782 | |||||||||||||||||||||||||||||
| 3783 | # "Example" | ||||||||||||||||||||||||||||
| 3784 | |||||||||||||||||||||||||||||
| 3785 | # my $routine = $error->stash('routine'); | ||||||||||||||||||||||||||||
| 3786 | |||||||||||||||||||||||||||||
| 3787 | # "execute" | ||||||||||||||||||||||||||||
| 3788 | |||||||||||||||||||||||||||||
| 3789 | =back | ||||||||||||||||||||||||||||
| 3790 | |||||||||||||||||||||||||||||
| 3791 | =over 4 | ||||||||||||||||||||||||||||
| 3792 | |||||||||||||||||||||||||||||
| 3793 | =item error: C<error_on_cop_undefined> | ||||||||||||||||||||||||||||
| 3794 | |||||||||||||||||||||||||||||
| 3795 | This package may raise an error_on_cop_undefined exception. | ||||||||||||||||||||||||||||
| 3796 | |||||||||||||||||||||||||||||
| 3797 | B<example 1> | ||||||||||||||||||||||||||||
| 3798 | |||||||||||||||||||||||||||||
| 3799 | # given: synopsis; | ||||||||||||||||||||||||||||
| 3800 | |||||||||||||||||||||||||||||
| 3801 | my $input = { | ||||||||||||||||||||||||||||
| 3802 | throw => 'error_on_cop_undefined', | ||||||||||||||||||||||||||||
| 3803 | package => 'Example', | ||||||||||||||||||||||||||||
| 3804 | routine => 'execute', | ||||||||||||||||||||||||||||
| 3805 | }; | ||||||||||||||||||||||||||||
| 3806 | |||||||||||||||||||||||||||||
| 3807 | my $error = $space->catch('error', $input); | ||||||||||||||||||||||||||||
| 3808 | |||||||||||||||||||||||||||||
| 3809 | # my $name = $error->name; | ||||||||||||||||||||||||||||
| 3810 | |||||||||||||||||||||||||||||
| 3811 | # "on_cop_undefined" | ||||||||||||||||||||||||||||
| 3812 | |||||||||||||||||||||||||||||
| 3813 | # my $message = $error->render; | ||||||||||||||||||||||||||||
| 3814 | |||||||||||||||||||||||||||||
| 3815 | # "Attempt to cop undefined object method from package \"$class\"" | ||||||||||||||||||||||||||||
| 3816 | |||||||||||||||||||||||||||||
| 3817 | # my $package = $error->stash('package'); | ||||||||||||||||||||||||||||
| 3818 | |||||||||||||||||||||||||||||
| 3819 | # "Example" | ||||||||||||||||||||||||||||
| 3820 | |||||||||||||||||||||||||||||
| 3821 | # my $routine = $error->stash('routine'); | ||||||||||||||||||||||||||||
| 3822 | |||||||||||||||||||||||||||||
| 3823 | # "execute" | ||||||||||||||||||||||||||||
| 3824 | |||||||||||||||||||||||||||||
| 3825 | =back | ||||||||||||||||||||||||||||
| 3826 | |||||||||||||||||||||||||||||
| 3827 | =over 4 | ||||||||||||||||||||||||||||
| 3828 | |||||||||||||||||||||||||||||
| 3829 | =item error: C<error_on_eval> | ||||||||||||||||||||||||||||
| 3830 | |||||||||||||||||||||||||||||
| 3831 | This package may raise an error_on_eval exception. | ||||||||||||||||||||||||||||
| 3832 | |||||||||||||||||||||||||||||
| 3833 | B<example 1> | ||||||||||||||||||||||||||||
| 3834 | |||||||||||||||||||||||||||||
| 3835 | # given: synopsis; | ||||||||||||||||||||||||||||
| 3836 | |||||||||||||||||||||||||||||
| 3837 | my $input = { | ||||||||||||||||||||||||||||
| 3838 | throw => 'error_on_eval', | ||||||||||||||||||||||||||||
| 3839 | error => 'Exception!', | ||||||||||||||||||||||||||||
| 3840 | package => 'Example', | ||||||||||||||||||||||||||||
| 3841 | }; | ||||||||||||||||||||||||||||
| 3842 | |||||||||||||||||||||||||||||
| 3843 | my $error = $space->catch('error', $input); | ||||||||||||||||||||||||||||
| 3844 | |||||||||||||||||||||||||||||
| 3845 | # my $name = $error->name; | ||||||||||||||||||||||||||||
| 3846 | |||||||||||||||||||||||||||||
| 3847 | # "on_eval" | ||||||||||||||||||||||||||||
| 3848 | |||||||||||||||||||||||||||||
| 3849 | # my $message = $error->render; | ||||||||||||||||||||||||||||
| 3850 | |||||||||||||||||||||||||||||
| 3851 | # "Exception!" | ||||||||||||||||||||||||||||
| 3852 | |||||||||||||||||||||||||||||
| 3853 | # my $package = $error->stash('package'); | ||||||||||||||||||||||||||||
| 3854 | |||||||||||||||||||||||||||||
| 3855 | # "Example" | ||||||||||||||||||||||||||||
| 3856 | |||||||||||||||||||||||||||||
| 3857 | =back | ||||||||||||||||||||||||||||
| 3858 | |||||||||||||||||||||||||||||
| 3859 | =over 4 | ||||||||||||||||||||||||||||
| 3860 | |||||||||||||||||||||||||||||
| 3861 | =item error: C<error_on_load> | ||||||||||||||||||||||||||||
| 3862 | |||||||||||||||||||||||||||||
| 3863 | This package may raise an error_on_load exception. | ||||||||||||||||||||||||||||
| 3864 | |||||||||||||||||||||||||||||
| 3865 | B<example 1> | ||||||||||||||||||||||||||||
| 3866 | |||||||||||||||||||||||||||||
| 3867 | # given: synopsis; | ||||||||||||||||||||||||||||
| 3868 | |||||||||||||||||||||||||||||
| 3869 | my $input = { | ||||||||||||||||||||||||||||
| 3870 | throw => 'error_on_load', | ||||||||||||||||||||||||||||
| 3871 | package => 'Example', | ||||||||||||||||||||||||||||
| 3872 | error => 'cause unknown', | ||||||||||||||||||||||||||||
| 3873 | }; | ||||||||||||||||||||||||||||
| 3874 | |||||||||||||||||||||||||||||
| 3875 | my $error = $space->catch('error', $input); | ||||||||||||||||||||||||||||
| 3876 | |||||||||||||||||||||||||||||
| 3877 | # my $name = $error->name; | ||||||||||||||||||||||||||||
| 3878 | |||||||||||||||||||||||||||||
| 3879 | # "on_load" | ||||||||||||||||||||||||||||
| 3880 | |||||||||||||||||||||||||||||
| 3881 | # my $message = $error->render; | ||||||||||||||||||||||||||||
| 3882 | |||||||||||||||||||||||||||||
| 3883 | # "Error attempting to load Example: \"cause unknown\"" | ||||||||||||||||||||||||||||
| 3884 | |||||||||||||||||||||||||||||
| 3885 | # my $package = $error->stash('package'); | ||||||||||||||||||||||||||||
| 3886 | |||||||||||||||||||||||||||||
| 3887 | # "Example" | ||||||||||||||||||||||||||||
| 3888 | |||||||||||||||||||||||||||||
| 3889 | =back | ||||||||||||||||||||||||||||
| 3890 | |||||||||||||||||||||||||||||
| 3891 | =over 4 | ||||||||||||||||||||||||||||
| 3892 | |||||||||||||||||||||||||||||
| 3893 | =item error: C<error_on_swap> | ||||||||||||||||||||||||||||
| 3894 | |||||||||||||||||||||||||||||
| 3895 | This package may raise an error_on_swap exception. | ||||||||||||||||||||||||||||
| 3896 | |||||||||||||||||||||||||||||
| 3897 | B<example 1> | ||||||||||||||||||||||||||||
| 3898 | |||||||||||||||||||||||||||||
| 3899 | # given: synopsis; | ||||||||||||||||||||||||||||
| 3900 | |||||||||||||||||||||||||||||
| 3901 | my $input = { | ||||||||||||||||||||||||||||
| 3902 | throw => 'error_on_swap', | ||||||||||||||||||||||||||||
| 3903 | package => 'Example', | ||||||||||||||||||||||||||||
| 3904 | routine => 'execute', | ||||||||||||||||||||||||||||
| 3905 | }; | ||||||||||||||||||||||||||||
| 3906 | |||||||||||||||||||||||||||||
| 3907 | my $error = $space->catch('error', $input); | ||||||||||||||||||||||||||||
| 3908 | |||||||||||||||||||||||||||||
| 3909 | # my $name = $error->name; | ||||||||||||||||||||||||||||
| 3910 | |||||||||||||||||||||||||||||
| 3911 | # "on_swap" | ||||||||||||||||||||||||||||
| 3912 | |||||||||||||||||||||||||||||
| 3913 | # my $message = $error->render; | ||||||||||||||||||||||||||||
| 3914 | |||||||||||||||||||||||||||||
| 3915 | # "Attempt to swap undefined subroutine in package \"$class\"" | ||||||||||||||||||||||||||||
| 3916 | |||||||||||||||||||||||||||||
| 3917 | # my $package = $error->stash('package'); | ||||||||||||||||||||||||||||
| 3918 | |||||||||||||||||||||||||||||
| 3919 | # "Example" | ||||||||||||||||||||||||||||
| 3920 | |||||||||||||||||||||||||||||
| 3921 | # my $routine = $error->stash('routine'); | ||||||||||||||||||||||||||||
| 3922 | |||||||||||||||||||||||||||||
| 3923 | # "execute" | ||||||||||||||||||||||||||||
| 3924 | |||||||||||||||||||||||||||||
| 3925 | =back | ||||||||||||||||||||||||||||
| 3926 | |||||||||||||||||||||||||||||
| 3927 | =head1 AUTHORS | ||||||||||||||||||||||||||||
| 3928 | |||||||||||||||||||||||||||||
| 3929 | Awncorp, C<awncorp@cpan.org> | ||||||||||||||||||||||||||||
| 3930 | |||||||||||||||||||||||||||||
| 3931 | =cut | ||||||||||||||||||||||||||||
| 3932 | |||||||||||||||||||||||||||||
| 3933 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 3934 | |||||||||||||||||||||||||||||
| 3935 | Copyright (C) 2000, Awncorp, C<awncorp@cpan.org>. | ||||||||||||||||||||||||||||
| 3936 | |||||||||||||||||||||||||||||
| 3937 | This program is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 3938 | the terms of the Apache license version 2.0. | ||||||||||||||||||||||||||||
| 3939 | |||||||||||||||||||||||||||||
| 3940 | =cut | ||||||||||||||||||||||||||||