NicoVideo/Content/MylistItem.pm

filter: Statementstmt 43.1% 22 / 51 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 66.6% 6 / 9 Podpod 0.0% 0 / 2 totaltotal 26.1% 28 / 107 CC 15 SCAR 42.5
CC
15
Cov
26%
__ANON__
132.0
parse
30.0
members
2.0
CRAP 70.0
↑ Summary NicoVideo.pm »
1 package Net::NicoVideo::Content::MylistItem;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 $VERSION = '0.28';
7  
8 1 ▶use base qw(Net::NicoVideo::Content Class::Accessor::Fast);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use HTML::Parser 3.00;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use vars qw(@Members);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 @Members = qw(
13 item_type
14 item_id
15 description
16 token
17 );
18  
19 1 __PACKAGE__->mk_accessors(@Members);
20  
21 0 ▶sub members { # implement
Subroutine members: not called CC=1 SCAR=6.9
Pod undocumented
22 0 my @copy = @Members;
23 0 @copy;
24 }
25  
26 0 ▶sub parse { # implement
Subroutine parse: not called CC=5 SCAR=34.0
Pod undocumented
27 0 my $self = shift;
28 0 ▶ $self->load($_[0]) if( defined $_[0] );
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0] 0 0 0
29  
30 0 my $content = $self->_decoded_content;
31  
32 # take NicoAPI.token
33 0 ▶ if( $content =~ /NicoAPI\.token\s*=\s*"([-\w]+)"/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($content =~ /NicoAPI\.token\s*=\s*"([-\w]+)"/) 0 0 0
34 0 $self->token( $1 );
35 }
36  
37 # take item_type and item_id using HTML::Parser
38 0 my $item_type = undef;
39 0 my $item_id = undef;
40 0 my $description = undef;
41 0 my $p;
42 $p = HTML::Parser->new(
43 api_version => 3,
44 0 ▶ start_h => [ sub {
Subroutine __ANON__: not called CC=11 SCAR=48.8
45 0 my ($tagname, $attr) = @_;
46 0 ▶ if( lc($tagname) eq 'input' ){
Branch: 1 branch
BranchTrueFalseTotal
if (lc $tagname eq "input") 0 0 0
47 0 ▶ if( exists $attr->{name} and lc($attr->{name}) eq 'item_type' ){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $attr->{"name"} and lc $attr->{"name"} eq "item_type") 0 0 0
Condition0%0/3
exists $attr->{"name"} and lc $attr->{"name"} eq "item_type"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $attr->{"name"} and lc $attr->{"name"} eq "item_type"
exists $attr->{"name"} lc $attr->{"name"} eq "item_type"
Truth table0%0/3
A and B
A= exists $attr->{"name"}B= lc $attr->{"name"} eq "item_type"
ABresult
0X0
100
111
48 0 $item_type = $attr->{value};
49 }
50 0 ▶ if( exists $attr->{name} and lc($attr->{name}) eq 'item_id' ){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $attr->{"name"} and lc $attr->{"name"} eq "item_id") 0 0 0
Condition0%0/3
exists $attr->{"name"} and lc $attr->{"name"} eq "item_id"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $attr->{"name"} and lc $attr->{"name"} eq "item_id"
exists $attr->{"name"} lc $attr->{"name"} eq "item_id"
Truth table0%0/3
A and B
A= exists $attr->{"name"}B= lc $attr->{"name"} eq "item_id"
ABresult
0X0
100
111
51 0 $item_id = $attr->{value};
52 }
53 0 ▶ if( exists $attr->{name} and lc($attr->{name}) eq 'description' ){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $attr->{"name"} and lc $attr->{"name"} eq "description") 0 0 0
Condition0%0/3
exists $attr->{"name"} and lc $attr->{"name"} eq "description"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $attr->{"name"} and lc $attr->{"name"} eq "description"
exists $attr->{"name"} lc $attr->{"name"} eq "description"
Truth table0%0/3
A and B
A= exists $attr->{"name"}B= lc $attr->{"name"} eq "description"
ABresult
0X0
100
111
54 0 $description= $attr->{value};
55 }
56 }
57 0 ▶ $p->eof if( defined $item_type and defined $item_id and defined $description );
Branch: 1 branch
BranchTrueFalseTotal
if defined $item_type and defined $item_id and defined $description 0 0 0
Condition0%0/6
defined $item_type and defined $item_id and defined $description
!ll&&!rl&&r
000
defined $item_type and defined $item_id
!ll&&!rl&&r
000
MC/DC0%0/3
defined $item_type and defined $item_id and defined $description
defined $item_type defined $item_id defined $description
Truth table0%0/4
A and B and C
A= defined $item_typeB= defined $item_idC= defined $description
ABCresult
0XX0
10X0
1100
1111
58 0 }, 'tagname, attr']);
59 0 $p->parse($content);
60 0 $self->item_type( $item_type );
61 0 $self->item_id( $item_id );
62 0 $self->description( $description );
63  
64 # status
65 0 ▶ if( defined $self->item_id and defined $self->item_type ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->item_id and defined $self->item_type) { } 0 0 0
Condition0%0/3
defined $self->item_id and defined $self->item_type
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->item_id and defined $self->item_type
defined $self->item_id defined $self->item_type
Truth table0%0/3
A and B
A= defined $self->item_idB= defined $self->item_type
ABresult
0X0
100
111
66 0 $self->set_status_success;
67 }else{
68 0 $self->set_status_error;
69 }
70
71 0 return $self;
72 }
73  
74  
75 1 1;
76 __END__
↑ Summary NicoVideo.pm »