Jaipo/Service/Plurk.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 60 CC 3 SCAR 15.0
CC
3
Cov
0%
init
12.0
send_msg
2.0
read_user_timeline
2.0
CRAP 4.5
1 package Jaipo::Service::Plurk;
2 use warnings;
3 use strict;
4 use WWW::Plurk;
5 use base qw/Jaipo::Service Class::Accessor::Fast/;
6 use utf8;
7  
8 # XXX:
9 # www-plurk module can not work!! hate!!
10  
11 sub init {
12 my $self = shift;
13 my $caller = shift;
14 my $opt = $self->options;
15  
16 unless( $opt->{username} and $opt->{password} ) {
17  
18 # request to setup parameter
19 # XXX TODO: we need to simplify this, let it like jifty dbi schema or
20 # something
21 $caller->setup_service ( {
22 package_name => __PACKAGE__,
23 require_args => [ {
24 username => {
25 label => 'Username',
26 description => '',
27 type => 'text'
28 }
29 },
30 { password => {
31 label => 'Password',
32 description => '',
33 type => 'text'
34 } } ]
35 },
36 $opt
37 );
38 }
39  
40 Jaipo->config->set_service_option( 'Plurk' , $opt );
41  
42 my $plurk = new WWW::Plurk;
43  
44 unless( $plurk ) {
45 # XXX: need to implement logger: Jaipo->log->warn( );
46 print "plurk init failed\n";
47 }
48  
49 $plurk->login( $opt->{username} , $opt->{password} );
50  
51 $self->core( $plurk );
52 }
53  
54  
55 sub send_msg {
56 my ( $self , $message ) = @_;
57 print "Sending to Plurk...";
58 my $result = $self->core->add_plurk( content => $message );
59 print "Done\n";
60 }
61  
62 # updates from user himself
63 sub read_user_timeline {
64 my $self = shift;
65 my @plurks = $self->plurks;
66 for ( @plurks ) {
67 # XXX: make this work with text::table::zh
68 printf "%s %s %s",$_->{uid}, $_->{date_from}, $_->{date_offset};
69 }
70 }
71  
72 # updates from user's friends or channel
73 sub read_public_timeline {
74 my $self = shift;
75 }
76  
77  
78 sub read_global_timeline {
79 my $self = shift;
80  
81 }
82  
83  
84  
85  
86 1;