/[Frey]/branches/zimbardo/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 /branches/zimbardo/lib/Frey/DelIcioUs.pm

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

revision 315 by dpavlin, Wed Nov 5 21:12:31 2008 UTC revision 455 by dpavlin, Wed Nov 19 15:28:23 2008 UTC
# Line 1  Line 1 
1  package Frey::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,
14          default => sub {          documentation => 'login on del.icio.us',
                 my $self = shift;  
                 $self->config->{username};  
         },  
15  );  );
16    
17  has 'password' => (  has 'password' => (
         is => 'rw',  
         isa => 'Str',  
         required => 1,  
         default => sub {  
                 my $self = shift;  
                 $self->config->{password};  
         },  
 );  
   
 has 'path' => (  
18          is => 'ro',          is => 'ro',
19          isa => 'Str',          isa => 'Str',
20          default => sub {          required => 1,
                 my $self = shift;  
                 'var/delicious/' . $self->username;  
         }  
21  );  );
22    
23  use LWP::UserAgent;  sub path {
24  use XML::Simple;          my $self = shift;
25  use Data::Dump qw/dump/;          'var/delicious/' . $self->username . '.yml';
26    }
27    
28  sub data {  sub posts {
29          my $self = shift;          my $self = shift;
30    
31          if ( my $posts = $self->load( $self->path ) ) {          if ( my $posts = $self->load( $self->path ) ) {
# Line 59  sub data { Line 47  sub data {
47          return $posts;          return $posts;
48  }  }
49    
50    sub as_data {
51            my $self = shift;
52            $self->posts;
53    }
54    
55    sub as_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.315  
changed lines
  Added in v.455

  ViewVC Help
Powered by ViewVC 1.1.26