Skip to content

Commit

Permalink
Load XML-Feed-0.04 into trunk.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwistow committed Apr 22, 2008
1 parent 62d9277 commit fe71566
Show file tree
Hide file tree
Showing 23 changed files with 82 additions and 91 deletions.
2 changes: 1 addition & 1 deletion Build.PL
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# $Id: Build.PL,v 1.1.1.1 2004/05/29 17:29:56 btrott Exp $
# $Id: Build.PL 918 2004-05-29 17:29:55Z btrott $

require 'Makefile.PL';
13 changes: 12 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# $Id: Changes,v 1.7 2004/10/09 07:02:01 btrott Exp $
# $Id: Changes 1750 2005-01-01 00:46:40Z btrott $

Revision history for XML::Feed

0.04 2004.12.31
- Use "loose" parsing in DateTime::Format::Mail so that we don't die
on invalid RFC-822 dates.
- XML::Feed::Entry->link on RSS feeds will now use a <guid> element
if a <link> element isn't found.
- Switched to using URI::Fetch when fetching feeds. Since we're not
storing or caching feeds currently, this basically just buys us
GZIP support, but that's something.
- Use Class::ErrorHandler instead of XML::Feed::ErrorHandler. Thanks
to Tim Appnel for the patch.

0.03 2004.10.09
- Fixed bug with feed format detection: properly detect format even in
feeds with <!DOCTYPE> at the top. (Thanks to Alberto Quario for the
Expand Down
7 changes: 4 additions & 3 deletions META.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: XML-Feed
version: 0.03
version: 0.04
abstract: XML Syndication Feed Support
author: Benjamin Trott <cpan@stupidfool.org>
author: Benjamin Trott <ben+cpan@stupidfool.org>
license: perl
distribution_type: module
requires:
Class::ErrorHandler: 0
Feed::Find: 0
URI::Fetch: 0
XML::RSS: 1.01
XML::Atom: 0.08
LWP: 0
Expand All @@ -20,4 +21,4 @@ no_index:
directory:
- t
- inc
generated_by: Module::Install version 0.35
generated_by: Module::Install version 0.36
5 changes: 3 additions & 2 deletions Makefile.PL
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# $Id: Makefile.PL,v 1.2 2004/10/04 03:38:11 btrott Exp $
# $Id: Makefile.PL 942 2004-12-31 23:01:21Z btrott $

use inc::Module::Install;

name('XML-Feed');
abstract('XML Syndication Feed Support');
author('Benjamin Trott <cpan@stupidfool.org>');
author('Benjamin Trott <ben+cpan@stupidfool.org>');
version_from('lib/XML/Feed.pm');
license('perl');
no_index(directory => 't');
Expand All @@ -14,6 +14,7 @@ include('ExtUtils::AutoInstall');

requires('Class::ErrorHandler');
requires('Feed::Find');
requires('URI::Fetch');
requires('XML::RSS' => 1.01);
requires('XML::Atom' => 0.08);
requires('LWP');
Expand Down
5 changes: 3 additions & 2 deletions README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$Id: README,v 1.2 2004/10/09 07:06:11 btrott Exp $
$Id: README 942 2004-12-31 23:01:21Z btrott $

This is XML::Feed, an abstraction above the RSS and Atom syndication
feed formats. It supports both parsing and autodiscovery of feeds.
Expand All @@ -16,6 +16,7 @@ PREREQUISITES
* DateTime::Format::W3CDTF
* List::Util
* Feed::Find
* URI::Fetch

INSTALLATION

Expand All @@ -33,4 +34,4 @@ Then install it:

% make install

Benjamin Trott / cpan@stupidfool.org
Benjamin Trott / ben+cpan@stupidfool.org
21 changes: 9 additions & 12 deletions inc/Module/Install.pm
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#line 1 "inc/Module/Install.pm - /Library/Perl/5.8.1/Module/Install.pm"
# $File: //depot/cpan/Module-Install/lib/Module/Install.pm $ $Author: autrijus $
# $Revision: #69 $ $Change: 2301 $ $DateTime: 2004/07/13 07:16:40 $ vim: expandtab shiftwidth=4

package Module::Install;
$VERSION = '0.35';
$VERSION = '0.36';

die << "." unless $INC{join('/', inc => split(/::/, __PACKAGE__)).'.pm'};
Please invoke ${\__PACKAGE__} with:
Expand All @@ -24,7 +21,7 @@ use File::Path ();
@inc::Module::Install::ISA = 'Module::Install';
*inc::Module::Install::VERSION = *VERSION;

#line 132
#line 129

sub import {
my $class = shift;
Expand All @@ -47,7 +44,7 @@ sub import {
delete $INC{"$self->{path}.pm"};
}

#line 159
#line 156

sub autoload {
my $self = shift;
Expand All @@ -67,7 +64,7 @@ sub autoload {
};
}

#line 184
#line 181

sub new {
my ($class, %args) = @_;
Expand All @@ -92,7 +89,7 @@ sub new {
bless(\%args, $class);
}

#line 213
#line 210

sub call {
my $self = shift;
Expand All @@ -103,7 +100,7 @@ sub call {
goto &{$obj->can($method)};
}

#line 228
#line 225

sub load {
my ($self, $method) = @_;
Expand All @@ -127,7 +124,7 @@ END
$obj;
}

#line 258
#line 255

sub load_extensions {
my ($self, $path, $top_obj) = @_;
Expand All @@ -146,7 +143,7 @@ sub load_extensions {
}
}

#line 282
#line 279

sub find_extensions {
my ($self, $path) = @_;
Expand All @@ -169,4 +166,4 @@ sub find_extensions {

__END__
#line 620
#line 617
3 changes: 0 additions & 3 deletions inc/Module/Install/AutoInstall.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#line 1 "inc/Module/Install/AutoInstall.pm - /Library/Perl/5.8.1/Module/Install/AutoInstall.pm"
# $File: //depot/cpan/Module-Install/lib/Module/Install/AutoInstall.pm $ $Author: autrijus $
# $Revision: #13 $ $Change: 1846 $ $DateTime: 2003/12/31 22:57:12 $ vim: expandtab shiftwidth=4

package Module::Install::AutoInstall;
use Module::Install::Base; @ISA = qw(Module::Install::Base);

Expand Down
13 changes: 5 additions & 8 deletions inc/Module/Install/Base.pm
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#line 1 "inc/Module/Install/Base.pm - /Library/Perl/5.8.1/Module/Install/Base.pm"
# $File: //depot/cpan/Module-Install/lib/Module/Install/Base.pm $ $Author: autrijus $
# $Revision: #10 $ $Change: 1847 $ $DateTime: 2003/12/31 23:14:54 $ vim: expandtab shiftwidth=4

package Module::Install::Base;

#line 31
#line 28

sub new {
my ($class, %args) = @_;
Expand All @@ -18,18 +15,18 @@ sub new {
bless(\%args, $class);
}

#line 49
#line 46

sub AUTOLOAD {
my $self = shift;
goto &{$self->_top->autoload};
}

#line 60
#line 57

sub _top { $_[0]->{_top} }

#line 71
#line 68

sub admin {
my $self = shift;
Expand All @@ -54,4 +51,4 @@ sub DESTROY {}

__END__
#line 115
#line 112
5 changes: 1 addition & 4 deletions inc/Module/Install/Build.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#line 1 "inc/Module/Install/Build.pm - /Library/Perl/5.8.1/Module/Install/Build.pm"
# $File: //depot/cpan/Module-Install/lib/Module/Install/Build.pm $ $Author: ingy $
# $Revision: #23 $ $Change: 1255 $ $DateTime: 2003/03/05 13:23:32 $ vim: expandtab shiftwidth=4

package Module::Install::Build;
$VERSION = '0.01';
use strict;
Expand Down Expand Up @@ -63,4 +60,4 @@ sub ACTION_dist {

__END__
#line 178
#line 175
3 changes: 0 additions & 3 deletions inc/Module/Install/Can.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#line 1 "inc/Module/Install/Can.pm - /Library/Perl/5.8.1/Module/Install/Can.pm"
# $File: //depot/cpan/Module-Install/lib/Module/Install/Can.pm $ $Author: autrijus $
# $Revision: #6 $ $Change: 1840 $ $DateTime: 2003/12/28 19:42:02 $ vim: expandtab shiftwidth=4

package Module::Install::Can;
use Module::Install::Base; @ISA = qw(Module::Install::Base);
$VERSION = '0.01';
Expand Down
3 changes: 0 additions & 3 deletions inc/Module/Install/Fetch.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#line 1 "inc/Module/Install/Fetch.pm - /Library/Perl/5.8.1/Module/Install/Fetch.pm"
# $File: //depot/cpan/Module-Install/lib/Module/Install/Fetch.pm $ $Author: autrijus $
# $Revision: #8 $ $Change: 1374 $ $DateTime: 2003/03/18 11:50:15 $ vim: expandtab shiftwidth=4

package Module::Install::Fetch;
use Module::Install::Base; @ISA = qw(Module::Install::Base);

Expand Down
3 changes: 0 additions & 3 deletions inc/Module/Install/Include.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#line 1 "inc/Module/Install/Include.pm - /Library/Perl/5.8.1/Module/Install/Include.pm"
# $File: //depot/cpan/Module-Install/lib/Module/Install/Include.pm $ $Author: autrijus $
# $Revision: #9 $ $Change: 2288 $ $DateTime: 2004/07/01 04:49:12 $ vim: expandtab shiftwidth=4

package Module::Install::Include;
use Module::Install::Base; @ISA = qw(Module::Install::Base);

Expand Down
5 changes: 1 addition & 4 deletions inc/Module/Install/Makefile.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#line 1 "inc/Module/Install/Makefile.pm - /Library/Perl/5.8.1/Module/Install/Makefile.pm"
# $File: //depot/cpan/Module-Install/lib/Module/Install/Makefile.pm $ $Author: autrijus $
# $Revision: #53 $ $Change: 1847 $ $DateTime: 2003/12/31 23:14:54 $ vim: expandtab shiftwidth=4

package Module::Install::Makefile;
use Module::Install::Base; @ISA = qw(Module::Install::Base);

Expand Down Expand Up @@ -143,4 +140,4 @@ sub postamble {

__END__
#line 276
#line 273
3 changes: 0 additions & 3 deletions inc/Module/Install/Metadata.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#line 1 "inc/Module/Install/Metadata.pm - /Library/Perl/5.8.1/Module/Install/Metadata.pm"
# $File: //depot/cpan/Module-Install/lib/Module/Install/Metadata.pm $ $Author: autrijus $
# $Revision: #32 $ $Change: 1885 $ $DateTime: 2004/03/11 05:55:27 $ vim: expandtab shiftwidth=4

package Module::Install::Metadata;
use Module::Install::Base; @ISA = qw(Module::Install::Base);

Expand Down
3 changes: 0 additions & 3 deletions inc/Module/Install/Win32.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#line 1 "inc/Module/Install/Win32.pm - /Library/Perl/5.8.1/Module/Install/Win32.pm"
# $File: //depot/cpan/Module-Install/lib/Module/Install/Win32.pm $ $Author: autrijus $
# $Revision: #9 $ $Change: 1789 $ $DateTime: 2003/11/11 01:22:54 $ vim: expandtab shiftwidth=4

package Module::Install::Win32;
use Module::Install::Base; @ISA = qw(Module::Install::Base);

Expand Down
3 changes: 0 additions & 3 deletions inc/Module/Install/WriteAll.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#line 1 "inc/Module/Install/WriteAll.pm - /Library/Perl/5.8.1/Module/Install/WriteAll.pm"
# $File: //depot/cpan/Module-Install/lib/Module/Install/WriteAll.pm $ $Author: autrijus $
# $Revision: #3 $ $Change: 1885 $ $DateTime: 2004/03/11 05:55:27 $ vim: expandtab shiftwidth=4

package Module::Install::WriteAll;
use Module::Install::Base; @ISA = qw(Module::Install::Base);

Expand Down
48 changes: 27 additions & 21 deletions lib/XML/Feed.pm
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# $Id: Feed.pm,v 1.10 2004/10/09 07:05:08 btrott Exp $
# $Id: Feed.pm 942 2004-12-31 23:01:21Z btrott $

package XML::Feed;
use strict;

use base qw( Class::ErrorHandler );
use LWP::UserAgent;
use HTML::Parser;
use Feed::Find;
use URI::Fetch;

use vars qw( $VERSION );
$VERSION = '0.03';
our $VERSION = '0.04';

sub parse {
my $class = shift;
Expand All @@ -18,12 +16,11 @@ sub parse {
my $feed = bless {}, $class;
my $xml = '';
if (UNIVERSAL::isa($stream, 'URI')) {
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $stream);
my $res = $ua->request($req);
if ($res->is_success) {
$xml = $res->content;
}
my $res = URI::Fetch->fetch($stream)
or return $class->error(URI::Fetch->errstr);
return $class->error("This feed has been permanently removed")
if $res->status == URI::Fetch::FEED_GONE();
$xml = $res->content;
} elsif (ref($stream) eq 'SCALAR') {
$xml = $$stream;
} elsif (ref($stream)) {
Expand All @@ -40,28 +37,37 @@ sub parse {
}
return $class->error("Can't get feed XML content from $stream")
unless $xml;
my $format = $feed->identify_format(\$xml)
or return $class->error($feed->errstr);
my $format_class = join '::', __PACKAGE__, $format;
eval "use $format_class";
return $class->error("Unsupported format $format: $@") if $@;
bless $feed, $format_class;
$feed->init_string(\$xml) or return $class->error($feed->errstr);
$feed;
}

sub identify_format {
my $feed = shift;
my($xml) = @_;
## Auto-detect feed type based on first element. This is prone
## to breakage, but then again we don't want to parse the whole
## feed ourselves.
my $tag;
while ($xml =~ /<(\S+)/sg) {
while ($$xml =~ /<(\S+)/sg) {
(my $t = $1) =~ tr/a-zA-Z0-9:\-\?!//cd;
my $first = substr $t, 0, 1;
$tag = $t, last unless $first eq '?' || $first eq '!';
}
return $class->error("Cannot find first element") unless $tag;
return $feed->error("Cannot find first element") unless $tag;
$tag =~ s/^.*://;
if ($tag eq 'rss' || $tag eq 'RDF') {
require XML::Feed::RSS;
bless $feed, 'XML::Feed::RSS';
return 'RSS';
} elsif ($tag eq 'feed') {
require XML::Feed::Atom;
bless $feed, 'XML::Feed::Atom';
return 'Atom';
} else {
return $class->error("Cannot detect feed type");
return $feed->error("Cannot detect feed type");
}
$feed->init_string($xml) or return;
$feed;
}

sub find_feeds {
Expand Down Expand Up @@ -217,6 +223,6 @@ under the same terms as Perl itself.
=head1 AUTHOR & COPYRIGHT
Except where otherwise noted, I<XML::Feed> is Copyright 2004 Benjamin
Trott, cpan@stupidfool.org. All rights reserved.
Trott, ben+cpan@stupidfool.org. All rights reserved.
=cut
Loading

0 comments on commit fe71566

Please sign in to comment.