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