[perl-www-contact commit] r39 - in trunk: . lib/WWW lib/WWW/Contact lib/WWW/Contact/CN t

0 views
Skip to first unread message

codesite...@google.com

unread,
Oct 28, 2008, 12:24:28 PM10/28/08
to perl-www...@googlegroups.com
Author: sachinjsk
Date: Tue Oct 28 09:22:54 2008
New Revision: 39

Added:
trunk/lib/WWW/Contact/Lycos.pm (contents, props changed)
trunk/t/109-lycos.t (contents, props changed)
Modified:
trunk/Changes
trunk/lib/WWW/Contact.pm
trunk/lib/WWW/Contact/AOL.pm
trunk/lib/WWW/Contact/Base.pm
trunk/lib/WWW/Contact/CN/163.pm
trunk/lib/WWW/Contact/Gmail.pm
trunk/lib/WWW/Contact/Hotmail.pm
trunk/lib/WWW/Contact/Indiatimes.pm
trunk/lib/WWW/Contact/Mail.pm
trunk/lib/WWW/Contact/Rediffmail.pm
trunk/lib/WWW/Contact/Yahoo.pm

Log:
Added contact import option from Lycos, and also preparation for 0.14
release

Modified: trunk/Changes
==============================================================================
--- trunk/Changes (original)
+++ trunk/Changes Tue Oct 28 09:22:54 2008
@@ -1,4 +1,7 @@
Revision history for WWW-Contact
+0.14 2008.10.28
+ added WWW::Contact::Lycos by Sachin Sebastian
+
0.13 2008.10.28
added WWW::Contact::Indiatimes by Sachin Sebastian
remove google.com check and wrong password check from test files.

Modified: trunk/lib/WWW/Contact.pm
==============================================================================
--- trunk/lib/WWW/Contact.pm (original)
+++ trunk/lib/WWW/Contact.pm Tue Oct 28 09:22:54 2008
@@ -4,7 +4,7 @@
use Moose;
use Moose::Util::TypeConstraints;

-our $VERSION = '0.13';
+our $VERSION = '0.14';
our $AUTHORITY = 'cpan:FAYLAND';

has 'errstr' => ( is => 'rw', isa => 'Maybe[Str]' );
@@ -26,6 +26,7 @@
'rediffmail.com' => 'Rediffmail',
'aol.com' => 'AOL',
'indiatimes.com' => 'Indiatimes',
+ 'lycos.com' => 'Lycos',

# cn
'163.com' => 'CN::163',
@@ -48,18 +49,18 @@
'writeme.com' => 'Mail',

# hotmail
- 'hotmail.com' => 'Hotmail',
- 'live.com' => 'Hotmail',
- 'compaq.net' => 'Hotmail',
- 'hotmail.co.jp' => 'Hotmail',
- 'hotmail.co.uk' => 'Hotmail',
- 'hotmail.de' => 'Hotmail',
- 'hotmail.fr' => 'Hotmail',
- 'hotmail.it' => 'Hotmail',
+ 'hotmail.com' => 'Hotmail',
+ 'live.com' => 'Hotmail',
+ 'compaq.net' => 'Hotmail',
+ 'hotmail.co.jp' => 'Hotmail',
+ 'hotmail.co.uk' => 'Hotmail',
+ 'hotmail.de' => 'Hotmail',
+ 'hotmail.fr' => 'Hotmail',
+ 'hotmail.it' => 'Hotmail',
'messengeruser.com' => 'Hotmail',
- 'msn.com' => 'Hotmail',
- 'passport.com' => 'Hotmail',
- 'webtv.net' => 'Hotmail',
+ 'msn.com' => 'Hotmail',
+ 'passport.com' => 'Hotmail',
+ 'webtv.net' => 'Hotmail',
}
}
);
@@ -204,6 +205,10 @@
=item Indiatimes

L<WWW::Contact::Indiatimes> By Sachin Sebastian
+
+=item Lycos
+
+L<WWW::Contact::Lycos> By Sachin Sebastian

=back


Modified: trunk/lib/WWW/Contact/AOL.pm
==============================================================================
--- trunk/lib/WWW/Contact/AOL.pm (original)
+++ trunk/lib/WWW/Contact/AOL.pm Tue Oct 28 09:22:54 2008
@@ -3,7 +3,7 @@
use Moose;
extends 'WWW::Contact::Base';

-our $VERSION = '0.13';
+our $VERSION = '0.14';
our $AUTHORITY = 'cpan:FAYLAND';

