--- trunk/lib/Frey/DelIcioUs.pm 2008/11/06 17:58:20 323 +++ trunk/lib/Frey/DelIcioUs.pm 2008/11/28 22:22:07 606 @@ -1,6 +1,7 @@ package Frey::DelIcioUs; use Moose; +extends 'Frey'; with 'Frey::Storage'; use LWP::UserAgent; @@ -11,6 +12,7 @@ is => 'rw', isa => 'Str', required => 1, + documentation => 'login on del.icio.us', ); has 'password' => ( @@ -19,16 +21,12 @@ required => 1, ); -has 'path' => ( - is => 'ro', - isa => 'Str', - default => sub { - my $self = shift; - 'var/delicious/' . $self->username; - } -); +sub path { + my $self = shift; + 'var/delicious/' . $self->username . '.yml'; +} -sub data { +sub posts { my $self = shift; if ( my $posts = $self->load( $self->path ) ) { @@ -46,8 +44,35 @@ warn substr($content,0,100), ' ... ', substr($content,-100); my $posts = XMLin( $content ); warn dump( $posts ); - $self->store( $self->path . '.yml', $posts ); + $self->store( $self->path, $posts ); return $posts; } +sub as_data { + my $self = shift; + $self->posts; +} + +sub as_sponge { + my $self = shift; + + my $posts = $self->posts->{post}; + die "not ARRAY ",dump( $posts ) unless ref($posts) eq 'ARRAY'; + + my @NAME = keys %{ $posts->[0] }; + my @rows; + + foreach my $post ( @$posts ) { + my @row; + push @row, $post->{ $_ } foreach @NAME; + push @rows, \@row; + } + + + return { + rows => \@rows, + NAME => \@NAME, + } +} + 1;