| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# WebFetch::Input::PerlStruct.pm |
|
2
|
|
|
|
|
|
|
# push a Perl structure with pre-parsed news into WebFetch |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# Copyright (c) 1998-2009 Ian Kluft. This program is free software; you can |
|
5
|
|
|
|
|
|
|
# redistribute it and/or modify it under the terms of the GNU General Public |
|
6
|
|
|
|
|
|
|
# License Version 3. See http://www.webfetch.org/GPLv3.txt |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package WebFetch::Input::PerlStruct; |
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
1434
|
use strict; |
|
|
1
|
|
|
|
|
12
|
|
|
|
1
|
|
|
|
|
54
|
|
|
11
|
1
|
|
|
1
|
|
7
|
use base "WebFetch"; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
83
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# define exceptions/errors |
|
14
|
|
|
|
|
|
|
use Exception::Class ( |
|
15
|
|
|
|
|
|
|
"WebFetch::Input::PerlStruct::Exception::NoStruct" => { |
|
16
|
|
|
|
|
|
|
isa => "WebFetch::Exception", |
|
17
|
|
|
|
|
|
|
alias => "throw_nostruct", |
|
18
|
|
|
|
|
|
|
description => "no 'content' structure was provided", |
|
19
|
|
|
|
|
|
|
}, |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
"WebFetch::Input::PerlStruct::Exception::BadStruct" => { |
|
22
|
|
|
|
|
|
|
isa => "WebFetch::Exception", |
|
23
|
|
|
|
|
|
|
alias => "throw_badstruct", |
|
24
|
|
|
|
|
|
|
description => "content of 'content' was not recognizable", |
|
25
|
|
|
|
|
|
|
}, |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our @Options = ( ); |
|
30
|
|
|
|
|
|
|
our $Usage = ""; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# configuration parameters |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# no user-servicable parts beyond this point |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# register capabilities with WebFetch |
|
37
|
|
|
|
|
|
|
__PACKAGE__->module_register( "input:perlstruct" ); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub fetch |
|
40
|
|
|
|
|
|
|
{ |
|
41
|
|
|
|
|
|
|
my ( $self ) = @_; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# get the content from the provided perl structure |
|
44
|
|
|
|
|
|
|
if ( !defined $self->{content}) { |
|
45
|
|
|
|
|
|
|
throw_nostruct "content struct does not exist"; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
if ( ref($self->{content})->isa( "WebFetch::Data::Store" )) { |
|
48
|
|
|
|
|
|
|
$self->{data} = $self->{content}; |
|
49
|
|
|
|
|
|
|
return; |
|
50
|
|
|
|
|
|
|
} elsif ( ref($self->{content}) eq "HASH" ) { |
|
51
|
|
|
|
|
|
|
if (( exists $self->{content}{fields}) |
|
52
|
|
|
|
|
|
|
and ( exists $self->{content}{records}) |
|
53
|
|
|
|
|
|
|
and ( exists $self->{content}{wk_names})) |
|
54
|
|
|
|
|
|
|
{ |
|
55
|
|
|
|
|
|
|
$self->data->{fields} = $self->{content}{fields}; |
|
56
|
|
|
|
|
|
|
$self->data->{wk_names} = $self->{content}{wk_names}; |
|
57
|
|
|
|
|
|
|
$self->data->{records} = $self->{content}{records}; |
|
58
|
|
|
|
|
|
|
return; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
throw_badstruct "content should be a WebFetch::Data::Store"; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
|
65
|
|
|
|
|
|
|
__END__ |