sub get_contacts {

Modified: trunk/lib/WWW/Contact/Base.pm
==============================================================================
--- trunk/lib/WWW/Contact/Base.pm (original)
+++ trunk/lib/WWW/Contact/Base.pm Tue Oct 28 09:22:54 2008
@@ -5,7 +5,7 @@
use Carp qw/croak/;
use Data::Dumper;

-our $VERSION = '0.13';
+our $VERSION = '0.14';
our $AUTHORITY = 'cpan:FAYLAND';

my $sub_verbose = sub {

Modified: trunk/lib/WWW/Contact/CN/163.pm
==============================================================================
--- trunk/lib/WWW/Contact/CN/163.pm (original)
+++ trunk/lib/WWW/Contact/CN/163.pm Tue Oct 28 09:22:54 2008
@@ -3,7 +3,7 @@
use Moose;
extends 'WWW::Contact::Base';

-our $VERSION = '0.13';
+our $VERSION = '0.14';
our $AUTHORITY = 'cpan:FAYLAND';

sub get_contacts {

Modified: trunk/lib/WWW/Contact/Gmail.pm
==============================================================================
--- trunk/lib/WWW/Contact/Gmail.pm (original)
+++ trunk/lib/WWW/Contact/Gmail.pm Tue Oct 28 09:22:54 2008
@@ -3,7 +3,7 @@
use Moose;
extends 'WWW::Contact::Base';

-our $VERSION = '0.13';
+our $VERSION = '0.14';
our $AUTHORITY = 'cpan:FAYLAND';

use HTML::TokeParser::Simple;

Modified: trunk/lib/WWW/Contact/Hotmail.pm
==============================================================================
--- trunk/lib/WWW/Contact/Hotmail.pm (original)
+++ trunk/lib/WWW/Contact/Hotmail.pm Tue Oct 28 09:22:54 2008
@@ -6,7 +6,7 @@
use HTTP::Request::Common qw/POST/;
use HTML::TokeParser::Simple;

-our $VERSION = '0.13';
+our $VERSION = '0.14';
our $AUTHORITY = 'cpan:FAYLAND';

sub get_contacts {

Modified: trunk/lib/WWW/Contact/Indiatimes.pm
==============================================================================
--- trunk/lib/WWW/Contact/Indiatimes.pm (original)
+++ trunk/lib/WWW/Contact/Indiatimes.pm Tue Oct 28 09:22:54 2008
@@ -3,7 +3,7 @@
use Moose;
extends 'WWW::Contact::Base';

-our $VERSION = '0.01';
+our $VERSION = '0.14';
our $AUTHORITY = 'cpan:SACHINJSK';

has '+ua_class' => ( default => 'WWW::Mechanize::GZip' );

Added: trunk/lib/WWW/Contact/Lycos.pm
==============================================================================
--- (empty file)
+++ trunk/lib/WWW/Contact/Lycos.pm Tue Oct 28 09:22:54 2008
@@ -0,0 +1,113 @@
+package WWW::Contact::Lycos;
+
+use Moose;
+extends 'WWW::Contact::Base';
+
+our $VERSION = '0.01';
+our $AUTHORITY = 'cpan:SACHINJSK';
+
+has '+ua_class' => ( default => 'WWW::Mechanize::GZip' );
+
+sub get_contacts {
+ my ($self, $email, $password) = @_;
+
+ # reset errstr
+ $self->errstr(undef);
+ my @contacts;
+
+ my $ua = $self->ua;
+ $self->debug("start get_contacts from lycos");
+
+ # Get username from email.
+ $email =~ /(.*)@.*/;
+ my $username = $1;
+
+ # get to login form
+ $self->get('http://www.lycos.com/') || return;
+
+ $self->submit_form(
+ form_number => 2,
+ fields => {
+ m_U => $username,
+ m_P => $password,
+ },
+ ) || return;
+
+ my $content = $ua->content();
+ if ($content =~ /password you provided don't match/ig) {
+ $self->errstr('Wrong Username or Password');
+ return;
+ }
+
+ $self->debug('Login OK');
+
+
$self->get("http://mail.lycos.com/lycos/addrbook/ExportAddr.lycos?ptype=act&fileType=OUTLOOK");
+
+ my $address_content = $ua->content();
+
+ @contacts = get_contacts_from_csv($address_content);
+ return wantarray ? @contacts : \@contacts;
+}
+
+sub get_contacts_from_csv {
+ my ($csv) = shift;
+ my @contacts;
+
+ # first_name, last_name, full_name, nickname, e-mail.
+ my @lines = split(/\n/, $csv);
+ shift @lines; # skip the first line
+ foreach my $line (@lines) {
+ $line =~ s/"//g;
+ my @cols = split(',', $line);
+ push @contacts, {
+ name => $cols[0].' '.$cols[2],
+ email => $cols[4]
+ };
+ }
+
+ return wantarray ? @contacts : \@contacts;
+}
+
+no Moose;
+__PACKAGE__->meta->make_immutable;
+
+1;
+__END__
+
+=head1 NAME
+
+WWW::Contact::Lycos - Get contacts from Lycos
+
+=head1 SYNOPSIS
+
+ use WWW::Contact;
+
+ my $wc = WWW::Contact->new();
+ my @contacts = $wc->get_contacts('it...@lycos.com', 'password');
+ my $errstr = $wc->errstr;
+ if ($errstr) {
+ die $errstr;
+ } else {
+ print Dumper(\@contacts);
+ }
+
+=head1 DESCRIPTION
+
+get contacts from Lycos. extends L<WWW::Contact::Base>
+
+=head1 SEE ALSO
+
+L<WWW::Contact>, L<WWW::Contact::Base>, L<WWW::Mechanize::GZip>
+
+=head1 AUTHOR
+
+Sachin Sebastian, C<< <sachinjsk at cpan.org> >>
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2008 Sachin Sebastian, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut

Modified: trunk/lib/WWW/Contact/Mail.pm
==============================================================================
--- trunk/lib/WWW/Contact/Mail.pm (original)
+++ trunk/lib/WWW/Contact/Mail.pm Tue Oct 28 09:22:54 2008
@@ -3,7 +3,7 @@
use Moose;
extends 'WWW::Contact::Base';

-our $VERSION = '0.13';
+our $VERSION = '0.14';
our $AUTHORITY = 'cpan:SACHINJSK';

has '+ua_class' => ( default => 'WWW::Mechanize::GZip' );

Modified: trunk/lib/WWW/Contact/Rediffmail.pm
==============================================================================
--- trunk/lib/WWW/Contact/Rediffmail.pm (original)
+++ trunk/lib/WWW/Contact/Rediffmail.pm Tue Oct 28 09:22:54 2008
@@ -3,7 +3,7 @@
use Moose;
extends 'WWW::Contact::Base';

-our $VERSION = '0.13';
+our $VERSION = '0.14';
our $AUTHORITY = 'cpan:SACHINJSK';

has '+ua_class' => ( default => 'WWW::Mechanize::GZip' );

Modified: trunk/lib/WWW/Contact/Yahoo.pm
==============================================================================
--- trunk/lib/WWW/Contact/Yahoo.pm (original)
+++ trunk/lib/WWW/Contact/Yahoo.pm Tue Oct 28 09:22:54 2008
@@ -3,7 +3,7 @@
use Moose;
extends 'WWW::Contact::Base';

-our $VERSION = '0.13';
+our $VERSION = '0.14';
our $AUTHORITY = 'cpan:FAYLAND';

has '+ua_class' => ( default => 'WWW::Mechanize::GZip' );

Added: trunk/t/109-lycos.t
==============================================================================
--- (empty file)
+++ trunk/t/109-lycos.t Tue Oct 28 09:22:54 2008
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use FindBin qw/$Bin/;
+use lib "$Bin/lib";
+use Test::More;
+use WWW::Contact::Lycos;
+use Data::Dumper;
+
+BEGIN {
+ unless ( $ENV{TEST_LYCOS} and $ENV{TEST_LYCOS_PASS} ) {
+ plan skip_all => 'set $ENV{TEST_LYCOS} and $ENV{TEST_LYCOS_PASS}
to test';
+ }
+ plan tests => 4;
+}
+
+my $wc = new WWW::Contact::Lycos->new();
+
+my @contacts = $wc->get_contacts('cp...@lycos.com', 'letmein');
+my $errstr = $wc->errstr;
+is($errstr, 'Wrong Username or Password', 'get error with wrong password');
+is(scalar @contacts, 0, 'empty contact list');
+
+{
+ @contacts = $wc->get_contacts($ENV{TEST_LYCOS}, $ENV{TEST_LYCOS_PASS});
+ $errstr = $wc->errstr;
+ is($errstr, undef, 'no error with username or password');
+ cmp_ok(scalar @contacts, '>', 0, 'got contact list');
+ diag(Dumper(\@contacts));
+}
+1;

Reply all
Reply to author
Forward
0 new messages