blib/lib/Feed/Source/Page2RSS.pm

filter: Statementstmt 67.3% 31 / 46 Branchbran 41.6% 5 / 12 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 70.0% 7 / 10 Podpod 100% 5 / 5 totaltotal 64.4% 49 / 76 CC 8 SCAR 12.5
CC
8
Cov
62%
feed_type
6.0
atom_feed
6.0
rss_feed
6.0
CRAP 3.5
↑ Summary
1 package Feed::Source::Page2RSS;
2  
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 RSS => "http://page2rss.com/page/rss",
10 ATOM => "http://page2rss.com/page/atom",
11 3 };
12  
13 =head1 NAME
14  
15 Feed::Source::Page2RSS - Creation of a Atom/RSS feed with the Page2RSS service
16  
17 =head1 VERSION
18  
19 Version 0.01
20  
21 =cut
22  
23 3 our $VERSION = '0.01';
24  
25 =head1 SYNOPSIS
26  
27 Page2RSS create a Atom/RSS feed to monitor a webpage. This module help you to
28 create these feeds.
29  
30 use Feed::Source::Page2RSS;
31
32 my $feed = Feed::Source::Page2RSS->new( url => "http://www.google.com", feed_type => "rss" );
33 my $feed_url = $feed->url_feed();
34
35 or
36
37 my $feed = Feed::Source::Page2RSS->new( url => "http://www.google.com" );
38 my $atom = $feed->atom_feed();
39
40 is equivalent to
41
42 my $feed = Feed::Source::Page2RSS->new( url => "http://www.google.com" );
43 $feed->feed_type('atom');
44 my $atom = $feed->url_feed();
45
46 or
47
48 my $feed = Feed::Source::Page2RSS->new( url => "http://www.google.com" );
49 my $rss = $feed->rss_feed();
50  
51 is equivalent to
52
53 my $feed = Feed::Source::Page2RSS->new( url => "http://www.google.com" );
54 $feed->feed_type('rss');
55 my $rss = $feed->url_feed();
56
57 =head1 FUNCTIONS
58  
59 =head2 new
60  
61 Constructor of the Feed::Source::Page2RSS object. You can spcecify the
62 following options :
63  
64 =over 4
65  
66 =item url
67  
68 URL to monitor
69  
70 =item feed_type
71  
72 Feed type of the returned URL. Possible values are RSS and Atom.
73  
74 =back
75  
76 =cut
77  
78 3 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
79 3 my ($class, %args) = @_;
80 3 my $self;
81 3 ▶ $self->{params}{url} = $args{url} if exists $args{url};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"url"} 1 2 3
82 3 ▶ $self->{feed_type} = uc $args{feed_type} || "RSS";
Condition50%1/2
uc $args{'feed_type'} || 'RSS'
l!l
03
MC/DC0%0/1
uc $args{'feed_type'} || 'RSS'
uc $args{'feed_type'}
Truth table50%1/2
A
A= uc $args{'feed_type'}
Aresult
11
00
83 3 bless $self, $class;
84 3 $self;
85 }
86  
87 =head2 feed_type
88  
89 Adjust the feed type. Possible value are RSS and Atom.
90  
91 =cut
92  
93 0 ▶sub feed_type {
Subroutine feed_type: not called CC=2 SCAR=17.9
Pod documented
94 0 my $self = shift;
95 0 ▶ $self->{feed_type} = uc shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
96 }
97  
98 =head2 url_feed
99  
100 Return the URL feed.
101  
102 =cut
103  
104 2 ▶sub url_feed {
Subroutine url_feed: called CC=3 SCAR=11.1
Pod documented
105 2 my $self = shift;
106 2 ▶ if (exists $self->{params}{url}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'params'}{'url'}) { } 1 1 2
107 1 my $uri;
108 1 ▶ if ($self->{feed_type} eq "RSS") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'feed_type'} eq 'RSS') { } 1 0 1
109 1 $uri = URI->new(RSS);
110 } else {
111 0 $uri = URI->new(ATOM)
112 }
113 1 $uri->query_form( $self->{params} );
114 1 return $uri->as_string();
115 } else {
116 1 croak "You must specify an URL to monitor";
117 }
118
119 }
120  
121 =head2 atom_feed
122  
123 Return the Atom URL feed.
124  
125 =cut
126  
127 0 ▶sub atom_feed {
Subroutine atom_feed: not called CC=2 SCAR=17.9
Pod documented
128 0 my $self = shift;
129 0 ▶ if (exists $self->{params}{url}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'params'}{'url'}) { } 0 0 0
130 0 my $uri = URI->new(ATOM);
131 0 $uri->query_form( $self->{params} );
132 0 return $uri->as_string();
133 } else {
134 0 croak "You must specify an URL to monitor";
135 }
136
137 }
138  
139 =head2 rss_feed
140  
141 Return the RSS URL feed.
142  
143 =cut
144  
145 0 ▶sub rss_feed {
Subroutine rss_feed: not called CC=2 SCAR=17.9
Pod documented
146 0 my $self = shift;
147 0 ▶ if (exists $self->{params}{url}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'params'}{'url'}) { } 0 0 0
148 0 my $uri = URI->new(RSS);
149 0 $uri->query_form( $self->{params} );
150 0 return $uri->as_string();
151 } else {
152 0 croak "You must specify an URL to monitor";
153 }
154
155 }
156  
157  
158 =head1 AUTHOR
159  
160 Emmanuel Di Pretoro, C<< <<manu at bjornoya.net>> >>
161  
162 =head1 BUGS
163  
164 Please report any bugs or feature requests to
165 C<bug-feed-source-page2rss at rt.cpan.org>, or through the web interface at
166 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Feed-Source-Page2RSS>.
167 I will be notified, and then you'll automatically be notified of progress on
168 your bug as I make changes.
169  
170 =head1 SUPPORT
171  
172 You can find documentation for this module with the perldoc command.
173  
174 perldoc Feed::Source::Page2RSS
175  
176 You can also look for information at:
177  
178 =over 4
179  
180 =item * AnnoCPAN: Annotated CPAN documentation
181  
182 L<http://annocpan.org/dist/Feed-Source-Page2RSS>
183  
184 =item * CPAN Ratings
185  
186 L<http://cpanratings.perl.org/d/Feed-Source-Page2RSS>
187  
188 =item * RT: CPAN's request tracker
189  
190 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Feed-Source-Page2RSS>
191  
192 =item * Search CPAN
193  
194 L<http://search.cpan.org/dist/Feed-Source-Page2RSS>
195  
196 =back
197  
198 =head1 SEE ALSO
199  
200 Page2RSS L<http://page2rss.com>
201  
202 =head1 COPYRIGHT & LICENSE
203  
204 Copyright 2006 Emmanuel Di Pretoro, all rights reserved.
205  
206 This program is free software; you can redistribute it and/or modify it
207 under the same terms as Perl itself.
208  
209 =cut
210  
211 3 1; # End of Feed::Source::Page2RSS
↑ Summary