/[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

revision 333 by dpavlin, Sat Nov 8 16:59:08 2008 UTC revision 606 by dpavlin, Fri Nov 28 22:22:07 2008 UTC
# Line 1  Line 1 
1  package Frey::DelIcioUs;  package Frey::DelIcioUs;
2  use Moose;  use Moose;
3    
4    extends 'Frey';
5  with 'Frey::Storage';  with 'Frey::Storage';
6    
7  use LWP::UserAgent;  use LWP::UserAgent;
# Line 11  has 'username' => ( Line 12  has 'username' => (
12          is => 'rw',          is => 'rw',
13          isa => 'Str',          isa => 'Str',
14          required => 1,          required => 1,
15            documentation => 'login on del.icio.us',
16  );  );
17    
18  has 'password' => (  has 'password' => (
# Line 21  has 'password' => ( Line 23  has 'password' => (
23    
24  sub path {  sub path {
25          my $self = shift;          my $self = shift;
26          'var/delicious/' . $self->username;          '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 42  sub data { Line 44  sub data {
44          warn substr($content,0,100), ' ... ', substr($content,-100);          warn substr($content,0,100), ' ... ', substr($content,-100);
45          my $posts = XMLin( $content );          my $posts = XMLin( $content );
46          warn dump( $posts );          warn dump( $posts );
47          $self->store( $self->path . '.yml', $posts );          $self->store( $self->path, $posts );
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.333  
changed lines
  Added in v.606

  ViewVC Help
Powered by ViewVC 1.1.26