/[Frey]/trunk/lib/Frey/DelIcioUs.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/DelIcioUs.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/lib/Data/DelIcioUs.pm revision 226 by dpavlin, Sat Nov 1 01:03:40 2008 UTC trunk/lib/Frey/DelIcioUs.pm revision 337 by dpavlin, Sat Nov 8 23:22:03 2008 UTC
# Line 1  Line 1 
1  package Data::DelIcioUs;  package Frey::DelIcioUs;
2  use Moose;  use Moose;
3    
 with 'Frey::Config';  
4  with 'Frey::Storage';  with 'Frey::Storage';
5    
6    use LWP::UserAgent;
7    use XML::Simple;
8    use Data::Dump qw/dump/;
9    
10  has 'username' => (  has 'username' => (
11          is => 'rw',          is => 'rw',
12          isa => 'Str',          isa => 'Str',
13          required => 1,          required => 1,
         default => sub {  
                 my $self = shift;  
                 $self->config->{username};  
         },  
14  );  );
15    
16  has 'password' => (  has 'password' => (
         is => 'rw',  
         isa => 'Str',  
         required => 1,  
         default => sub {  
                 my $self = shift;  
                 $self->config->{password};  
         },  
 );  
   
 has 'path' => (  
17          is => 'ro',          is => 'ro',
18          isa => 'Str',          isa => 'Str',
19          default => sub {          required => 1,
                 my $self = shift;  
                 'var/delicious/' . $self->username;  
         }  
20  );  );
21    
22  use LWP::UserAgent;  sub path {
23  use XML::Simple;          my $self = shift;
24  use Data::Dump qw/dump/;          '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 ) ) {
# Line 59  sub data { Line 46  sub data {
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;

Legend:
Removed from v.226  
changed lines
  Added in v.337

  ViewVC Help
Powered by ViewVC 1.1.26