21 |
|
|
22 |
sub path { |
sub path { |
23 |
my $self = shift; |
my $self = shift; |
24 |
'var/delicious/' . $self->username; |
'var/delicious/' . $self->username . '.yml'; |
25 |
} |
} |
26 |
|
|
27 |
sub data { |
sub posts { |
28 |
my $self = shift; |
my $self = shift; |
29 |
|
|
30 |
if ( my $posts = $self->load( $self->path ) ) { |
if ( my $posts = $self->load( $self->path ) ) { |
42 |
warn substr($content,0,100), ' ... ', substr($content,-100); |
warn substr($content,0,100), ' ... ', substr($content,-100); |
43 |
my $posts = XMLin( $content ); |
my $posts = XMLin( $content ); |
44 |
warn dump( $posts ); |
warn dump( $posts ); |
45 |
$self->store( $self->path . '.yml', $posts ); |
$self->store( $self->path, $posts ); |
46 |
return $posts; |
return $posts; |
47 |
} |
} |
48 |
|
|
49 |
|
sub data { |
50 |
|
my $self = shift; |
51 |
|
# $self->posts; |
52 |
|
$self->sponge; |
53 |
|
} |
54 |
|
|
55 |
|
sub sponge { |
56 |
|
my $self = shift; |
57 |
|
|
58 |
|
my $posts = $self->posts->{post}; |
59 |
|
die "not ARRAY ",dump( $posts ) unless ref($posts) eq 'ARRAY'; |
60 |
|
|
61 |
|
my @NAME = keys %{ $posts->[0] }; |
62 |
|
my @rows; |
63 |
|
|
64 |
|
foreach my $post ( @$posts ) { |
65 |
|
my @row; |
66 |
|
push @row, $post->{ $_ } foreach @NAME; |
67 |
|
push @rows, \@row; |
68 |
|
} |
69 |
|
|
70 |
|
|
71 |
|
return { |
72 |
|
rows => \@rows, |
73 |
|
NAME => \@NAME, |
74 |
|
} |
75 |
|
} |
76 |
|
|
77 |
1; |
1; |