public
Description: WebService::Hatena::Diary - CRUD interface to Hatena::Diary with AtomPub API
Homepage:
Clone URL: git://github.com/hakobe/webservice-hatena-diary.git
- POD を書いた
- テストがあやしかったところを修正
hakobe (author)
Tue Sep 23 07:57:51 -0700 2008
commit  39e8fcff70673b9c92451462ad236acf4c88a713
tree    43a96e98e90faf9879fcfdc5a8f01c7f1956c859
parent  286e0e5289d8a070b4ba53c96ab5e904a6673286
0
...
24
25
26
 
 
 
 
 
27
...
24
25
26
27
28
29
30
31
32
0
@@ -24,4 +24,9 @@ WebService::Hatena::Diary documentation is available as in POD. So you can do:
0
 
0
 to read the documentation online with your favorite pager.
0
 
0
+DEVELOPMENT
0
+
0
+If you want to see latest version of this module, please see
0
+https://github.com/hakobe/webservice-hatena-diary/tree
0
+
0
 Yohei Fushii
...
209
210
211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
213
214
215
 
216
217
218
219
220
 
221
222
223
224
225
 
 
 
 
 
 
 
 
 
 
 
226
227
 
228
229
 
230
231
 
232
233
...
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
 
441
442
443
444
445
446
447
448
449
450
451
452
 
453
454
 
455
456
 
457
458
459
0
@@ -209,25 +209,251 @@ WebService::Hatena::Diary - A Perl Interface for Hatena::Diary AtomPub API
0
 WebService::Hatena::Diary is a simple wrapper of Hatena::Diary AtomPub API. 
0
 This provides CRUD interfaces for Hatena::Diary and it's draft entries. 
0
 
0
+=head1 METHOD
0
+
0
+=head2 new ( I<\%args> )
0
+
0
+=over 4
0
+
0
+  my $diary = WebService::Hatena::Diary->new({
0
+      username  => $username,
0
+      dusername => $dusername,
0
+      password  => $password,
0
+      mode      => $mode,
0
+  });
0
+
0
+Create a WebService::Hatena::Diary object.
0
+
0
+=over 4
0
+
0
+=item * 
0
+
0
+B<username>
0
+
0
+Your Hatena id.
0
+
0
+=item *
0
+
0
+B<dusername> (Optional)
0
+
0
+Diary name that you want to manipulate.
0
+Default is username.
0
+
0
+=item *
0
+
0
+B<password>
0
+
0
+Password for your Hatena id.
0
+
0
+=item *
0
+
0
+B<mode> (Optional)
0
+
0
+API mode ( C<blog> | C<draft> ).
0
+Default is C<blog>.
0
+
0
+=back
0
+
0
+=back
0
+
0
+
0
+=head2 ua
0
+
0
+=over 4
0
+
0
+  $diary->ua;
0
+
0
+  Returns a UserAgent of this API.
0
+
0
+=back
0
+
0
+
0
+=head2 errstr
0
+
0
+=over 4
0
+
0
+  $diary->errstr;
0
+
0
+Returns a error messages of the last error.
0
+
0
+=back
0
+
0
+=head2 list
0
+
0
+=over 4
0
+
0
+  my @entries = $diary->list;
0
+
0
+Returns a LIST of entries of the specified (blog|draft). 
0
+Each entry has values blow as a HASH object:
0
+
0
+=over 4
0
+
0
+=item *
0
+
0
+B<edit_uri>
0
+
0
+Edit URI is a URI to identify a entry.
0
+
0
+=item *
0
+
0
+B<title>
0
+
0
+Title of a entry.
0
+
0
+=item *
0
+
0
+B<content>
0
+
0
+Content of a entry as a html format.
0
+
0
+=item *
0
+
0
+B<date>
0
+
0
+YYYY-MM-DD style date of a entry.
0
+
0
+=back
0
+
0
+=back
0
+
0
+
0
+=head2 create ( I<\%args> )
0
+
0
+=over 4
0
+
0
+  my $edit_uri = $diary->create({
0
+      title   => $title,
0
+      content => $content,
0
+      date    => $date,
0
+  });
0
+
0
+Create a new entry of the specified (blog|draft).
0
+Returns Edit URI of a created entry if succeed.
0
+
0
+You have to pass C<date> on a YYYY-MM-DD format.
0
+
0
+=back
0
+
0
+
0
+=head2 retrieve ( I<$edit_uri> )
0
+
0
+=over 4
0
+
0
+  my $entry = $diary->retrieve($edit_uri);
0
+
0
+Returns a entry specified by an Edit URI as a HASH object like below:
0
+
0
+=over 4
0
+
0
+=item *
0
+
0
+B<title>
0
+
0
+Title of a entry.
0
+
0
+=item *
0
+
0
+B<content>
0
+
0
+Content of a entry as a html format.
0
+
0
+=item *
0
+
0
+B<hatena_syntax>
0
+
0
+Content of a entry as a hatena syntax format.
0
+
0
+=item *
0
+
0
+B<date>
0
+
0
+YYYY-MM-DD style date of a entry.
0
+
0
+=back
0
+
0
+=back
0
+
0
+
0
+=head2 update ( I<$edit_uri>, I<\%args> )
0
+
0
+=over 4
0
+
0
+  $diary->update($edit_uri, {
0
+      title   => $title,
0
+      content => $content,
0
+  });
0
+
0
+Update a entry specified by an Edit URI.
0
+Returns 1 if succeed.
0
+
0
+=back
0
+
0
+
0
+=head2 delete ( I<$edit_uri> )
0
+
0
+=over 4
0
+
0
+  $diary->delete($edit_uri);
0
+
0
+Delete a entry specified by an Edit URI.
0
+Returns 1 if succeed.
0
+
0
+=back
0
+
0
+
0
+=head2 publish ( I<$edit_uri> )
0
+
0
+=over 4
0
+
0
+  $diary->publish($edit_uri);
0
+
0
+Publish a I<draft> entry specified by an Edit URI.
0
+Returns 1 if succeed.
0
+
0
+If you publish a draft entry, the entry will be deleted from draft, 
0
+and a new I<blog> entry will be created.
0
+
0
+=back
0
+
0
+
0
+=head1 DEVELOPMENT
0
+
0
+If you want to see latest version of this module, please see
0
+L<https://github.com/hakobe/webservice-hatena-diary/tree>
0
+
0
+
0
 =head1 AUTHOR
