| 1 | package AnyEvent::Ident::Response; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | # ABSTRACT: Simple asynchronous ident response | ||||||||||||||
| 7 | 5 | our $VERSION = '0.08'; # VERSION | |||||||||||||
| 8 | |||||||||||||||
| 9 | sub new | ||||||||||||||
| 10 | 22 | ▶ | { | ||||||||||||
|
Subroutine
new: called CC=8 SCAR=21.0
Pod
undocumented
| |||||||||||||||
| 11 | 22 | my $class = shift; | |||||||||||||
| 12 | 22 | ▶ | if(@_ == 1) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 13 | { | ||||||||||||||
| 14 | 13 | my $raw = shift; | |||||||||||||
| 15 | 13 | $raw =~ s/^\s+//; | |||||||||||||
| 16 | 13 | $raw =~ s/\s+$//; | |||||||||||||
| 17 | 13 | my ($pair, @list) = split /\s*:\s*/, $raw; | |||||||||||||
| 18 | 13 | my($server_port, $client_port) = split /\s*,\s*/, $pair; | |||||||||||||
| 19 | 13 | my $self = bless { | |||||||||||||
| 20 | raw => $raw, | ||||||||||||||
| 21 | server_port => $server_port, | ||||||||||||||
| 22 | client_port => $client_port | ||||||||||||||
| 23 | }, $class; | ||||||||||||||
| 24 | |||||||||||||||
| 25 | 13 | ▶ | if($list[0] eq 'USERID') | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 26 | { | ||||||||||||||
| 27 | 5 | shift @list; | |||||||||||||
| 28 | 5 | ($self->{os}, $self->{charset}) = split /\s,\s*/, shift @list; | |||||||||||||
| 29 | 5 | $self->{username} = shift @list; | |||||||||||||
| 30 | 5 | ▶ | $self->{charset} ||= 'US-ASCII'; | ||||||||||||
|
Condition50%1/2
$self->{"charset"} ||= "US-ASCII"
MC/DC0%0/1
$self->{"charset"} ||= "US-ASCII"
$self->{"charset"}
Truth table50%1/2
A
A= $self->{"charset"}
| |||||||||||||||
| 31 | } | ||||||||||||||
| 32 | else | ||||||||||||||
| 33 | { | ||||||||||||||
| 34 | 8 | shift @list; | |||||||||||||
| 35 | 8 | $self->{error_type} = shift @list; | |||||||||||||
| 36 | } | ||||||||||||||
| 37 | |||||||||||||||
| 38 | 13 | return $self; | |||||||||||||
| 39 | } | ||||||||||||||
| 40 | else | ||||||||||||||
| 41 | { | ||||||||||||||
| 42 | 0 | ▶ | my $args = ref $_[0] eq 'HASH' ? (\%{$_[0]}) : ({@_}); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 43 | my $self = bless { | ||||||||||||||
| 44 | server_port => $args->{req}->server_port, | ||||||||||||||
| 45 | client_port => $args->{req}->client_port, | ||||||||||||||
| 46 | username => $args->{username}, | ||||||||||||||
| 47 | os => $args->{os}, | ||||||||||||||
| 48 | charset => $args->{charset}, | ||||||||||||||
| 49 | error_type => $args->{error_type}, | ||||||||||||||
| 50 | 9 | }, $class; | |||||||||||||
| 51 | 9 | ▶ | $self->{os} = 'OTHER' unless defined $self->{os}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 52 | 9 | ▶ | if($self->{error_type}) | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 53 | { | ||||||||||||||
| 54 | 4 | $self->{raw} = join(':', join(',', $self->{server_port}, $self->{client_port}), 'ERROR', $self->{error_type}); | |||||||||||||
| 55 | } | ||||||||||||||
| 56 | elsif($self->{charset}) | ||||||||||||||
| 57 | { | ||||||||||||||
| 58 | 0 | $self->{raw} = join(':', join(',', $self->{server_port}, $self->{client_port}), 'USERID', join(',', $self->{os}, $self->{charset}), $self->{username}); | |||||||||||||
| 59 | } | ||||||||||||||
| 60 | else | ||||||||||||||
| 61 | { | ||||||||||||||
| 62 | 5 | $self->{raw} = join(':', join(',', $self->{server_port}, $self->{client_port}), 'USERID', $self->{os}, $self->{username}); | |||||||||||||
| 63 | } | ||||||||||||||
| 64 | 9 | return $self; | |||||||||||||
| 65 | } | ||||||||||||||
| 66 | } | ||||||||||||||
| 67 | |||||||||||||||
| 68 | sub _key | ||||||||||||||
| 69 | 15 | ▶ | { | ||||||||||||
|
Subroutine
_key: called CC=1 SCAR=0.0
| |||||||||||||||
| 70 | 15 | my($self) = @_; | |||||||||||||
| 71 | 15 | join ':', $self->{server_port}, $self->{client_port}; | |||||||||||||
| 72 | } | ||||||||||||||
| 73 | |||||||||||||||
| 74 | |||||||||||||||
| 75 | 11 | ▶ | sub as_string { shift->{raw} } | ||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 76 | 15 | ▶ | sub is_success { defined shift->{username} } | ||||||||||||
|
Subroutine
is_success: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 77 | 4 | ▶ | sub server_port { shift->{server_port} } | ||||||||||||
|
Subroutine
server_port: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 78 | 4 | ▶ | sub client_port { shift->{client_port} } | ||||||||||||
|
Subroutine
client_port: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 79 | 6 | ▶ | sub username { shift->{username} } | ||||||||||||
|
Subroutine
username: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 80 | 6 | ▶ | sub os { shift->{os} } | ||||||||||||
|
Subroutine
os: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 81 | 0 | ▶ | sub charset { shift->{charset} } | ||||||||||||
|
Subroutine
charset: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 82 | 9 | ▶ | sub error_type { shift->{error_type} } | ||||||||||||
|
Subroutine
error_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 83 | |||||||||||||||
| 84 | 5 | 1; | |||||||||||||
| 85 | |||||||||||||||
| 86 | __END__ | ||||||||||||||