| 1 | package Statocles::Person; | ||||||||||||||||||||||||||||
| 2 | 101 | our $VERSION = '0.099'; | |||||||||||||||||||||||||||
| 3 | # ABSTRACT: Information about a person, including name and e-mail | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | #pod =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 6 | #pod | ||||||||||||||||||||||||||||
| 7 | #pod # site.yml | ||||||||||||||||||||||||||||
| 8 | #pod site: | ||||||||||||||||||||||||||||
| 9 | #pod $class: Statocles::Site | ||||||||||||||||||||||||||||
| 10 | #pod author: | ||||||||||||||||||||||||||||
| 11 | #pod $class: Statocles::Person | ||||||||||||||||||||||||||||
| 12 | #pod name: Doug Bell | ||||||||||||||||||||||||||||
| 13 | #pod email: doug@example.com | ||||||||||||||||||||||||||||
| 14 | #pod | ||||||||||||||||||||||||||||
| 15 | #pod # Perl code | ||||||||||||||||||||||||||||
| 16 | #pod my $person = Statocles::Person->new( | ||||||||||||||||||||||||||||
| 17 | #pod name => 'Doug Bell', | ||||||||||||||||||||||||||||
| 18 | #pod email => 'doug@example.com', | ||||||||||||||||||||||||||||
| 19 | #pod ); | ||||||||||||||||||||||||||||
| 20 | #pod | ||||||||||||||||||||||||||||
| 21 | #pod =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 22 | #pod | ||||||||||||||||||||||||||||
| 23 | #pod This class stores information about a person, most commonly an author of | ||||||||||||||||||||||||||||
| 24 | #pod a site or a document. | ||||||||||||||||||||||||||||
| 25 | #pod | ||||||||||||||||||||||||||||
| 26 | #pod This class can parse plain strings like C<< Doug Bell <doug@example.com> >> | ||||||||||||||||||||||||||||
| 27 | #pod into an object with name and e-mail set correctly. | ||||||||||||||||||||||||||||
| 28 | #pod | ||||||||||||||||||||||||||||
| 29 | #pod Person objects stringify into the C<name> field, for | ||||||||||||||||||||||||||||
| 30 | #pod backwards-compatibility. | ||||||||||||||||||||||||||||
| 31 | #pod | ||||||||||||||||||||||||||||
| 32 | #pod =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 33 | #pod | ||||||||||||||||||||||||||||
| 34 | #pod =over | ||||||||||||||||||||||||||||
| 35 | #pod | ||||||||||||||||||||||||||||
| 36 | #pod =item L<Statocles::Document/author> | ||||||||||||||||||||||||||||
| 37 | #pod | ||||||||||||||||||||||||||||
| 38 | #pod =item L<Statocles::Site/author> | ||||||||||||||||||||||||||||
| 39 | #pod | ||||||||||||||||||||||||||||
| 40 | #pod =back | ||||||||||||||||||||||||||||
| 41 | #pod | ||||||||||||||||||||||||||||
| 42 | #pod =cut | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 101 | ▶ | use Statocles::Base 'Class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 45 | use overload | ||||||||||||||||||||||||||||
| 46 | 85 | ▶ | q{""} => sub { shift->name }, | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 47 | 101 | ; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | #pod =attr name | ||||||||||||||||||||||||||||
| 50 | #pod | ||||||||||||||||||||||||||||
| 51 | #pod The author's name. Required. | ||||||||||||||||||||||||||||
| 52 | #pod | ||||||||||||||||||||||||||||
| 53 | #pod =cut | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 101 | has name => ( | |||||||||||||||||||||||||||
| 56 | is => 'rw', | ||||||||||||||||||||||||||||
| 57 | isa => Str, | ||||||||||||||||||||||||||||
| 58 | required => 1, | ||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | #pod =attr email | ||||||||||||||||||||||||||||
| 62 | #pod | ||||||||||||||||||||||||||||
| 63 | #pod The author's email. Optional. | ||||||||||||||||||||||||||||
| 64 | #pod | ||||||||||||||||||||||||||||
| 65 | #pod =cut | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 101 | has email => ( | |||||||||||||||||||||||||||
| 68 | is => 'rw', | ||||||||||||||||||||||||||||
| 69 | isa => Str, | ||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | #pod =method new | ||||||||||||||||||||||||||||
| 73 | #pod | ||||||||||||||||||||||||||||
| 74 | #pod my $person = Statocles::Person->new( | ||||||||||||||||||||||||||||
| 75 | #pod name => 'Doug Bell', | ||||||||||||||||||||||||||||
| 76 | #pod email => 'doug@example.com', | ||||||||||||||||||||||||||||
| 77 | #pod ); | ||||||||||||||||||||||||||||
| 78 | #pod | ||||||||||||||||||||||||||||
| 79 | #pod my $person = Statocles::Person->new( 'Doug Bell <doug@example.com>' ); | ||||||||||||||||||||||||||||
| 80 | #pod | ||||||||||||||||||||||||||||
| 81 | #pod Construct a new Person object. Arguments can be a list of name/value pairs, or | ||||||||||||||||||||||||||||
| 82 | #pod a single string with the format C<< Name <email@domain> >> (the e-mail part | ||||||||||||||||||||||||||||
| 83 | #pod is optional). | ||||||||||||||||||||||||||||
| 84 | #pod | ||||||||||||||||||||||||||||
| 85 | #pod =cut | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 40 | ▶ | sub BUILDARGS { | ||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 88 | 40 | my ( $class, @args ) = @_; | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 40 | ▶ | return $args[0] if @args == 1 && ref $args[0] eq 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@args == 1 and ref $args[0] eq "HASH"
MC/DC100%2/2
@args == 1 and ref $args[0] eq "HASH"
@args == 1
ref $args[0] eq "HASH"
Truth table100%3/3
A and B
A= @args == 1B= ref $args[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 39 | ▶ | if ( @args == 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 17 | ▶ | if ( $args[0] =~ s/\s*<([^>]+)>\s*// ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 6 | @args = ( | |||||||||||||||||||||||||||
| 95 | name => $args[0], | ||||||||||||||||||||||||||||
| 96 | email => $1, | ||||||||||||||||||||||||||||
| 97 | ); | ||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | else { | ||||||||||||||||||||||||||||
| 100 | 11 | @args = ( | |||||||||||||||||||||||||||
| 101 | name => $args[0], | ||||||||||||||||||||||||||||
| 102 | ); | ||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 39 | return { @args }; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 101 | 1; | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | __END__ | ||||||||||||||||||||||||||||