--- trunk/lib/Frey/DelIcioUs.pm 2008/11/05 21:12:31 315 +++ trunk/lib/Frey/DelIcioUs.pm 2008/11/08 23:22:03 337 @@ -1,43 +1,30 @@ package Frey::DelIcioUs; use Moose; -with 'Frey::Config'; with 'Frey::Storage'; +use LWP::UserAgent; +use XML::Simple; +use Data::Dump qw/dump/; + has 'username' => ( is => 'rw', isa => 'Str', required => 1, - default => sub { - my $self = shift; - $self->config->{username}; - }, ); has 'password' => ( - is => 'rw', - isa => 'Str', - required => 1, - default => sub { - my $self = shift; - $self->config->{password}; - }, -); - -has 'path' => ( is => 'ro', isa => 'Str', - default => sub { - my $self = shift; - 'var/delicious/' . $self->username; - } + required => 1, ); -use LWP::UserAgent; -use XML::Simple; -use Data::Dump qw/dump/; +sub path { + my $self = shift; + 'var/delicious/' . $self->username . '.yml'; +} -sub data { +sub posts { my $self = shift; if ( my $posts = $self->load( $self->path ) ) { @@ -59,4 +46,32 @@ return $posts; } +sub data { + my $self = shift; +# $self->posts; + $self->sponge; +} + +sub 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;