line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (c) 2004-2009 Timothy Appnel |
2
|
|
|
|
|
|
|
# http://appnel.com/ |
3
|
|
|
|
|
|
|
# This code is released under the Artistic License. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# XML::RAI - RSS Abstraction Interface. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package XML::RAI; |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
82308
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
184
|
|
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
24
|
use vars qw($VERSION); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
534
|
|
13
|
|
|
|
|
|
|
$VERSION = 1.3031; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
29410
|
use XML::RSS::Parser 4.0; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use XML::RAI::Channel; |
17
|
|
|
|
|
|
|
use XML::RAI::Item; |
18
|
|
|
|
|
|
|
use XML::RAI::Image; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use constant W3CDTF => '%Y-%m-%dT%H:%M:%S%z'; # AKA... |
21
|
|
|
|
|
|
|
use constant RFC8601 => W3CDTF; |
22
|
|
|
|
|
|
|
use constant RFC822 => '%a, %d %b %G %T %Z'; |
23
|
|
|
|
|
|
|
use constant PASS_THRU => ''; |
24
|
|
|
|
|
|
|
use constant EPOCH => 'EPOCH'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
|
|
|
|
|
|
my $class = shift; |
28
|
|
|
|
|
|
|
my $self = bless {}, $class; |
29
|
|
|
|
|
|
|
$self->init(@_); |
30
|
|
|
|
|
|
|
$self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub init { |
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
my $doc; |
36
|
|
|
|
|
|
|
unless (ref($_[0]) eq 'XML::RSS::Parser::Feed') { |
37
|
|
|
|
|
|
|
my ($method, @r) = @_; |
38
|
|
|
|
|
|
|
my $parser = XML::RSS::Parser->new; |
39
|
|
|
|
|
|
|
$doc = $parser->$method(@r) or die $parser->errstr; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else { |
42
|
|
|
|
|
|
|
$doc = shift; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
$self->{__doc} = $doc; |
45
|
|
|
|
|
|
|
my $channel = $self->{__channel} = |
46
|
|
|
|
|
|
|
XML::RAI::Channel->new($doc->channel, $self); |
47
|
|
|
|
|
|
|
my @items = map { XML::RAI::Item->new($_, $channel) } $doc->items; |
48
|
|
|
|
|
|
|
$self->{__items} = \@items; |
49
|
|
|
|
|
|
|
my @imgs = $doc->image; # fix multiple image bug ala slashdot. |
50
|
|
|
|
|
|
|
$self->{__image} = XML::RAI::Image->new($imgs[0], $channel) |
51
|
|
|
|
|
|
|
if $doc->image; |
52
|
|
|
|
|
|
|
$self->{__timef} = W3CDTF; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub time_format { |
56
|
|
|
|
|
|
|
$_[0]->{__timef} = $_[1] if defined $_[1]; |
57
|
|
|
|
|
|
|
$_[0]->{__timef}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub parse { |
61
|
|
|
|
|
|
|
my $class = shift; |
62
|
|
|
|
|
|
|
if (ref($_[0]) eq 'GLOB') { # is filehandle |
63
|
|
|
|
|
|
|
$class->parse_file(@_); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
else { # is string |
66
|
|
|
|
|
|
|
$class->parse_string(@_); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub parsefile { |
71
|
|
|
|
|
|
|
my $class = shift; |
72
|
|
|
|
|
|
|
$class->new('parse_file', @_) or die $class->errstr; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
*parse_file = \&parsefile; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub parse_string { |
77
|
|
|
|
|
|
|
my $class = shift; |
78
|
|
|
|
|
|
|
$class->new('parse_string', @_) or die $class->errstr; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub parse_uri { |
82
|
|
|
|
|
|
|
my $class = shift; |
83
|
|
|
|
|
|
|
$class->new('parse_uri', @_) or die $class->errstr; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub document { $_[0]->{__doc}; } |
87
|
|
|
|
|
|
|
sub channel { $_[0]->{__channel}; } |
88
|
|
|
|
|
|
|
sub items { $_[0]->{__items}; } |
89
|
|
|
|
|
|
|
sub item_count { scalar @{$_[0]->{__items}}; } |
90
|
|
|
|
|
|
|
sub image { $_[0]->{__image}; } |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |