blib/lib/WWW/FetchStory/Fetcher/TwistingHellmouth.pm

filter: Statementstmt 20.9% 9 / 43 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 28.5% 2 / 7 Podpod 100% 5 / 5 totaltotal 25.4% 16 / 63 CC 5 SCAR 22.1
CC
5
Cov
18%
parse_chapter_urls
20.0
parse_toc
6.0
info
2.0
CRAP 9.1
« blib/lib/WWW/FetchStory/Fetcher/DigitalQuill.pm ↑ Summary Build »
1 package WWW::FetchStory::Fetcher::TwistingHellmouth;
2 1 $WWW::FetchStory::Fetcher::TwistingHellmouth::VERSION = '0.2004';
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 =head1 NAME
6  
7 WWW::FetchStory::Fetcher::TwistingHellmouth - fetching module for WWW::FetchStory
8  
9 =head1 VERSION
10  
11 version 0.2004
12  
13 =head1 DESCRIPTION
14  
15 This is the TwistingHellmouth story-fetching plugin for WWW::FetchStory.
16  
17 =cut
18  
19 1 our @ISA = qw(WWW::FetchStory::Fetcher);
20  
21 =head1 METHODS
22  
23 =head2 info
24  
25 Information about the fetcher.
26  
27 $info = $self->info();
28  
29 =cut
30  
31 sub info {
32 0 ▶ my $self = shift;
Subroutine info: not called CC=1 SCAR=6.9
Pod documented
33
34 0 my $info = "(http://www.tthfanfic.org) Twisting The Hellmouth; Buffy The Vampire Slayer crossovers.";
35  
36 0 return $info;
37 } # info
38  
39 =head2 priority
40  
41 The priority of this fetcher. Fetchers with higher priority
42 get tried first. This is useful where there may be a generic
43 fetcher for a particular site, and then a more specialized fetcher
44 for particular sections of a site. For example, there may be a
45 generic TwistingHellmouth fetcher, and then refinements for particular
46 TwistingHellmouth community, such as the sshg_exchange community.
47 This works as either a class function or a method.
48  
49 This must be overridden by the specific fetcher class.
50  
51 $priority = $self->priority();
52  
53 $priority = WWW::FetchStory::Fetcher::priority($class);
54  
55 =cut
56  
57 sub priority {
58 0 ▶ my $class = shift;
Subroutine priority: not called CC=1 SCAR=6.9
Pod documented
59  
60 0 return 1;
61 } # priority
62  
63 =head2 allow
64  
65 If this fetcher can be used for the given URL, then this returns
66 true.
67 This must be overridden by the specific fetcher class.
68  
69 if ($obj->allow($url))
70 {
71 ....
72 }
73  
74 =cut
75  
76 sub allow {
77 0 ▶ my $self = shift;
Subroutine allow: not called CC=1 SCAR=6.9
Pod documented
78 0 my $url = shift;
79  
80 0 return ($url =~ /tthfanfic\.org/);
81 } # allow
82  
83 =head1 Private Methods
84  
85 =head2 parse_toc
86  
87 Parse the table-of-contents file.
88  
89 %info = $self->parse_toc(content=>$content,
90 url=>$url,
91 urls=>\@urls);
92  
93 This should return a hash containing:
94  
95 =over
96  
97 =item chapters
98  
99 An array of URLs for the chapters of the story. In the case where the
100 story only takes one page, that will be the chapter.
101 In the case where multiple URLs have been passed in, it will be those URLs.
102  
103 =item title
104  
105 The title of the story.
106  
107 =back
108  
109 It may also return additional information, such as Summary.
110  
111 =cut
112  
113 sub parse_toc {
114 0 ▶ my $self = shift;
Subroutine parse_toc: not called CC=2 SCAR=17.9
Pod documented
115 0 my %args = (
116 url=>'',
117 content=>'',
118 @_
119 );
120  
121 0 my $content = $args{content};
122 0 my %info = ();
123 0 $info{url} = $args{url};
124 0 $info{title} = $self->parse_title(%args);
125 0 $info{author} = $self->parse_author(%args);
126 0 $info{summary} = $self->parse_summary(%args);
127 0 $info{characters} = $self->parse_characters(%args);
128 0 $info{universe} = 'Buffy';
129  
130 0 ▶ if ($content =~ m{<td>(No|Yes)\s*</td>\s*</tr>}s)
Branch: 1 branch
BranchTrueFalseTotal
if ($content =~ m[<td>(No|Yes)\s*</td>\s*</tr>]s) 0 0 0
131 {
132 0 $info{complete} = $1;
133 }
134 0 $info{chapters} = $self->parse_chapter_urls(%args);
135  
136 0 return %info;
137 } # parse_toc
138  
139 =head2 parse_chapter_urls
140  
141 Figure out the URLs for the chapters of this story.
142  
143 =cut
144 sub parse_chapter_urls {
145 0 ▶ my $self = shift;
Subroutine parse_chapter_urls: not called CC=4 SCAR=30.0
Pod documented
146 0 my %args = (
147 url=>'',
148 content=>'',
149 @_
150 );
151 0 my $content = $args{content};
152 0 my @chapters = ();
153 0 ▶ if (defined $args{urls})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"urls"}) 0 0 0
154 {
155 0 @chapters = @{$args{urls}};
156 }
157 0 ▶ if (@chapters == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (@chapters == 1) 0 0 0
158 {
159 0 ▶ if ($args{url} =~ m{http://www.tthfanfic.org/Story-(\d+)})
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"url"} =~ m[http://www.tthfanfic.org/Story-(\d+)]) 0 0 0
160 {
161 0 my $sid = $1;
162 0 @chapters =
163 ("http://www.tthfanfic.org/wholestory.php?no=${sid}&format=print");
164 }
165 }
166  
167 0 return \@chapters;
168 } # parse_chapter_urls
169  
170 1 1; # End of WWW::FetchStory::Fetcher::TwistingHellmouth
171 __END__
« blib/lib/WWW/FetchStory/Fetcher/DigitalQuill.pm ↑ Summary Build »