| 1 | package Venus::Name; | ||||||||||||
| 2 | |||||||||||||
| 3 | 5 | ▶ | use 5.018; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | 5 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 5 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 5 | ▶ | use Venus::Class; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | 5 | base 'Venus::Kind::Utility'; | |||||||||||
| 11 | |||||||||||||
| 12 | 5 | with 'Venus::Role::Accessible'; | |||||||||||
| 13 | 5 | with 'Venus::Role::Explainable'; | |||||||||||
| 14 | |||||||||||||
| 15 | use overload ( | ||||||||||||
| 16 | '""' => 'explain', | ||||||||||||
| 17 | 1 | ▶ | '.' => sub{$_[0]->value . "$_[1]"}, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | 2 | ▶ | 'eq' => sub{$_[0]->value eq "$_[1]"}, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | 2 | ▶ | 'ne' => sub{$_[0]->value ne "$_[1]"}, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 20 | 1 | ▶ | 'qr' => sub{qr/@{[quotemeta($_[0]->value)]}/}, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 21 | 5 | '~~' => 'explain', | |||||||||||
| 22 | fallback => 1, | ||||||||||||
| 23 | 5 | ▶ | ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 24 | |||||||||||||
| 25 | 5 | my $sep = qr/'|__|::|\\|\//; | |||||||||||
| 26 | |||||||||||||
| 27 | # BUILDERS | ||||||||||||
| 28 | |||||||||||||
| 29 | sub build_arg { | ||||||||||||
| 30 | 122 | ▶ | my ($self, $data) = @_; | ||||||||||
|
Subroutine
build_arg: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 31 | |||||||||||||
| 32 | return { | ||||||||||||
| 33 | 122 | value => $data, | |||||||||||
| 34 | }; | ||||||||||||
| 35 | } | ||||||||||||
| 36 | |||||||||||||
| 37 | # METHODS | ||||||||||||
| 38 | |||||||||||||
| 39 | sub default { | ||||||||||||
| 40 | 3 | ▶ | return 'Venus'; | ||||||||||
|
Subroutine
default: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 41 | } | ||||||||||||
| 42 | |||||||||||||
| 43 | sub dist { | ||||||||||||
| 44 | 1 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
dist: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 45 | |||||||||||||
| 46 | 1 | return $self->label =~ s/_/-/gr; | |||||||||||
| 47 | } | ||||||||||||
| 48 | |||||||||||||
| 49 | sub explain { | ||||||||||||
| 50 | 8 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
explain: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 51 | |||||||||||||
| 52 | 8 | return $self->get; | |||||||||||
| 53 | } | ||||||||||||
| 54 | |||||||||||||
| 55 | sub file { | ||||||||||||
| 56 | 2 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
file: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||
| 57 | |||||||||||||
| 58 | 2 | ▶ | return $self->get if $self->lookslike_a_file; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 59 | |||||||||||||
| 60 | 2 | my $string = $self->package; | |||||||||||
| 61 | |||||||||||||
| 62 | return join '__', map { | ||||||||||||
| 63 | 2 | join '_', map {lc} map {split /_/} grep {length} | |||||||||||
| 64 | split /([A-Z]{1}[^A-Z]*)/ | ||||||||||||
| 65 | } split /$sep/, $string; | ||||||||||||
| 66 | } | ||||||||||||
| 67 | |||||||||||||
| 68 | sub format { | ||||||||||||
| 69 | 6 | ▶ | my ($self, $method, $format) = @_; | ||||||||||
|
Subroutine
format: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||
| 70 | |||||||||||||
| 71 | 6 | my $string = $self->$method; | |||||||||||
| 72 | |||||||||||||
| 73 | 6 | ▶ | return sprintf($format || '%s', $string); | ||||||||||
|
Condition50%1/2
$format || '%s'
MC/DC0%0/1
$format || '%s'
$format
Truth table50%1/2
A
A= $format
| |||||||||||||
| 74 | } | ||||||||||||
| 75 | |||||||||||||
| 76 | sub label { | ||||||||||||
| 77 | 4 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
label: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 78 | |||||||||||||
| 79 | 4 | ▶ | return $self->get if $self->lookslike_a_label; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 80 | |||||||||||||
| 81 | 3 | return join '_', split /$sep/, $self->package; | |||||||||||
| 82 | } | ||||||||||||
| 83 | |||||||||||||
| 84 | sub lookslike_a_file { | ||||||||||||
| 85 | 3 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
lookslike_a_file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 86 | |||||||||||||
| 87 | 3 | my $string = $self->get; | |||||||||||
| 88 | |||||||||||||
| 89 | 3 | return $string =~ /^[a-z](?:\w*[a-z])?$/; | |||||||||||
| 90 | } | ||||||||||||
| 91 | |||||||||||||
| 92 | sub lookslike_a_label { | ||||||||||||
| 93 | 5 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
lookslike_a_label: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 94 | |||||||||||||
| 95 | 5 | my $string = $self->get; | |||||||||||
| 96 | |||||||||||||
| 97 | 5 | return $string =~ /^[A-Z](?:\w*[a-zA-Z0-9])?$/; | |||||||||||
| 98 | } | ||||||||||||
| 99 | |||||||||||||
| 100 | sub lookslike_a_package { | ||||||||||||
| 101 | 118 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
lookslike_a_package: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 102 | |||||||||||||
| 103 | 118 | my $string = $self->get; | |||||||||||
| 104 | |||||||||||||
| 105 | 118 | return $string =~ /^[A-Z](?:(?:\w|::)*[a-zA-Z0-9])?$/; | |||||||||||
| 106 | } | ||||||||||||
| 107 | |||||||||||||
| 108 | sub lookslike_a_path { | ||||||||||||
| 109 | 33 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
lookslike_a_path: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 110 | |||||||||||||
| 111 | 33 | my $string = $self->get; | |||||||||||
| 112 | |||||||||||||
| 113 | 33 | return $string =~ /^[A-Z](?:(?:\w|\\|\/|[\:\.]{1}[a-zA-Z0-9])*[a-zA-Z0-9])?$/; | |||||||||||
| 114 | } | ||||||||||||
| 115 | |||||||||||||
| 116 | sub lookslike_a_pragma { | ||||||||||||
| 117 | 97 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
lookslike_a_pragma: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 118 | |||||||||||||
| 119 | 97 | my $string = $self->get; | |||||||||||
| 120 | |||||||||||||
| 121 | 97 | return $string =~ /^\[\w+\]$/; | |||||||||||
| 122 | } | ||||||||||||
| 123 | |||||||||||||
| 124 | sub package { | ||||||||||||
| 125 | 117 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
package: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||
| 126 | |||||||||||||
| 127 | 117 | ▶ | return $self->get if $self->lookslike_a_package; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 128 | |||||||||||||
| 129 | 96 | ▶ | return substr($self->get, 1, -1) if $self->lookslike_a_pragma; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 130 | |||||||||||||
| 131 | 96 | my $string = $self->get; | |||||||||||
| 132 | |||||||||||||
| 133 | 96 | ▶ | if ($string !~ $sep) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 134 | 35 | return join '', map {ucfirst} split /[^a-zA-Z0-9]/, $string; | |||||||||||
| 135 | } else { | ||||||||||||
| 136 | return join '::', map { | ||||||||||||
| 137 | 61 | join '', map {ucfirst} split /[^a-zA-Z0-9]/ | |||||||||||
| 138 | } split /$sep/, $string; | ||||||||||||
| 139 | } | ||||||||||||
| 140 | } | ||||||||||||
| 141 | |||||||||||||
| 142 | sub path { | ||||||||||||
| 143 | 32 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
path: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 144 | |||||||||||||
| 145 | 32 | ▶ | return $self->get if $self->lookslike_a_path; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 146 | |||||||||||||
| 147 | 30 | return join '/', split /$sep/, $self->package; | |||||||||||
| 148 | } | ||||||||||||
| 149 | |||||||||||||
| 150 | 5 | 1; | |||||||||||
| 151 | |||||||||||||
| 152 | |||||||||||||
| 153 | |||||||||||||
| 154 | =head1 NAME | ||||||||||||
| 155 | |||||||||||||
| 156 | Venus::Name - Name Class | ||||||||||||
| 157 | |||||||||||||
| 158 | =cut | ||||||||||||
| 159 | |||||||||||||
| 160 | =head1 ABSTRACT | ||||||||||||
| 161 | |||||||||||||
| 162 | Name Class for Perl 5 | ||||||||||||
| 163 | |||||||||||||
| 164 | =cut | ||||||||||||
| 165 | |||||||||||||
| 166 | =head1 SYNOPSIS | ||||||||||||
| 167 | |||||||||||||
| 168 | package main; | ||||||||||||
| 169 | |||||||||||||
| 170 | use Venus::Name; | ||||||||||||
| 171 | |||||||||||||
| 172 | my $name = Venus::Name->new('Foo/Bar'); | ||||||||||||
| 173 | |||||||||||||
| 174 | # $name->package; | ||||||||||||
| 175 | |||||||||||||
| 176 | =cut | ||||||||||||
| 177 | |||||||||||||
| 178 | =head1 DESCRIPTION | ||||||||||||
| 179 | |||||||||||||
| 180 | This package provides methods for parsing and formatting package namespace | ||||||||||||
| 181 | strings. | ||||||||||||
| 182 | |||||||||||||
| 183 | =cut | ||||||||||||
| 184 | |||||||||||||
| 185 | =head1 INHERITS | ||||||||||||
| 186 | |||||||||||||
| 187 | This package inherits behaviors from: | ||||||||||||
| 188 | |||||||||||||
| 189 | L<Venus::Kind::Utility> | ||||||||||||
| 190 | |||||||||||||
| 191 | =cut | ||||||||||||
| 192 | |||||||||||||
| 193 | =head1 INTEGRATES | ||||||||||||
| 194 | |||||||||||||
| 195 | This package integrates behaviors from: | ||||||||||||
| 196 | |||||||||||||
| 197 | L<Venus::Role::Accessible> | ||||||||||||
| 198 | |||||||||||||
| 199 | L<Venus::Role::Explainable> | ||||||||||||
| 200 | |||||||||||||
| 201 | =cut | ||||||||||||
| 202 | |||||||||||||
| 203 | =head1 METHODS | ||||||||||||
| 204 | |||||||||||||
| 205 | This package provides the following methods: | ||||||||||||
| 206 | |||||||||||||
| 207 | =cut | ||||||||||||
| 208 | |||||||||||||
| 209 | =head2 default | ||||||||||||
| 210 | |||||||||||||
| 211 | default() (Str) | ||||||||||||
| 212 | |||||||||||||
| 213 | The default method returns the default value, i.e. C<'Venus'>. | ||||||||||||
| 214 | |||||||||||||
| 215 | I<Since C<0.01>> | ||||||||||||
| 216 | |||||||||||||
| 217 | =over 4 | ||||||||||||
| 218 | |||||||||||||
| 219 | =item default example 1 | ||||||||||||
| 220 | |||||||||||||
| 221 | # given: synopsis; | ||||||||||||
| 222 | |||||||||||||
| 223 | my $default = $name->default; | ||||||||||||
| 224 | |||||||||||||
| 225 | # "Venus" | ||||||||||||
| 226 | |||||||||||||
| 227 | =back | ||||||||||||
| 228 | |||||||||||||
| 229 | =cut | ||||||||||||
| 230 | |||||||||||||
| 231 | =head2 dist | ||||||||||||
| 232 | |||||||||||||
| 233 | dist() (Str) | ||||||||||||
| 234 | |||||||||||||
| 235 | The dist method returns a package distribution representation of the name. | ||||||||||||
| 236 | |||||||||||||
| 237 | I<Since C<0.01>> | ||||||||||||
| 238 | |||||||||||||
| 239 | =over 4 | ||||||||||||
| 240 | |||||||||||||
| 241 | =item dist example 1 | ||||||||||||
| 242 | |||||||||||||
| 243 | # given: synopsis; | ||||||||||||
| 244 | |||||||||||||
| 245 | my $dist = $name->dist; | ||||||||||||
| 246 | |||||||||||||
| 247 | # "Foo-Bar" | ||||||||||||
| 248 | |||||||||||||
| 249 | =back | ||||||||||||
| 250 | |||||||||||||
| 251 | =cut | ||||||||||||
| 252 | |||||||||||||
| 253 | =head2 explain | ||||||||||||
| 254 | |||||||||||||
| 255 | explain() (Str) | ||||||||||||
| 256 | |||||||||||||
| 257 | The explain method returns the package name and is used in stringification | ||||||||||||
| 258 | operations. | ||||||||||||
| 259 | |||||||||||||
| 260 | I<Since C<0.01>> | ||||||||||||
| 261 | |||||||||||||
| 262 | =over 4 | ||||||||||||
| 263 | |||||||||||||
| 264 | =item explain example 1 | ||||||||||||
| 265 | |||||||||||||
| 266 | # given: synopsis; | ||||||||||||
| 267 | |||||||||||||
| 268 | my $explain = $name->explain; | ||||||||||||
| 269 | |||||||||||||
| 270 | # "Foo/Bar" | ||||||||||||
| 271 | |||||||||||||
| 272 | =back | ||||||||||||
| 273 | |||||||||||||
| 274 | =cut | ||||||||||||
| 275 | |||||||||||||
| 276 | =head2 file | ||||||||||||
| 277 | |||||||||||||
| 278 | file() (Str) | ||||||||||||
| 279 | |||||||||||||
| 280 | The file method returns a file representation of the name. | ||||||||||||
| 281 | |||||||||||||
| 282 | I<Since C<0.01>> | ||||||||||||
| 283 | |||||||||||||
| 284 | =over 4 | ||||||||||||
| 285 | |||||||||||||
| 286 | =item file example 1 | ||||||||||||
| 287 | |||||||||||||
| 288 | # given: synopsis; | ||||||||||||
| 289 | |||||||||||||
| 290 | my $file = $name->file; | ||||||||||||
| 291 | |||||||||||||
| 292 | # "foo__bar" | ||||||||||||
| 293 | |||||||||||||
| 294 | =back | ||||||||||||
| 295 | |||||||||||||
| 296 | =cut | ||||||||||||
| 297 | |||||||||||||
| 298 | =head2 format | ||||||||||||
| 299 | |||||||||||||
| 300 | format(Str $method, Str $format) (Str) | ||||||||||||
| 301 | |||||||||||||
| 302 | The format method calls the specified method passing the result to the core | ||||||||||||
| 303 | L</sprintf> function with itself as an argument. This method supports | ||||||||||||
| 304 | dispatching, i.e. providing a method name and arguments whose return value will | ||||||||||||
| 305 | be acted on by this method. | ||||||||||||
| 306 | |||||||||||||
| 307 | I<Since C<0.01>> | ||||||||||||
| 308 | |||||||||||||
| 309 | =over 4 | ||||||||||||
| 310 | |||||||||||||
| 311 | =item format example 1 | ||||||||||||
| 312 | |||||||||||||
| 313 | # given: synopsis; | ||||||||||||
| 314 | |||||||||||||
| 315 | my $format = $name->format('file', '%s.t'); | ||||||||||||
| 316 | |||||||||||||
| 317 | # "foo__bar.t" | ||||||||||||
| 318 | |||||||||||||
| 319 | =back | ||||||||||||
| 320 | |||||||||||||
| 321 | =cut | ||||||||||||
| 322 | |||||||||||||
| 323 | =head2 label | ||||||||||||
| 324 | |||||||||||||
| 325 | label() (Str) | ||||||||||||
| 326 | |||||||||||||
| 327 | The label method returns a label (or constant) representation of the name. | ||||||||||||
| 328 | |||||||||||||
| 329 | I<Since C<0.01>> | ||||||||||||
| 330 | |||||||||||||
| 331 | =over 4 | ||||||||||||
| 332 | |||||||||||||
| 333 | =item label example 1 | ||||||||||||
| 334 | |||||||||||||
| 335 | # given: synopsis; | ||||||||||||
| 336 | |||||||||||||
| 337 | my $label = $name->label; | ||||||||||||
| 338 | |||||||||||||
| 339 | # "Foo_Bar" | ||||||||||||
| 340 | |||||||||||||
| 341 | =back | ||||||||||||
| 342 | |||||||||||||
| 343 | =cut | ||||||||||||
| 344 | |||||||||||||
| 345 | =head2 lookslike_a_file | ||||||||||||
| 346 | |||||||||||||
| 347 | lookslike_a_file() (Str) | ||||||||||||
| 348 | |||||||||||||
| 349 | The lookslike_a_file method returns truthy if its state resembles a filename. | ||||||||||||
| 350 | |||||||||||||
| 351 | I<Since C<0.01>> | ||||||||||||
| 352 | |||||||||||||
| 353 | =over 4 | ||||||||||||
| 354 | |||||||||||||
| 355 | =item lookslike_a_file example 1 | ||||||||||||
| 356 | |||||||||||||
| 357 | # given: synopsis; | ||||||||||||
| 358 | |||||||||||||
| 359 | my $lookslike_a_file = $name->lookslike_a_file; | ||||||||||||
| 360 | |||||||||||||
| 361 | # "" | ||||||||||||
| 362 | |||||||||||||
| 363 | =back | ||||||||||||
| 364 | |||||||||||||
| 365 | =cut | ||||||||||||
| 366 | |||||||||||||
| 367 | =head2 lookslike_a_label | ||||||||||||
| 368 | |||||||||||||
| 369 | lookslike_a_label() (Str) | ||||||||||||
| 370 | |||||||||||||
| 371 | The lookslike_a_label method returns truthy if its state resembles a label (or | ||||||||||||
| 372 | constant). | ||||||||||||
| 373 | |||||||||||||
| 374 | I<Since C<0.01>> | ||||||||||||
| 375 | |||||||||||||
| 376 | =over 4 | ||||||||||||
| 377 | |||||||||||||
| 378 | =item lookslike_a_label example 1 | ||||||||||||
| 379 | |||||||||||||
| 380 | # given: synopsis; | ||||||||||||
| 381 | |||||||||||||
| 382 | my $lookslike_a_label = $name->lookslike_a_label; | ||||||||||||
| 383 | |||||||||||||
| 384 | # "" | ||||||||||||
| 385 | |||||||||||||
| 386 | =back | ||||||||||||
| 387 | |||||||||||||
| 388 | =cut | ||||||||||||
| 389 | |||||||||||||
| 390 | =head2 lookslike_a_package | ||||||||||||
| 391 | |||||||||||||
| 392 | lookslike_a_package() (Str) | ||||||||||||
| 393 | |||||||||||||
| 394 | The lookslike_a_package method returns truthy if its state resembles a package | ||||||||||||
| 395 | name. | ||||||||||||
| 396 | |||||||||||||
| 397 | I<Since C<0.01>> | ||||||||||||
| 398 | |||||||||||||
| 399 | =over 4 | ||||||||||||
| 400 | |||||||||||||
| 401 | =item lookslike_a_package example 1 | ||||||||||||
| 402 | |||||||||||||
| 403 | # given: synopsis; | ||||||||||||
| 404 | |||||||||||||
| 405 | my $lookslike_a_package = $name->lookslike_a_package; | ||||||||||||
| 406 | |||||||||||||
| 407 | # "" | ||||||||||||
| 408 | |||||||||||||
| 409 | =back | ||||||||||||
| 410 | |||||||||||||
| 411 | =cut | ||||||||||||
| 412 | |||||||||||||
| 413 | =head2 lookslike_a_path | ||||||||||||
| 414 | |||||||||||||
| 415 | lookslike_a_path() (Str) | ||||||||||||
| 416 | |||||||||||||
| 417 | The lookslike_a_path method returns truthy if its state resembles a file path. | ||||||||||||
| 418 | |||||||||||||
| 419 | I<Since C<0.01>> | ||||||||||||
| 420 | |||||||||||||
| 421 | =over 4 | ||||||||||||
| 422 | |||||||||||||
| 423 | =item lookslike_a_path example 1 | ||||||||||||
| 424 | |||||||||||||
| 425 | # given: synopsis; | ||||||||||||
| 426 | |||||||||||||
| 427 | my $lookslike_a_path = $name->lookslike_a_path; | ||||||||||||
| 428 | |||||||||||||
| 429 | # 1 | ||||||||||||
| 430 | |||||||||||||
| 431 | =back | ||||||||||||
| 432 | |||||||||||||
| 433 | =cut | ||||||||||||
| 434 | |||||||||||||
| 435 | =head2 lookslike_a_pragma | ||||||||||||
| 436 | |||||||||||||
| 437 | lookslike_a_pragma() (Str) | ||||||||||||
| 438 | |||||||||||||
| 439 | The lookslike_a_pragma method returns truthy if its state resembles a pragma. | ||||||||||||
| 440 | |||||||||||||
| 441 | I<Since C<0.01>> | ||||||||||||
| 442 | |||||||||||||
| 443 | =over 4 | ||||||||||||
| 444 | |||||||||||||
| 445 | =item lookslike_a_pragma example 1 | ||||||||||||
| 446 | |||||||||||||
| 447 | # given: synopsis; | ||||||||||||
| 448 | |||||||||||||
| 449 | my $lookslike_a_pragma = $name->lookslike_a_pragma; | ||||||||||||
| 450 | |||||||||||||
| 451 | # "" | ||||||||||||
| 452 | |||||||||||||
| 453 | =back | ||||||||||||
| 454 | |||||||||||||
| 455 | =cut | ||||||||||||
| 456 | |||||||||||||
| 457 | =head2 package | ||||||||||||
| 458 | |||||||||||||
| 459 | package() (Str) | ||||||||||||
| 460 | |||||||||||||
| 461 | The package method returns a package name representation of the name given. | ||||||||||||
| 462 | |||||||||||||
| 463 | I<Since C<0.01>> | ||||||||||||
| 464 | |||||||||||||
| 465 | =over 4 | ||||||||||||
| 466 | |||||||||||||
| 467 | =item package example 1 | ||||||||||||
| 468 | |||||||||||||
| 469 | # given: synopsis; | ||||||||||||
| 470 | |||||||||||||
| 471 | my $package = $name->package; | ||||||||||||
| 472 | |||||||||||||
| 473 | # "Foo::Bar" | ||||||||||||
| 474 | |||||||||||||
| 475 | =back | ||||||||||||
| 476 | |||||||||||||
| 477 | =cut | ||||||||||||
| 478 | |||||||||||||
| 479 | =head2 path | ||||||||||||
| 480 | |||||||||||||
| 481 | path() (Str) | ||||||||||||
| 482 | |||||||||||||
| 483 | The path method returns a path representation of the name. | ||||||||||||
| 484 | |||||||||||||
| 485 | I<Since C<0.01>> | ||||||||||||
| 486 | |||||||||||||
| 487 | =over 4 | ||||||||||||
| 488 | |||||||||||||
| 489 | =item path example 1 | ||||||||||||
| 490 | |||||||||||||
| 491 | # given: synopsis; | ||||||||||||
| 492 | |||||||||||||
| 493 | my $path = $name->path; | ||||||||||||
| 494 | |||||||||||||
| 495 | # "Foo/Bar" | ||||||||||||
| 496 | |||||||||||||
| 497 | =back | ||||||||||||
| 498 | |||||||||||||
| 499 | =cut | ||||||||||||
| 500 | |||||||||||||
| 501 | =head1 OPERATORS | ||||||||||||
| 502 | |||||||||||||
| 503 | This package overloads the following operators: | ||||||||||||
| 504 | |||||||||||||
| 505 | =cut | ||||||||||||
| 506 | |||||||||||||
| 507 | =over 4 | ||||||||||||
| 508 | |||||||||||||
| 509 | =item operation: C<(.)> | ||||||||||||
| 510 | |||||||||||||
| 511 | This package overloads the C<.> operator. | ||||||||||||
| 512 | |||||||||||||
| 513 | B<example 1> | ||||||||||||
| 514 | |||||||||||||
| 515 | # given: synopsis; | ||||||||||||
| 516 | |||||||||||||
| 517 | my $package = $name . 'Baz'; | ||||||||||||
| 518 | |||||||||||||
| 519 | # "Foo::BarBaz" | ||||||||||||
| 520 | |||||||||||||
| 521 | =back | ||||||||||||
| 522 | |||||||||||||
| 523 | =over 4 | ||||||||||||
| 524 | |||||||||||||
| 525 | =item operation: C<(eq)> | ||||||||||||
| 526 | |||||||||||||
| 527 | This package overloads the C<eq> operator. | ||||||||||||
| 528 | |||||||||||||
| 529 | B<example 1> | ||||||||||||
| 530 | |||||||||||||
| 531 | # given: synopsis; | ||||||||||||
| 532 | |||||||||||||
| 533 | $name eq 'Foo/Bar'; | ||||||||||||
| 534 | |||||||||||||
| 535 | # 1 | ||||||||||||
| 536 | |||||||||||||
| 537 | B<example 2> | ||||||||||||
| 538 | |||||||||||||
| 539 | package main; | ||||||||||||
| 540 | |||||||||||||
| 541 | use Venus::Name; | ||||||||||||
| 542 | |||||||||||||
| 543 | my $name1 = Venus::Name->new('Foo\Bar'); | ||||||||||||
| 544 | my $name2 = Venus::Name->new('Foo\Bar'); | ||||||||||||
| 545 | |||||||||||||
| 546 | $name1 eq $name2; | ||||||||||||
| 547 | |||||||||||||
| 548 | # 1 | ||||||||||||
| 549 | |||||||||||||
| 550 | =back | ||||||||||||
| 551 | |||||||||||||
| 552 | =over 4 | ||||||||||||
| 553 | |||||||||||||
| 554 | =item operation: C<(ne)> | ||||||||||||
| 555 | |||||||||||||
| 556 | This package overloads the C<ne> operator. | ||||||||||||
| 557 | |||||||||||||
| 558 | B<example 1> | ||||||||||||
| 559 | |||||||||||||
| 560 | # given: synopsis; | ||||||||||||
| 561 | |||||||||||||
| 562 | $name ne 'Foo\Bar'; | ||||||||||||
| 563 | |||||||||||||
| 564 | # 1 | ||||||||||||
| 565 | |||||||||||||
| 566 | B<example 2> | ||||||||||||
| 567 | |||||||||||||
| 568 | package main; | ||||||||||||
| 569 | |||||||||||||
| 570 | use Venus::Name; | ||||||||||||
| 571 | |||||||||||||
| 572 | my $name1 = Venus::Name->new('FooBar'); | ||||||||||||
| 573 | my $name2 = Venus::Name->new('Foo_Bar'); | ||||||||||||
| 574 | |||||||||||||
| 575 | $name1 ne $name2; | ||||||||||||
| 576 | |||||||||||||
| 577 | # 1 | ||||||||||||
| 578 | |||||||||||||
| 579 | =back | ||||||||||||
| 580 | |||||||||||||
| 581 | =over 4 | ||||||||||||
| 582 | |||||||||||||
| 583 | =item operation: C<(qr)> | ||||||||||||
| 584 | |||||||||||||
| 585 | This package overloads the C<qr> operator. | ||||||||||||
| 586 | |||||||||||||
| 587 | B<example 1> | ||||||||||||
| 588 | |||||||||||||
| 589 | # given: synopsis; | ||||||||||||
| 590 | |||||||||||||
| 591 | "Foo/Bar" =~ qr/$name/; | ||||||||||||
| 592 | |||||||||||||
| 593 | # 1 | ||||||||||||
| 594 | |||||||||||||
| 595 | =back | ||||||||||||
| 596 | |||||||||||||
| 597 | =over 4 | ||||||||||||
| 598 | |||||||||||||
| 599 | =item operation: C<("")> | ||||||||||||
| 600 | |||||||||||||
| 601 | This package overloads the C<""> operator. | ||||||||||||
| 602 | |||||||||||||
| 603 | B<example 1> | ||||||||||||
| 604 | |||||||||||||
| 605 | # given: synopsis; | ||||||||||||
| 606 | |||||||||||||
| 607 | my $result = "$name"; | ||||||||||||
| 608 | |||||||||||||
| 609 | # "Foo/Bar" | ||||||||||||
| 610 | |||||||||||||
| 611 | =back | ||||||||||||
| 612 | |||||||||||||
| 613 | =over 4 | ||||||||||||
| 614 | |||||||||||||
| 615 | =item operation: C<(~~)> | ||||||||||||
| 616 | |||||||||||||
| 617 | This package overloads the C<~~> operator. | ||||||||||||
| 618 | |||||||||||||
| 619 | B<example 1> | ||||||||||||
| 620 | |||||||||||||
| 621 | # given: synopsis; | ||||||||||||
| 622 | |||||||||||||
| 623 | my $result = $name ~~ 'Foo/Bar'; | ||||||||||||
| 624 | |||||||||||||
| 625 | # 1 | ||||||||||||
| 626 | |||||||||||||
| 627 | =back | ||||||||||||