| 1 | package Mail::SimpleList::Alias; | ||||||||||
| 2 | |||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 4 | ▶ | use Mail::Action::Address; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 4 | ▶ | use Mail::Address; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | use Class::Roles | ||||||||||
| 9 | 4 | does => 'address_expires', | |||||||||
| 10 | does => 'address_named', | ||||||||||
| 11 | 4 | ▶ | does => 'address_described'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 4 | ▶ | use vars qw( $VERSION ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 4 | $VERSION = '0.94'; | |||||||||
| 15 | |||||||||||
| 16 | sub new | ||||||||||
| 17 | { | ||||||||||
| 18 | 40 | ▶ | my $class = shift; | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 19 | 40 | bless { | |||||||||
| 20 | owner => '', | ||||||||||
| 21 | closed => 0, | ||||||||||
| 22 | expires => 0, | ||||||||||
| 23 | auto_add => 1, | ||||||||||
| 24 | description => '', | ||||||||||
| 25 | members => [], | ||||||||||
| 26 | @_ }, $class; | ||||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | sub members | ||||||||||
| 30 | { | ||||||||||
| 31 | 28 | ▶ | my $self = shift; | ||||||||
|
Subroutine
members: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 32 | 28 | return $self->{members}; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | sub add | ||||||||||
| 36 | { | ||||||||||
| 37 | 19 | ▶ | my $self = shift; | ||||||||
|
Subroutine
add: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||
| 38 | |||||||||||
| 39 | 19 | my %existing = map { $_ => 1 } @{ $self->{members} }; | |||||||||
| 40 | 19 | my $existing = @{ $self->{members} }; | |||||||||
| 41 | |||||||||||
| 42 | 19 | ▶ | while (@_) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | { | ||||||||||
| 44 | 25 | ▶ | my $address = shift or next; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 22 | chomp $address; | |||||||||
| 46 | |||||||||||
| 47 | 22 | for my $member ( Mail::Address->parse( $address )) | |||||||||
| 48 | { | ||||||||||
| 49 | 22 | $member = $member->address(); | |||||||||
| 50 | 22 | ▶ | next if exists $existing{ $member }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | 16 | push @{ $self->{members} }, $member; | |||||||||
| 52 | 16 | $existing{ $member } = 1; | |||||||||
| 53 | } | ||||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 19 | return @{ $self->{members} }[ $existing .. $#{ $self->{members} } ]; | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | sub remove_address | ||||||||||
| 60 | { | ||||||||||
| 61 | 4 | ▶ | my ($self, $remove) = @_; | ||||||||
|
Subroutine
remove_address: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 62 | |||||||||||
| 63 | # Mail::Address format adds a newline | ||||||||||
| 64 | 4 | chomp $remove; | |||||||||
| 65 | 4 | my $original = @{ $self->{members} }; | |||||||||
| 66 | |||||||||||
| 67 | 4 | $self->{members} = [ grep { $_ ne $remove } @{ $self->{members} } ]; | |||||||||
| 68 | 4 | ▶ | $self->{owner} = '' if $self->{owner} eq $remove; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | |||||||||||
| 70 | 4 | return $original > @{ $self->{members} }; | |||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | sub owner | ||||||||||
| 74 | { | ||||||||||
| 75 | 14 | ▶ | my $self = shift; | ||||||||
|
Subroutine
owner: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 76 | 14 | ▶ | $self->add( $self->{owner} = shift ) if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 77 | 14 | return $self->{owner}; | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | sub closed | ||||||||||
| 81 | { | ||||||||||
| 82 | 14 | ▶ | my $self = shift; | ||||||||
|
Subroutine
closed: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 83 | 14 | ▶ | $self->{closed} = $self->is_true( $_[0] ) if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | 14 | return $self->{closed}; | |||||||||
| 85 | } | ||||||||||
| 86 | |||||||||||
| 87 | sub is_true | ||||||||||
| 88 | { | ||||||||||
| 89 | 6 | ▶ | my ($self, $value) = @_; | ||||||||
|
Subroutine
is_true: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 90 | 6 | ▶ | return 0 unless $value; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 91 | 5 | ▶ | return 0 if $value =~ /^[Nn]o/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 92 | 3 | return 1; | |||||||||
| 93 | |||||||||||
| 94 | } | ||||||||||
| 95 | |||||||||||
| 96 | sub auto_add | ||||||||||
| 97 | { | ||||||||||
| 98 | 11 | ▶ | my $self = shift; | ||||||||
|
Subroutine
auto_add: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 99 | 11 | ▶ | $self->{auto_add} = $self->is_true( $_[0] ) if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 100 | 11 | return $self->{auto_add}; | |||||||||
| 101 | } | ||||||||||
| 102 | |||||||||||
| 103 | sub attributes | ||||||||||
| 104 | { | ||||||||||
| 105 | 11 | ▶ | +{ map { $_ => 1 } qw( owner closed expires auto_add description name ) } | ||||||||
|
Subroutine
attributes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 106 | } | ||||||||||
| 107 | |||||||||||
| 108 | 4 | 1; | |||||||||
| 109 | __END__ | ||||||||||