| 1 | package Net::NicoVideo::Content; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 2 | ▶ | use vars qw($VERSION); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 2 | $VERSION = '0.28'; | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 1 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||
| 9 | 1 | my $class = shift; | |||||||||||||||||||
| 10 | 1 | ▶ | $class = ref $class || $class; | ||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 1 | my $contents = shift; | |||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 1 | my $self = { | |||||||||||||||||||
| 15 | _decoded_content => undef, | ||||||||||||||||||||
| 16 | _status => undef, | ||||||||||||||||||||
| 17 | }; | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 1 | bless $self, $class; | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 1 | ▶ | $self->load($contents) if( defined $contents ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 1 | return $self; | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 2 | ▶ | sub _decoded_content { | ||||||||||||||||||
|
Subroutine
_decoded_content: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 27 | 2 | my $self = shift; | |||||||||||||||||||
| 28 | 2 | ▶ | return @_ ? $self->{_decoded_content} = shift : $self->{_decoded_content}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 1 | ▶ | sub _status { | ||||||||||||||||||
|
Subroutine
_status: called CC=2 SCAR=7.2
| |||||||||||||||||||||
| 32 | 1 | my $self = shift; | |||||||||||||||||||
| 33 | 1 | ▶ | return @_ ? $self->{_status} = shift : $self->{_status}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 1 | ▶ | sub set_status_success { | ||||||||||||||||||
|
Subroutine
set_status_success: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 37 | 1 | $_[0]->_status(1); | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 0 | ▶ | sub set_status_error { | ||||||||||||||||||
|
Subroutine
set_status_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 41 | 0 | $_[0]->_status(0); | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 1 | ▶ | sub load { | ||||||||||||||||||
|
Subroutine
load: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||
| 45 | 1 | my $self = shift; | |||||||||||||||||||
| 46 | 1 | my $contents = shift; | |||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 1 | ▶ | unless( ref($contents) ){ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 49 | 0 | $self->_decoded_content( $contents ); | |||||||||||||||||||
| 50 | }else{ | ||||||||||||||||||||
| 51 | 1 | ▶ | if( $contents->isa('HTTP::Response') ){ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 52 | 1 | $self->_decoded_content( $contents->decoded_content ); | |||||||||||||||||||
| 53 | }else{ | ||||||||||||||||||||
| 54 | 0 | $self->_decoded_content( $$contents ); | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | } | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 1 | return $self; | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 0 | ▶ | sub members { # interface | ||||||||||||||||||
|
Subroutine
members: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 62 | 0 | (); | |||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 0 | ▶ | sub parse { # interface | ||||||||||||||||||
|
Subroutine
parse: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 66 | 0 | my $self = shift; | |||||||||||||||||||
| 67 | 0 | ▶ | $self->load($_[0]) if( defined $_[0] ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | # here! parse contents and set _status to success or error | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 0 | return $self; | |||||||||||||||||||
| 72 | } | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 0 | ▶ | sub is_success { | ||||||||||||||||||
|
Subroutine
is_success: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 75 | 0 | my $self = shift; | |||||||||||||||||||
| 76 | 0 | ▶ | unless( defined $self->_status ){ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 77 | 0 | die "content is not parsed as @{[ ref($self) ]} yet"; | |||||||||||||||||||
| 78 | } | ||||||||||||||||||||
| 79 | 0 | ▶ | return $self->_status ? 1 : 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 80 | } | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 0 | ▶ | sub is_error { | ||||||||||||||||||
|
Subroutine
is_error: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 83 | 0 | my $self = shift; | |||||||||||||||||||
| 84 | 0 | ▶ | unless( defined $self->_status ){ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 85 | 0 | die "content is not parsed as @{[ ref($self) ]} yet"; | |||||||||||||||||||
| 86 | } | ||||||||||||||||||||
| 87 | 0 | ▶ | return $self->_status ? 0 : 1; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 88 | } | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | 2 | 1; | |||||||||||||||||||
| 92 | __END__ | ||||||||||||||||||||