EZTV/Episode.pm

filter: Statementstmt 65.3% 17 / 26 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 13 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 12.5% 1 / 8 Podpod n/a totaltotal 32.1% 18 / 56 CC 8 SCAR 33.0
CC
8
Cov
41%
_parse
56.0
__ANON__
3.7
__ANON__
1.1
CRAP 27.1
↑ Summary EZTV/Link.pm »
1 package WWW::EZTV::Episode;
2 2 $WWW::EZTV::Episode::VERSION = '0.06';
3 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 with 'WWW::EZTV::UA';
5  
6 # ABSTRACT: Show episode
7  
8 2 has show => is => 'ro', isa => 'WWW::EZTV::Show', required => 1;
9 2 has title => is => 'ro', isa => 'Str', required => 1;
10 2 has url => is => 'ro', isa => 'Mojo::URL', required => 1;
11 2 has links =>
12 is => 'ro',
13 handles => {
14 find_link => 'first',
15 has_links => 'size',
16 };
17  
18 2 has _parsed => is => 'ro', lazy => 1, builder => '_parse';
19  
20 has name => is => 'ro', lazy => 1,
21 0 ▶ default => sub { shift->_parsed->{name} };
Subroutine __ANON__: not called CC=1 SCAR=1.2
22  
23 has season => is => 'ro', lazy => 1,
24 0 ▶ default => sub { shift->_parsed->{season} };
Subroutine __ANON__: not called CC=1 SCAR=1.2
25  
26 has number => is => 'ro', lazy => 1,
27 0 ▶ default => sub { shift->_parsed->{number} };
Subroutine __ANON__: not called CC=1 SCAR=1.2
28  
29 has version => is => 'ro', lazy => 1,
30 0 ▶ default => sub { shift->_parsed->{version} };
Subroutine __ANON__: not called CC=1 SCAR=1.2
31  
32 has quality => is => 'ro', lazy => 1,
33 0 ▶ default => sub { shift->_parsed->{quality} || 'standard' };
Subroutine __ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
BranchTrueFalseTotal
+(shift())->_parsed->{"quality"} or "standard" 0 0 0
34  
35 has size => is => 'ro', lazy => 1,
36 0 ▶ default => sub { shift->_parsed->{size} };
Subroutine __ANON__: not called CC=1 SCAR=1.2
37  
38 sub _parse {
39 0 ▶ my $title = shift->title;
Subroutine _parse: not called CC=7 SCAR=40.3
40  
41 0 $title =~ /^\s*
42 (?<name>.+?)
43 \s+
44 (?<chapter>
45 S (?<season>\d+) E (?<number>\d+)
46 |(?<season>\d+) x (?<number>\d+)
47 |(?<number>\d+) of (?<total>\d+)
48 )
49 \s+
50 (?<version>
51 ((?<quality>\d+p)\s+)?
52 (?<team>.*?)
53 )
54 (?:
55 \s+
56 \((?<size>
57 \d+
58 [^\)]+
59 )\)
60 )?
61 \s*$/xi;
62  
63 return {
64 name => $+{name} || $title,
65 chapter => $+{chapter},
66 number => ($+{number}||0) +0,
67 season => ($+{season}||0) +0,
68 total => ($+{total}||0) +0,
69 version => $+{version} || '',
70 quality => $+{quality} || 'standard',
71 team => $+{team},
72 size => $+{size}
73 0 ▶ };
Condition0%0/13
$+{'name'} || $title
l!l&&r!l&&!r
000
$+{'number'} || 0
l!l
00
$+{'season'} || 0
l!l
00
$+{'total'} || 0
l!l
00
$+{'version'} || ''
l!l
00
$+{'quality'} || 'standard'
l!l
00
MC/DC0%0/2
$+{'name'} || $title
$+{'name'} $title
MC/DC0%0/1
$+{'number'} || 0
$+{'number'}
MC/DC0%0/1
$+{'season'} || 0
$+{'season'}
MC/DC0%0/1
$+{'total'} || 0
$+{'total'}
MC/DC0%0/1
$+{'version'} || ''
$+{'version'}
MC/DC0%0/1
$+{'quality'} || 'standard'
$+{'quality'}
Truth table0%0/3
A || B
A= $+{'name'}B= $title
ABresult
1X1
011
000
Truth table0%0/2
A
A= $+{'number'}
Aresult
11
00
Truth table0%0/2
A
A= $+{'season'}
Aresult
11
00
Truth table0%0/2
A
A= $+{'total'}
Aresult
11
00
Truth table0%0/2
A
A= $+{'version'}
Aresult
11
00
Truth table0%0/2
A
A= $+{'quality'}
Aresult
11
00
74 }
75  
76 2 1;
77  
78 __END__
79  
80 =pod
81  
82 =encoding UTF-8
83  
84 =head1 NAME
85  
86 WWW::EZTV::Episode - Show episode
87  
88 =head1 VERSION
89  
90 version 0.06
91  
92 =head1 ATTRIBUTES
93  
94 =head2 has_links
95  
96 How many episodes has this show.
97  
98 =head1 METHODS
99  
100 =head2 find_link
101  
102 Find first L<WWW::EZTV::Link> object matching the given criteria.
103 This method accept an anon function.
104  
105 =head1 AUTHOR
106  
107 Diego Kuperman <diego@freekeylabs.com>
108  
109 =head1 COPYRIGHT AND LICENSE
110  
111 This software is copyright (c) 2012 by Diego Kuperman.
112  
113 This is free software; you can redistribute it and/or modify it under
114 the same terms as the Perl 5 programming language system itself.
115  
116 =cut
↑ Summary EZTV/Link.pm »