0
 
0
 Yohei Fushii E<lt>hakobe@gmail.comE<gt>
0
 
0
+
0
 =head1 LICENSE
0
 
0
 This library is free software; you can redistribute it and/or modify
0
 it under the same terms as Perl itself.
0
 
0
+
0
 =head1 SEE ALSO
0
 
0
 =over 4
0
 
0
-=item L<http://d.hatena.ne.jp>
0
+=item * 
0
+
0
+L<http://d.hatena.ne.jp>
0
+
0
+=item * 
0
+
0
+L<http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%C0%A5%A4%A5%A2%A5%EA%A1%BCAtomPub>
0
+
0
+=item * 
0
+
0
+L<WWW::HatenaDiary>
0
 
0
-=item L<http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%C0%A5%A4%A5%A2%A5%EA%A1%BCAtomPub>
0
+=item 
0
 
0
-=item L<WWW::HatenaDiary>
0
+L<XML::Atom>
0
 
0
-=item L<XML::Atom>
0
+=back
0
 
0
 =cut
...
18
19
20
21
 
22
23
24
...
94
95
96
 
97
 
98
99
 
100
101
102
103
104
 
 
 
 
 
 
 
 
105
106
...
18
19
20
 
21
22
23
24
...
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
0
@@ -18,7 +18,7 @@ my $dusername = $ENV{WEBSERVICE_HATENA_DIARY_TEST_DUSERNAME} || $username;
0
 my $password  = $ENV{WEBSERVICE_HATENA_DIARY_TEST_PASSWORD};
0
 
0
 if ($username && $password) {
0
-    plan tests => 16;
0
+    plan tests => 17;
0
 }
0
 else {
0
     plan skip_all => "Set ENV:WEBSERVICE_HATENA_DIARY_TEST_USERNAME/PASSWORD";
0
@@ -94,13 +94,24 @@ $edit_uri = $diary->create({
0
 });
0
 
0
 # publish
0
+sleep 3; # wait for create
0
 $diary->publish($edit_uri);
0
+
0
 $diary->{mode} = 'blog'; # blogモード
0
 
0
+sleep 3; # wait for publish
0
 $entry = ($diary->list)[0];
0
 is($entry->{title},     $input_data->{title});
0
 like($entry->{content}, qr/$input_data->{content}/);
0
 is($entry->{date},      $now->ymd);
0
 
0
+## delete
0
+$edit_uri = $entry->{edit_uri};
0
+$diary->delete($edit_uri);
0
+$entry = $diary->retrieve($edit_uri);
0
+ok(!$entry);
0
+$diary->client->{_errstr} = ''; # errorをクリア
0
+
0
+
0
 $diary->{mode} = 'draft'; # draftモード
0
 
...
15
16
17
 
 
 
 
 
 
 
 
 
 
 
 
 
...
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
0
@@ -15,3 +15,16 @@ all_pod_files_spelling_ok('lib');
0
 __DATA__
0
 Yohei
0
 Fushii
0
+API
0
+AtomPub
0
+DD
0
+Hatena
0
+URI
0
+YYYY
0
+blog
0
+dusername
0
+errstr
0
+hatena
0
+html
0
+ua
0
+username

Comments