addfile ./examples/dump.pl
hunk ./examples/dump.pl 1
+#! /usr/bin/perl -I../lib
+
+use WWW::VieDeMerde;
+
+my $vdm = WWW::VieDeMerde->new();
+
+print $vdm->raw_xml('view', 'last');
+
addfile ./examples/fml.pl
hunk ./examples/fml.pl 1
+#! /usr/bin/perl -I../lib
+
+use WWW::VieDeMerde;
+
+my $vdm = WWW::VieDeMerde->new(lang => 'en');
+my $id = shift;
+
+my $item;
+if ($id) {
+    $item = $vdm->get($id);
+}
+else {
+   $item = $vdm->random();
+}
+die unless defined($item);
+print $item->text, "\n";
+print $item->id, "\n";
+
hunk ./examples/random-fml.pl 1
-#! /usr/bin/perl -I../lib
-
-use WWW::VieDeMerde;
-
-my $vdm = WWW::VieDeMerde->new(lang => 'en');
-
-my $r = $vdm->random();
-print $r->text, "\n";
-print $r->id, "\n";
-
rmfile ./examples/random-fml.pl
hunk ./examples/random-vdm.pl 1
-#! /usr/bin/perl -I../lib
-
-use WWW::VieDeMerde;
-
-my $vdm = WWW::VieDeMerde->new();
-
-my $r = $vdm->random();
-print $r->text, "\n";
-print $r->id, "\n";
-
rmfile ./examples/random-vdm.pl
hunk ./examples/vdm.pl 6
+my $id = shift;
hunk ./examples/vdm.pl 8
-my $r = $vdm->get(shift);
-print $r->text, "\n";
-print $r->id, "\n";
+my $item;
+if ($id) {
+    $item = $vdm->get($id);
+}
+else {
+   $item = $vdm->random();
+}
+die unless defined($item);
+print $item->text, "\n";
+print $item->id, "\n";
hunk ./lib/WWW/VieDeMerde.pm 124
-    my $xml = $self->run("view", "last", $page);
+    my $xml = $self->_run("view", "last", $page);
hunk ./lib/WWW/VieDeMerde.pm 126
-    if (parse($xml, $t)) {
+    if (defined($xml)) {
hunk ./lib/WWW/VieDeMerde.pm 156
-    my $xml = $self->run("view", "random");
-    if (parse($xml, $t)) {
+    my $xml = $self->_run("view", "random");
+    if (defined($xml)) {
hunk ./lib/WWW/VieDeMerde.pm 175
-    my $xml = $self->run("view", $id);
+    my $xml = $self->_run("view", $id);
hunk ./lib/WWW/VieDeMerde.pm 177
-    if (parse($xml, $t)) {
+    if (defined($xml)) {
hunk ./lib/WWW/VieDeMerde.pm 199
-    my $xml = $self->run("view", "top", $page);
-    if (parse($xml, $t)) {
+    my $xml = $self->_run("view", "top", $page);
+    if (defined($xml)) {
hunk ./lib/WWW/VieDeMerde.pm 219
-    my $xml = $self->run("view", "top_day", $page);
-    if (parse($xml, $t)) {
+    my $xml = $self->_run("view", "top_day", $page);
+    if (defined($xml)) {
hunk ./lib/WWW/VieDeMerde.pm 253
-    my $xml = $self->run("view", "top_week", $page);
-    if (parse($xml, $t)) {
+    my $xml = $self->_run("view", "top_week", $page);
+    if (defined($xml)) {
hunk ./lib/WWW/VieDeMerde.pm 287
-    my $xml = $self->run("view", "top_mois", $page);
-    if (parse($xml, $t)) {
+    my $xml = $self->_run("view", "top_mois", $page);
+    if (defined($xml)) {
hunk ./lib/WWW/VieDeMerde.pm 320
-    my $xml = $self->run("view", "flop", $page);
-    if (parse($xml, $t)) {
+    my $xml = $self->_run("view", "flop", $page);
+    if (defined($xml)) {
hunk ./lib/WWW/VieDeMerde.pm 340
-    my $xml = $self->run("view", "flop_day", $page);
-    if (parse($xml, $t)) {
+    my $xml = $self->_run("view", "flop_day", $page);
+    if (defined($xml)) {
hunk ./lib/WWW/VieDeMerde.pm 373
-    my $xml = $self->run("view", "flop_week", $page);
-    if (parse($xml, $t)) {
+    my $xml = $self->_run("view", "flop_week", $page);
+    if (defined($xml)) {
hunk ./lib/WWW/VieDeMerde.pm 406
-    my $xml = $self->run("view", "flop_month", $page);
-    if (parse($xml, $t)) {
+    my $xml = $self->_run("view", "flop_month", $page);
+    if (defined($xml)) {
hunk ./lib/WWW/VieDeMerde.pm 438
-    my $xml = $self->run("view", "categories");
+    my $xml = $self->_run("view", "categories");
hunk ./lib/WWW/VieDeMerde.pm 441
-    # if (parse($xml, $t)) {
+    # if (defined($xml)) {
hunk ./lib/WWW/VieDeMerde.pm 461
-    my $xml = $self->run("view", $cat, $page);
-    if (parse($xml, $t)) {
+    my $xml = $self->_run("view", $cat, $page);
+    if (defined($xml)) {
hunk ./lib/WWW/VieDeMerde.pm 469
+=head2 errors
+
+Extract errors. Not implemented.
+
+=cut
+
+sub errors {
+    my $self = shift;
+    my $e = shift;
+    if (defined $e) {
+        $self->{errors} = $e;
+        return;
+    }
+    else {
+        return $self->{errors}
+    }
+}
+
hunk ./lib/WWW/VieDeMerde.pm 490
-=head2 run
+=head2 _run
hunk ./lib/WWW/VieDeMerde.pm 496
-sub run {
+sub _run {
hunk ./lib/WWW/VieDeMerde.pm 506
+    my $t = $self->{twig};
hunk ./lib/WWW/VieDeMerde.pm 508
-    my $cmd = $url . "/" . join("/", @commands);
+    my $cmd = $url . '/' . join("/", @commands);
+    my $args = '';
hunk ./lib/WWW/VieDeMerde.pm 511
-        $cmd .= "?key=$key";
+        $args .= '?key=' . $key;
hunk ./lib/WWW/VieDeMerde.pm 514
-        $cmd .= "&token=$token";
+        $args .= '&token=' . $token;
hunk ./lib/WWW/VieDeMerde.pm 517
-        $cmd .= "&language=$lang";
+        $args .= '&language=' . $lang;
hunk ./lib/WWW/VieDeMerde.pm 520
-    my $response = $ua->get($cmd);
+    my $response = $ua->get($cmd . $args);
hunk ./lib/WWW/VieDeMerde.pm 523
-        return $response->content;
-    }
-    else {
-        carp $response->status_line;
-        return undef;
-    }
-}
-
-=head2 parse
-
-parse($xml, $t) is true if $xml is valid xml when parsed with parser $t.
-
-=cut
+        my $xml = $response->content;
+        if (defined($xml) and $t->safe_parse($xml)) {
+            my $root = $t->root;
hunk ./lib/WWW/VieDeMerde.pm 527
-sub parse {
-    my $xml = shift;
-    my $t = shift;
+            my $errors = $root->first_child("errors");
+            my @errors = map {$_->text} $errors->children('error');
+            if (@errors) {
+                map {carp($_)} @errors;
+                $self->errors(\@errors);
+                return undef;
+            }
hunk ./lib/WWW/VieDeMerde.pm 535
-    if (defined($xml)) {
-        if ($t->safe_parse($xml)) {
-            my $root = $t->root;
-            if ($root->tag eq "root") {
-                if ($root->first_child("code")->text == 1) {
-                    return 1;
-                }
+            my $items = $root->first_child("items");
+            my @items = $items->children('item');
+            if (! @items) {
+                my $error = "No item found";
+                carp $error;
+                $self->errors([$error]);
+                return undef;
hunk ./lib/WWW/VieDeMerde.pm 543
+            print "toto\n";
+            return $xml;
hunk ./lib/WWW/VieDeMerde.pm 547
-
-    return 0;
+    else {
+        carp $response->status_line;
+        $self->errors([$response->status_line]);
+        return undef;
+    }
hunk ./lib/WWW/VieDeMerde.pm 554
-=head2 errors
+=head2 raw_xml
hunk ./lib/WWW/VieDeMerde.pm 556
-Extract errors. Not implemented.
+Outputs raw xml for the given commands.
hunk ./lib/WWW/VieDeMerde.pm 560
-sub errors {
-    my $t = shift;
-
-    return undef;
+sub raw_xml {
+    my $self = shift;
+    return $self->_run(@_);
hunk ./t/fmylife.t 53
-    is($fml->from_cat($_), 15, "cat($_) returns a list with 15 entries");
+    is($fml->from_cat($_), 15, "from_cat($_) returns a list with 15 entries");
hunk ./lib/WWW/VieDeMerde.pm 7
-
hunk ./lib/WWW/VieDeMerde.pm 523
-        if (defined($xml) and $t->safe_parse($xml)) {
-            my $root = $t->root;
-
-            my $errors = $root->first_child("errors");
-            my @errors = map {$_->text} $errors->children('error');
-            if (@errors) {
-                map {carp($_)} @errors;
-                $self->errors(\@errors);
-                return undef;
-            }
-
-            my $items = $root->first_child("items");
-            my @items = $items->children('item');
-            if (! @items) {
-                my $error = "No item found";
-                carp $error;
-                $self->errors([$error]);
-                return undef;
-            }
-            print "toto\n";
-            return $xml;
-        }
+        return undef if $self->_errors($xml) == 1;
+        return $xml;
hunk ./lib/WWW/VieDeMerde.pm 533
+=head2 _errors 
+
+Detect errors in an xml fragment returned by _run.
+
+=cut
+
+sub _errors {
+    my $self = shift;
+    my $xml = shift;
+
+    my $t = $self->{twig};
+
+    if (defined($xml) and $t->safe_parse($xml)) {
+        my $root = $t->root;
+
+        my $errors = $root->first_child("errors");
+        my @errors = map {$_->text} $errors->children('error');
+        if (@errors) {
+            map {carp($_)} @errors;
+            $self->errors(\@errors);
+            return 1;
+        }
+        
+        my $items = $root->first_child("items");
+        my @items = $items->children('item');
+        if (! @items) {
+            my $error = "No item found";
+            carp $error;
+            $self->errors([$error]);
+                return 2;
+        }
+        return 0;
+    }
+}
+
hunk ./lib/WWW/VieDeMerde.pm 624
+=head1 SEE ALSO
+
+L<WWW::FMyLife>
+
+In early development, it seems to intend to support votes and comments
+which is not my priority right now. Supports both French and English
+version, despite the name.
hunk ./lib/WWW/VieDeMerde.pm 82
-        key => "readonly",
+        key => 'readonly',
hunk ./lib/WWW/VieDeMerde.pm 84
-        url => "http://api.betacie.com",
+        url => 'http://api.betacie.com',
hunk ./lib/WWW/VieDeMerde.pm 123
-    my $xml = $self->_run("view", "last", $page);
+    my $xml = $self->_run('view', 'last', $page);
hunk ./lib/WWW/VieDeMerde.pm 155
-    my $xml = $self->_run("view", "random");
+    my $xml = $self->_run('view', 'random');
hunk ./lib/WWW/VieDeMerde.pm 174
-    my $xml = $self->_run("view", $id);
+    my $xml = $self->_run('view', $id);
hunk ./lib/WWW/VieDeMerde.pm 198
-    my $xml = $self->_run("view", "top", $page);
+    my $xml = $self->_run('view', 'top', $page);
hunk ./lib/WWW/VieDeMerde.pm 218
-    my $xml = $self->_run("view", "top_day", $page);
+    my $xml = $self->_run('view', 'top_day', $page);
hunk ./lib/WWW/VieDeMerde.pm 252
-    my $xml = $self->_run("view", "top_week", $page);
+    my $xml = $self->_run('view', 'top_week', $page);
hunk ./lib/WWW/VieDeMerde.pm 286
-    my $xml = $self->_run("view", "top_mois", $page);
+    my $xml = $self->_run('view', 'top_mois', $page);
hunk ./lib/WWW/VieDeMerde.pm 319
-    my $xml = $self->_run("view", "flop", $page);
+    my $xml = $self->_run('view', 'flop', $page);
hunk ./lib/WWW/VieDeMerde.pm 339
-    my $xml = $self->_run("view", "flop_day", $page);
+    my $xml = $self->_run('view', 'flop_day', $page);
hunk ./lib/WWW/VieDeMerde.pm 372
-    my $xml = $self->_run("view", "flop_week", $page);
+    my $xml = $self->_run('view', 'flop_week', $page);
hunk ./lib/WWW/VieDeMerde.pm 405
-    my $xml = $self->_run("view", "flop_month", $page);
+    my $xml = $self->_run('view', 'flop_month', $page);
hunk ./lib/WWW/VieDeMerde.pm 437
-    my $xml = $self->_run("view", "categories");
-    warn "WWW::VieDeMerde->categories gives raw xml";
+    my $xml = $self->_run('view', 'categories');
+    warn 'WWW::VieDeMerde->categories gives raw xml';
hunk ./lib/WWW/VieDeMerde.pm 460
-    my $xml = $self->_run("view", $cat, $page);
+    my $xml = $self->_run('view', $cat, $page);
hunk ./lib/WWW/VieDeMerde.pm 507
-    my $cmd = $url . '/' . join("/", @commands);
+    my $cmd = $url . '/' . join('/', @commands);
hunk ./lib/WWW/VieDeMerde.pm 548
-        my $errors = $root->first_child("errors");
+        my $errors = $root->first_child('errors');
hunk ./lib/WWW/VieDeMerde.pm 556
-        my $items = $root->first_child("items");
+        my $items = $root->first_child('items');
hunk ./lib/WWW/VieDeMerde.pm 559
-            my $error = "No item found";
+            my $error = 'No item found';
hunk ./lib/WWW/VieDeMerde/Message.pm 36
-A WWW::VieDeMerde::Message object describes a fmylife or viedemerde entry. You probably do not need to create yourself such object, L<WWW::VieDeMerde> manage it.
+A WWW::VieDeMerde::Message object describes a fmylife or viedemerde item. You probably do not need to create yourself such object, L<WWW::VieDeMerde> manage it.
hunk ./lib/WWW/VieDeMerde.pm 20
-Version 0.1
+Version 0.031
hunk ./lib/WWW/VieDeMerde.pm 24
-our $VERSION = '0.1';
+our $VERSION = '0.031';
hunk ./lib/WWW/VieDeMerde/Message.pm 17
-Version 0.1
+Version 0.031
hunk ./lib/WWW/VieDeMerde/Message.pm 21
-our $VERSION = '0.1';
+our $VERSION = '0.031';
hunk ./lib/WWW/VieDeMerde.pm 165
-C<< $vdm->get($id) >> return the item number $id.
+C<< $vdm->get($id) >> returns the item number $id.
hunk ./lib/WWW/VieDeMerde/Message.pm 30
-    print $tata->texte, $tata->auteur;
+    print $tata->text, $tata->author;
hunk ./MANIFEST 4
+examples/comments.pl
+examples/dump.pl
+examples/fml.pl
hunk ./MANIFEST 8
-examples/random-fml.pl
-examples/random-vdm.pl
+examples/vdm.pl
hunk ./MANIFEST 12
-MANIFEST
+MANIFEST			This list of files
hunk ./MANIFEST 10
+lib/WWW/VieDeMerde/Comment.pm
addfile ./examples/comments.pl
hunk ./examples/comments.pl 1
+#! /usr/bin/perl -I../lib
+
+use WWW::VieDeMerde;
+
+my $vdm = WWW::VieDeMerde->new();
+my $id = shift;
+
+my $item = $vdm->get($id);
+die unless defined($item);
+print $item->text, "\n";
+print $item->id, "\n\n";
+
+my @comments = $vdm->comments($item->id);
+
+foreach (@comments) {
+    print $_->text, "\n  -- ", $_->author, "\n";
+}
+
hunk ./lib/WWW/VieDeMerde.pm 11
+use WWW::VieDeMerde::Comment;
hunk ./lib/WWW/VieDeMerde.pm 35
+    my $tata = $toto->get(1234);
hunk ./lib/WWW/VieDeMerde.pm 176
-    my $xml = $self->_run('view', $id);
-
+    my $xml = $self->_run('view', $id, 'nocomment');
hunk ./lib/WWW/VieDeMerde.pm 184
+=head2 comments
+
+C<< $vdm->comments($id) >> returns the comments of the item $id.
+
+=cut
+
+sub comments {
+    my $self = shift;
+    my $id = shift;
+    my $t = $self->{twig};
+
+    my $xml = $self->_run('view', $id);
+    if (defined($xml)) {
+        my @l = WWW::VieDeMerde::Comment->parse($t);
+        return @l;
+    }
+    return undef;
+}
+
addfile ./lib/WWW/VieDeMerde/Comment.pm
hunk ./lib/WWW/VieDeMerde/Comment.pm 1
+package WWW::VieDeMerde::Comment;
+
+use warnings;
+use strict;
+use Carp;
+
+use XML::Twig;
+
+=encoding utf8
+
+=head1 NAME
+
+WWW::VieDeMerde::Comment - A message from VieDeMerde.fr
+
+=head1 VERSION
+
+Version 0.1
+
+=cut
+
+our $VERSION = '0.1';
+
+=head1 SYNOPSIS
+
+    use WWW::VieDeMerde;
+    
+    my $toto = WWW::VieDeMerde->new();
+    my @c = $toto->comments(1664);
+    foreach @c {
+       print $_->text, $_->author;
+    }
+
+=head1 DESCRIPTION
+
+You should first read the documentation L<WWW::VieDeMerde> !
+
+A WWW::VieDeMerde::Comment object describes a fmylife or viedemerde comment. You probably do not need to create yourself such object, L<WWW::VieDeMerde> manage it.
+
+The following accessors are useful:
+
+=over 4
+
+=item * id
+
+=item * author
+
+=item * date
+
+=item * text
+
+=back
+
+=head1 METHODS
+
+=head2 new
+
+Create a new WWW::VieDeMerde::Comment given a vdm node the xml response to a query.
+
+=cut
+
+sub new {
+    my $class = shift;
+    my $t     = shift;
+
+    my $self = {};
+    bless($self, $class);
+
+    $self->{id} = $t->att('id');
+    foreach ($t->children()) {
+        my $tag = $_->tag;
+        $self->{$tag} = $_->text;
+    }
+
+    return $self;
+}
+
+
+=head2 parse
+
+Take an xml tree and return a list of WWW::VieDeMerde::Comment.
+qu'il contient.
+
+=cut
+
+#'
+
+sub parse {
+    my $class = shift;
+    my $t     = shift;
+
+    my $root = $t->root;
+    my $vdms = $root->first_child('comments');
+
+    my @vdm = $vdms->children('comment');
+
+    my @result = ();
+
+    foreach (@vdm) {
+        my $m = WWW::VieDeMerde::Comment->new($_);
+        push @result, $m;
+    }
+
+    return @result;
+}
+
+# read-only accessors
+for my $attr (qw(id author date text )) {
+    no strict 'refs';
+    *{"WWW::VieDeMerde::Comment::$attr"} = sub { $_[0]{$attr} }
+}
+
+=head1 AUTHOR
+
+Olivier Schwander, C<< <olivier.schwander at ens-lyon.org> >>
+
+=head1 BUGS
+
+Please report any bugs or feature requests to C<bug-www-vdm at
+rt.cpan.org>, or through the web interface at
+L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-VieDeMerde>. I will
+be notified, and then you'll automatically be notified of progress on
+your bug as I make changes.
+
+
+
+
+=head1 SUPPORT
+
+You can find documentation for this module with the perldoc command.
+
+    perldoc WWW::VieDeMerde
+
+
+You can also look for information at:
+
+=over 4
+
+=item * RT: CPAN's request tracker
+
+L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-VieDeMerde>
+
+=item * AnnoCPAN: Annotated CPAN documentation
+
+L<http://annocpan.org/dist/WWW-VieDeMerde>
+
+=item * CPAN Ratings
+
+L<http://cpanratings.perl.org/d/WWW-VieDeMerde>
+
+=item * Search CPAN
+
+L<http://search.cpan.org/dist/WWW-VieDeMerde>
+
+=back
+
+
+=head1 ACKNOWLEDGEMENTS
+
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2008 Olivier Schwander, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+
+=cut
+
+1; # End of WWW::VieDeMerde
hunk ./MANIFEST 17
+t/errors.t
addfile ./t/errors.t
hunk ./t/errors.t 1
+#!perl -T
+
+use Test::More;
+use WWW::VieDeMerde;
+
+BEGIN { my $plan = 0; }
+plan tests => $plan;
+
+BEGIN { $plan += 3; }
+my @xml = <DATA>;
+my $xml = join("\n", @xml);
+
+my $fml = WWW::VieDeMerde->new();
+my $code = $fml->_errors($xml);
+my @errors = @{$fml->errors()};
+is($code, 1, 'Good error code');
+is($errors[0], 'Invalid API key', 'First error found');
+is($errors[1], 'Variable language is missing', 'Second error found');
+
+__DATA__
+<?xml version="1.0" encoding="UTF-8"?>
+<root><active_key>readonly</active_key><code>0</code><pubdate>2009-08-30T15:21:49+02:00</pubdate><language/><errors><error>Invalid API key</error><error>Variable language is missing</error></errors></root>
hunk ./lib/WWW/VieDeMerde.pm 490
-Extract errors. Not implemented.
+Read/write accessor for errors.
hunk ./lib/WWW/VieDeMerde.pm 11
-use WWW::VieDeMerde::Comment;
hunk ./lib/WWW/VieDeMerde.pm 34
-    my $tata = $toto->get(1234);
hunk ./lib/WWW/VieDeMerde.pm 174
-    my $xml = $self->_run('view', $id, 'nocomment');
+    my $xml = $self->_run('view', $id);
+
hunk ./lib/WWW/VieDeMerde.pm 183
-=head2 comments
-
-C<< $vdm->comments($id) >> returns the comments of the item $id.
-
-=cut
-
-sub comments {
-    my $self = shift;
-    my $id = shift;
-    my $t = $self->{twig};
-
-    my $xml = $self->_run('view', $id);
-    if (defined($xml)) {
-        my @l = WWW::VieDeMerde::Comment->parse($t);
-        return @l;
-    }
-    return undef;
-}
-
hunk ./lib/WWW/VieDeMerde/Comment.pm 1
-package WWW::VieDeMerde::Comment;
-
-use warnings;
-use strict;
-use Carp;
-
-use XML::Twig;
-
-=encoding utf8
-
-=head1 NAME
-
-WWW::VieDeMerde::Comment - A message from VieDeMerde.fr
-
-=head1 VERSION
-
-Version 0.1
-
-=cut
-
-our $VERSION = '0.1';
-
-=head1 SYNOPSIS
-
-    use WWW::VieDeMerde;
-    
-    my $toto = WWW::VieDeMerde->new();
-    my @c = $toto->comments(1664);
-    foreach @c {
-       print $_->text, $_->author;
-    }
-
-=head1 DESCRIPTION
-
-You should first read the documentation L<WWW::VieDeMerde> !
-
-A WWW::VieDeMerde::Comment object describes a fmylife or viedemerde comment. You probably do not need to create yourself such object, L<WWW::VieDeMerde> manage it.
-
-The following accessors are useful:
-
-=over 4
-
-=item * id
-
-=item * author
-
-=item * date
-
-=item * text
-
-=back
-
-=head1 METHODS
-
-=head2 new
-
-Create a new WWW::VieDeMerde::Comment given a vdm node the xml response to a query.
-
-=cut
-
-sub new {
-    my $class = shift;
-    my $t     = shift;
-
-    my $self = {};
-    bless($self, $class);
-
-    $self->{id} = $t->att('id');
-    foreach ($t->children()) {
-        my $tag = $_->tag;
-        $self->{$tag} = $_->text;
-    }
-
-    return $self;
-}
-
-
-=head2 parse
-
-Take an xml tree and return a list of WWW::VieDeMerde::Comment.
-qu'il contient.
-
-=cut
-
-#'
-
-sub parse {
-    my $class = shift;
-    my $t     = shift;
-
-    my $root = $t->root;
-    my $vdms = $root->first_child('comments');
-
-    my @vdm = $vdms->children('comment');
-
-    my @result = ();
-
-    foreach (@vdm) {
-        my $m = WWW::VieDeMerde::Comment->new($_);
-        push @result, $m;
-    }
-
-    return @result;
-}
-
-# read-only accessors
-for my $attr (qw(id author date text )) {
-    no strict 'refs';
-    *{"WWW::VieDeMerde::Comment::$attr"} = sub { $_[0]{$attr} }
-}
-
-=head1 AUTHOR
-
-Olivier Schwander, C<< <olivier.schwander at ens-lyon.org> >>
-
-=head1 BUGS
-
-Please report any bugs or feature requests to C<bug-www-vdm at
-rt.cpan.org>, or through the web interface at
-L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-VieDeMerde>. I will
-be notified, and then you'll automatically be notified of progress on
-your bug as I make changes.
-
-
-
-
-=head1 SUPPORT
-
-You can find documentation for this module with the perldoc command.
-
-    perldoc WWW::VieDeMerde
-
-
-You can also look for information at:
-
-=over 4
-
-=item * RT: CPAN's request tracker
-
-L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-VieDeMerde>
-
-=item * AnnoCPAN: Annotated CPAN documentation
-
-L<http://annocpan.org/dist/WWW-VieDeMerde>
-
-=item * CPAN Ratings
-
-L<http://cpanratings.perl.org/d/WWW-VieDeMerde>
-
-=item * Search CPAN
-
-L<http://search.cpan.org/dist/WWW-VieDeMerde>
-
-=back
-
-
-=head1 ACKNOWLEDGEMENTS
-
-
-=head1 COPYRIGHT & LICENSE
-
-Copyright 2008 Olivier Schwander, all rights reserved.
-
-This program is free software; you can redistribute it and/or modify it
-under the same terms as Perl itself.
-
-
-=cut
-
-1; # End of WWW::VieDeMerde
rmfile ./lib/WWW/VieDeMerde/Comment.pm
hunk ./lib/WWW/VieDeMerde.pm 11
+use WWW::VieDeMerde::Comment;
hunk ./lib/WWW/VieDeMerde.pm 35
+    my $tata = $toto->get(1234);
hunk ./lib/WWW/VieDeMerde.pm 176
-    my $xml = $self->_run('view', $id);
-
+    my $xml = $self->_run('view', $id, 'nocomment');
hunk ./lib/WWW/VieDeMerde.pm 184
+=head2 comments
+
+C<< $vdm->comments($id) >> returns the comments of the item $id.
+
+=cut
+
+sub comments {
+    my $self = shift;
+    my $id = shift;
+    my $t = $self->{twig};
+
+    my $xml = $self->_run('view', $id);
+    if (defined($xml)) {
+        my @l = WWW::VieDeMerde::Comment->parse($t);
+        return @l;
+    }
+    return undef;
+}
+
+
addfile ./lib/WWW/VieDeMerde/Comment.pm
hunk ./lib/WWW/VieDeMerde/Comment.pm 1
+package WWW::VieDeMerde::Comment;
+
+use warnings;
+use strict;
+use Carp;
+
+use XML::Twig;
+
+=encoding utf8
+
+=head1 NAME
+
+WWW::VieDeMerde::Comment - A message from VieDeMerde.fr
+
+=head1 VERSION
+
+Version 0.1
+
+=cut
+
+our $VERSION = '0.1';
+
+=head1 SYNOPSIS
+
+    use WWW::VieDeMerde;
+    
+    my $toto = WWW::VieDeMerde->new();
+    my @c = $toto->comments(1664);
+    foreach @c {
+       print $_->text, $_->author;
+    }
+
+=head1 DESCRIPTION
+
+You should first read the documentation L<WWW::VieDeMerde> !
+
+A WWW::VieDeMerde::Comment object describes a fmylife or viedemerde comment. You probably do not need to create yourself such object, L<WWW::VieDeMerde> manage it.
+
+The following accessors are useful:
+
+=over 4
+
+=item * id
+
+=item * author
+
+=item * date
+
+=item * text
+
+=back
+
+=head1 METHODS
+
+=head2 new
+
+Create a new WWW::VieDeMerde::Comment given a vdm node the xml response to a query.
+
+=cut
+
+sub new {
+    my $class = shift;
+    my $t     = shift;
+
+    my $self = {};
+    bless($self, $class);
+
+    $self->{id} = $t->att('id');
+    foreach ($t->children()) {
+        my $tag = $_->tag;
+        $self->{$tag} = $_->text;
+    }
+
+    return $self;
+}
+
+
+=head2 parse
+
+Take an xml tree and return a list of WWW::VieDeMerde::Comment.
+qu'il contient.
+
+=cut
+
+#'
+
+sub parse {
+    my $class = shift;
+    my $t     = shift;
+
+    my $root = $t->root;
+    my $vdms = $root->first_child('comments');
+
+    my @vdm = $vdms->children('comment');
+
+    my @result = ();
+
+    foreach (@vdm) {
+        my $m = WWW::VieDeMerde::Comment->new($_);
+        push @result, $m;
+    }
+
+    return @result;
+}
+
+# read-only accessors
+for my $attr (qw(id author date text )) {
+    no strict 'refs';
+    *{"WWW::VieDeMerde::Comment::$attr"} = sub { $_[0]{$attr} }
+}
+
+=head1 AUTHOR
+
+Olivier Schwander, C<< <olivier.schwander at ens-lyon.org> >>
+
+=head1 BUGS
+
+Please report any bugs or feature requests to C<bug-www-vdm at
+rt.cpan.org>, or through the web interface at
+L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-VieDeMerde>. I will
+be notified, and then you'll automatically be notified of progress on
+your bug as I make changes.
+
+
+
+
+=head1 SUPPORT
+
+You can find documentation for this module with the perldoc command.
+
+    perldoc WWW::VieDeMerde
+
+
+You can also look for information at:
+
+=over 4
+
+=item * RT: CPAN's request tracker
+
+L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-VieDeMerde>
+
+=item * AnnoCPAN: Annotated CPAN documentation
+
+L<http://annocpan.org/dist/WWW-VieDeMerde>
+
+=item * CPAN Ratings
+
+L<http://cpanratings.perl.org/d/WWW-VieDeMerde>
+
+=item * Search CPAN
+
+L<http://search.cpan.org/dist/WWW-VieDeMerde>
+
+=back
+
+
+=head1 ACKNOWLEDGEMENTS
+
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2008 Olivier Schwander, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+
+=cut
+
+1; # End of WWW::VieDeMerde
hunk ./lib/WWW/VieDeMerde/Comment.pm 17
-Version 0.1
+Version 0.2
hunk ./lib/WWW/VieDeMerde/Comment.pm 21
-our $VERSION = '0.1';
+our $VERSION = '0.2';
hunk ./Changes 3
+0.21  Sun Aug 30 21:49 2009
+      Support comments
+		Error management
+
hunk ./lib/WWW/VieDeMerde.pm 21
-Version 0.031
+Version 0.21
hunk ./lib/WWW/VieDeMerde.pm 25
-our $VERSION = '0.031';
+our $VERSION = '0.21';
hunk ./lib/WWW/VieDeMerde/Comment.pm 17
-Version 0.2
+Version 0.21
hunk ./lib/WWW/VieDeMerde/Comment.pm 21
-our $VERSION = '0.2';
+our $VERSION = '0.21';
hunk ./lib/WWW/VieDeMerde/Message.pm 17
-Version 0.031
+Version 0.21
hunk ./lib/WWW/VieDeMerde/Message.pm 21
-our $VERSION = '0.031';
+our $VERSION = '0.21';
