EZTV/Show.pm

filter: Statementstmt 51.2% 21 / 41 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 36.3% 4 / 11 Podpod n/a totaltotal 38.4% 25 / 65 CC 5 SCAR 15.6
CC
5
Cov
41%
__ANON__
12.0
_name
6.0
_year
6.0
CRAP 4.7
« EZTV/UA.pm ↑ Summary EZTV.pm »
1 package WWW::EZTV::Show;
2 2 $WWW::EZTV::Show::VERSION = '0.06';
3 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 with 'WWW::EZTV::UA';
6 2 ▶use WWW::EZTV::Link;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use WWW::EZTV::Episode;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: Show object
10  
11 2 has title => is => 'ro', isa => 'Str', required => 1;
12 2 has name => is => 'ro', lazy => 1, default => \&_name;
13 2 has year => is => 'ro', lazy => 1, default => \&_year;
14 2 has url => is => 'ro', isa => 'Mojo::URL', required => 1;
15 2 has status => is => 'ro', isa => 'Str', required => 1;
16 0 ▶has rating => is => 'ro', isa => 'Num', default => sub {0};
Subroutine __ANON__: not called CC=1 SCAR=1.2
17 2 has episodes =>
18 is => 'ro',
19 lazy => 1,
20 builder => '_build_episodes',
21 handles => {
22 find_episode => 'first',
23 has_episodes => 'size',
24 };
25  
26 sub _build_episodes {
27 0 ▶ my $self = shift;
Subroutine _build_episodes: not called CC=1 SCAR=6.9
28 $self->get_response($self->url)->dom->find('table.header_noborder tr[name="hover"]')->map(sub{
29 0 ▶ my $tr = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 0 my $link = $tr->at('td:nth-child(2) a');
31  
32 WWW::EZTV::Episode->new(
33 title => $link->attr('alt'),
34 url => $self->url->clone->path($link->attr('href')),
35 links => $tr->find('td:nth-child(3) a')->map(sub{
36 0 ▶ WWW::EZTV::Link->new( url => $_[0]->attr('href')
Subroutine __ANON__: not called CC=3 SCAR=24.8
Condition0%0/6
$_[0]->attr('href') || $_[0]->attr('data-url') || $_[0]->attr('data-bx-magnet')
l!l&&r!l&&!r
000
$_[0]->attr("href") or $_[0]->attr("data-url")
l!l&&r!l&&!r
000
MC/DC0%0/3
$_[0]->attr('href') || $_[0]->attr('data-url') || $_[0]->attr('data-bx-magnet')
$_[0]->attr("href") $_[0]->attr("data-url") $_[0]->attr('data-bx-magnet')
Truth table0%0/4
A or B || C
A= $_[0]->attr("href")B= $_[0]->attr("data-url")C= $_[0]->attr('data-bx-magnet')
ABCresult
1XX1
01X1
0011
0000
37 || $_[0]->attr('data-url')
38 || $_[0]->attr('data-bx-magnet') )
39 0 }),
40 released => $tr->at('td:nth-child(4)')->all_text,
41 show => $self
42 );
43 0 });
44 }
45  
46 sub _name {
47 0 ▶ my $self = shift;
Subroutine _name: not called CC=2 SCAR=17.9
48 0 my $name = $self->title;
49  
50 # Chasers War on Everything, The
51 0 ▶ if ( $name =~ /^(.+),\s*([^,]+)$/ ) { $name = "$2 $1" }
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^(.+),\s*([^,]+)$/) 0 0 0
52  
53 # Remove year: Castle (2009)
54 0 $name =~ s/\s* \(\d{4}\) \s*/ /x;
55  
56 # Trim and cleanup spaces
57 0 $self->_cleanup_str($name);
58 }
59  
60 sub _year {
61 0 ▶ my $self = shift;
Subroutine _year: not called CC=2 SCAR=17.9
62 0 ▶ if ( $self->title =~ /\((\d{4})\)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->title =~ /\((\d{4})\)/) 0 0 0
63 0 return $1;
64 }
65 }
66  
67 sub _cleanup_str {
68 0 ▶ my $str = pop;
Subroutine _cleanup_str: not called CC=1 SCAR=6.9
69 0 $str =~ s/^\s+|\s+$//g;
70 0 $str =~ s/\s+/ /g;
71 0 $str;
72 }
73  
74 2 1;
75  
76 __END__
77  
78 =pod
79  
80 =encoding UTF-8
81  
82 =head1 NAME
83  
84 WWW::EZTV::Show - Show object
85  
86 =head1 VERSION
87  
88 version 0.06
89  
90 =head1 ATTRIBUTES
91  
92 =head2 title
93  
94 =head2 name
95  
96 =head2 year
97  
98 =head2 url
99  
100 =head2 status
101  
102 =head2 rating
103  
104 =head2 episodes
105  
106 Collection of episodes fetched for this show.
107  
108 =head2 has_episodes
109  
110 How many episodes has this show.
111  
112 =head1 METHODS
113  
114 =head2 find_episode
115  
116 Find first L<WWW::EZTV::Episode> object matching the given criteria.
117 This method accept an anon function.
118  
119 =head1 AUTHOR
120  
121 Diego Kuperman <diego@freekeylabs.com>
122  
123 =head1 COPYRIGHT AND LICENSE
124  
125 This software is copyright (c) 2012 by Diego Kuperman.
126  
127 This is free software; you can redistribute it and/or modify it under
128 the same terms as the Perl 5 programming language system itself.
129  
130 =cut
« EZTV/UA.pm ↑ Summary EZTV.pm »