/[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 606 by dpavlin, Fri Nov 28 22:22:07 2008 UTC
# Line 1  Line 1 
1  package Data::DelIcioUs;  package Frey::DelIcioUs;
2  use Moose;  use Moose;
3    
4  with 'Frey::Config';  extends 'Frey';
5  with 'Frey::Storage';  with 'Frey::Storage';
6    
7    use LWP::UserAgent;
8    use XML::Simple;
9    use Data::Dump qw/dump/;
10    
11  has 'username' => (  has 'username' => (
12          is => 'rw',          is => 'rw',
13          isa => 'Str',          isa => 'Str',
14          required => 1,          required => 1,
15          default => sub {          documentation => 'login on del.icio.us',
                 my $self = shift;  
                 $self->config->{username};  
         },  
16  );  );
17    
18  has 'password' => (  has 'password' => (
         is => 'rw',  
         isa => 'Str',  
         required => 1,  
         default => sub {  
                 my $self = shift;  
                 $self->config->{password};  
         },  
 );  
   
 has 'path' => (  
19          is => 'ro',          is => 'ro',
20          isa => 'Str',          isa => 'Str',
21          default => sub {          required => 1,
                 my $self = shift;  
                 'var/delicious/' . $self->username;  
         }  
22  );  );
23    
24  use LWP::UserAgent;  sub path {
25  use XML::Simple;          my $self = shift;
26  use Data::Dump qw/dump/;          'var/delicious/' . $self->username . '.yml';
27    }
28    
29  sub data {  sub posts {
30          my $self = shift;          my $self = shift;
31    
32          if ( my $posts = $self->load( $self->path ) ) {          if ( my $posts = $self->load( $self->path ) ) {
# Line 59  sub data { Line 48  sub data {
48          return $posts;          return $posts;
49  }  }
50    
51    sub as_data {
52            my $self = shift;
53            $self->posts;
54    }
55    
56    sub as_sponge {
57            my $self = shift;
58    
59            my $posts = $self->posts->{post};
60            die "not ARRAY ",dump( $posts ) unless ref($posts) eq 'ARRAY';
61    
62            my @NAME = keys %{ $posts->[0] };
63            my @rows;
64    
65            foreach my $post ( @$posts ) {
66                    my @row;
67                    push @row, $post->{ $_ } foreach @NAME;
68                    push @rows, \@row;
69            }
70    
71    
72            return {
73                    rows => \@rows,
74                    NAME => \@NAME,
75            }
76    }
77    
78  1;  1;

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

  ViewVC Help
Powered by ViewVC 1.1.26