Show
Ignore:
Timestamp:
01/09/08 10:49:21 (7 years ago)
Author:
kentaro
Message:

lang/perl/WWW-Hatena: wrote a POD, added prereq modules into Makefile.PL

Location:
lang/perl/WWW-HatenaDiary/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/WWW-HatenaDiary/trunk/Makefile.PL

    r3939 r4255  
    1010    Getopt::Long 
    1111    Digest::MD5 
     12    Text::Hatena 
     13    Web::Scraper 
     14    WWW::Mechanize 
     15    JSON::Syck 
    1216/); 
    1317 
  • lang/perl/WWW-HatenaDiary/trunk/README

    r3939 r4255  
    33INSTALLATION 
    44 
    5 WWW::HatenaDiary installation is straightforward. If your CPAN shell is set up, 
    6 you should just be able to do 
     5WWW::HatenaDiary installation is straightforward. If your CPAN shell 
     6is set up, you should just be able to do 
    77 
    88    % cpan WWW::HatenaDiary 
     
    2525to read the documentation online with your favorite pager. 
    2626 
     27AUTHOR 
     28 
    2729Tokuhiro Matsuno 
     30Kentaro Kuribayashi 
  • lang/perl/WWW-HatenaDiary/trunk/lib/WWW/HatenaDiary.pm

    r4239 r4255  
    7676 
    7777    my $entry = Load($self->{mech}->content); 
    78  
    7978    if($args->{format}) { 
    8079        $entry->{body} = Text::Hatena->parse($entry->{body}); 
    8180    } 
    82  
    8381    $entry; 
    8482} 
     
    9795        carp "Invalid ymd format: $args->{date}. YYYY-MM-DD formatted date is required."; 
    9896    } 
    99 } 
    100  
    101 # TODO: implement retrieve_month method. 
    102 sub retrieve_month { 
    103     my ($self, $args) = @_; 
    104     die "Not implemented yet"; 
    10597} 
    10698 
     
    190182=head1 NAME 
    191183 
    192 WWW::HatenaDiary - 
     184WWW::HatenaDiary - CRUD interface to Hatena::Diary 
    193185 
    194186=head1 SYNOPSIS 
     
    196188  use WWW::HatenaDiary; 
    197189 
    198   my $hatena = WWW::HatenaDiary->new({ 
     190  my $diary = WWW::HatenaDiary->new({ 
    199191      login_id => $login_id, 
    200192      login_pw => $login_pw, 
     
    202194 
    203195  # Create 
    204   my $uri = $hatena->create({ 
    205       title => 'mixi', 
    206       body  => 'boofy', 
     196  my $edit_uri = $diary->create({ 
     197      title => $title, 
     198      body  => $body, 
     199  }); 
     200 
     201  # Retrieve 
     202  my $post = $diary->retrieve({ 
     203      uri => $edit_uri, 
     204  }) 
     205 
     206  my $day_body = $diary->retrieve_day({ 
     207      date => $date,     # $date must be YYYY-MM-DD formatted string 
    207208  }); 
    208209 
    209210  # Update 
    210   $uri = $hatena->update({ 
    211       uri   => $uri, 
    212       title => 'Update: mixi', 
    213       body  => "Update: boofy", 
    214   }); 
    215  
    216   $hatena->update_day({date => '2008-01-01', body => <<'EOS'}); 
    217 * title 1 
    218 body 1 
    219  
    220 * title 2 
    221 body 2 
    222 EOS 
    223  
    224   # Retrieve 
    225   my $body = $hatena->retrieve($uri) 
    226   my $day_body = $hatena->retrieve_day({date => '2008-01-01'}); 
     211  $edit_uri = $diary->update({ 
     212      uri   => $edit_uri, 
     213      title => $new_title, 
     214      body  => $new_body, 
     215  }); 
     216 
     217  $diary->update_day({ 
     218      date => $date,     # $date must be YYYY-MM-DD formatted string 
     219      body => $new_body, 
     220  }); 
    227221 
    228222  # Delete 
    229   $hatena->delete($uri);                # not implemented yet 
    230   $hatena->delete_day({date => $date}); 
     223  $diary->delete({       # not implemented yet 
     224      uri => $edit_uri, 
     225  }); 
     226 
     227  $diary->delete_day({, 
     228      date => $date,     # $date must be YYYY-MM-DD formatted string 
     229  }); 
    231230 
    232231=head1 DESCRIPTION 
    233232 
    234 WWW::HatenaDiary is 
    235  
    236 =head1 THANKS 
    237  
    238 typester++ some codes copied from Fuse::Hatena. 
     233WWW::HatenaDiary provides a CRUD interface to Hatena::Diary, aiming to 
     234help you efficiently communicate with the service with programatical 
     235ways. 
     236 
     237This module is, so far, for those who want to write some tools not 
     238only to retrieve data from diaries, but also to create/update/delete 
     239the posts at the same time. Which is why I adopted the way as if this 
     240module treats such API like AtomPP, and this module retrieves and 
     241returns raw formatted post content not a data already converted to 
     242HTML. 
     243 
     244=head1 METHODS 
     245 
     246=head2 new ( I<\%args> ) 
     247 
     248=over 4 
     249 
     250  my $diary = WWW::HatenaDiary->new({ 
     251      login_id => $login_id, 
     252      login_pw => $login_pw, 
     253  }); 
     254 
     255Creates and returns a new WWW::HatenaDiary object. Both C<login_id> 
     256and C<login_pw> are required. 
     257 
     258=back 
     259 
     260=head2 create ( I<\%args> ) 
     261 
     262=over 4 
     263 
     264  my $edit_uri = $diary->create({ 
     265      title => $title, 
     266      body  => $body, 
     267  }); 
     268 
     269Creates a new post and returns a URI as a L<URI> object for you to 
     270retrieve/update/delete the post later on. 
     271 
     272=back 
     273 
     274=head2 retrieve ( I<\%args> ) 
     275 
     276=over 4 
     277 
     278  my $post = $diary->retrieve({ 
     279      uri => $edit_uri, 
     280  }) 
     281 
     282Retrieves the post for C<uri>. The return value C<$post> is a 
     283reference to a hash which contains the fields as follows: 
     284 
     285=item title 
     286 
     287Title of the post. 
     288 
     289=item body 
     290 
     291Content of the post as a raw formatted data. 
     292 
     293=item editable 
     294 
     295Flag if you're authorized to edit the post or not. 
     296 
     297=item rkm 
     298 
     299Token which is internally used when this module sends a request. You 
     300needn't care about it. 
     301 
     302=back 
     303 
     304=head2 retrieve_day ( I<\%args> ) 
     305 
     306=over 4 
     307 
     308  my $day_body = $diary->retrieve_day({ 
     309      date => $date, # $date must be YYYY-MM-DD formatted string 
     310  }); 
     311 
     312Retrieves the post body for C<date>. So far, this method gets only the 
     313raw formatted content of the post. 
     314 
     315=back 
     316 
     317=head2 update ( I<\%args> ) 
     318 
     319=over 4 
     320 
     321  $edit_uri = $diary->update({ 
     322      uri   => $edit_uri, 
     323      title => $new_title, 
     324      body  => $new_body, 
     325  }); 
     326 
     327Updates the post for C<uri> and returns the URI as a L<URI> object for 
     328you to do with the post still more. 
     329 
     330=back 
     331 
     332=head2 update_day ( I<\%args> ) 
     333 
     334=over 4 
     335 
     336  $diary->update_day({ 
     337      date => $date,     # $date must be YYYY-MM-DD formatted string 
     338      body => $new_body, 
     339  }); 
     340 
     341Updates the whole posts of the C<date>. C<body> must be a 
     342Hatena::Diary style formatted data, that is, this method emulates the 
     343way when you write a post on your browser and send it via the form. 
     344 
     345=back 
     346 
     347=head2 delete ( I<\%args> ) **NOT IMPLEMENTED YET** 
     348 
     349=over 4 
     350 
     351  $diary->delete({ 
     352      uri => $edit_uri, 
     353  }); 
     354 
     355Deletes the post for C<uri>. 
     356 
     357=back 
     358 
     359=head2 delete_day ( I<\%args> ) 
     360 
     361=over 4 
     362 
     363  $diary->delete_day({ 
     364      date => $date, # $date must be YYYY-MM-DD formatted string 
     365  }); 
     366 
     367Deletes the whole posts of the C<date>. 
     368 
     369=back 
     370 
     371=head1 SEE ALSO 
     372 
     373=over 4 
     374 
     375=item * Hatena::Diary (Japanese) 
     376 
     377L<http://d.hatena.ne.jp/> 
     378 
     379=back 
     380 
     381=head1 ACKNOWLEDGMENT 
     382 
     383typester++ for some codes copied from Fuse::Hatena. 
    239384 
    240385=head1 AUTHOR 
     
    243388 
    244389Kentaro Kuribayashi E<lt>kentarok aaaatttt gmail dotottto commmmmE<gt> 
    245  
    246 =head1 SEE ALSO 
    247390 
    248391=head1 LICENSE