Changeset 995

Show
Ignore:
Timestamp:
01/30/04 17:52:28
Author:
miyagawa
Message:

0.03: quick hack for '-foo@example.com'

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Email-Valid-Loose/trunk/Changes

    r424 r995  
    11Revision history for Perl extension Email::Valid::Loose. 
    22 
    3 0.02 
     30.03  Fri Jan 30 17:50:39 JST 2004 
     4        * Now allows '-foo@example.com' due to quick hack 
     5          (Thanks to Takefumi Kimura) 
     6 
     70.02  Tue Jan  8 01:12:00 JST 2002 
    48        - Added dependency on Email::Valid in Makefile.PL 
    59        - Added Changes file 
  • Email-Valid-Loose/trunk/MANIFEST

    r424 r995  
    66t/00_compile.t 
    77t/01_loose.t 
     8META.yml                                 Module meta-data (added by MakeMaker) 
  • Email-Valid-Loose/trunk/lib/Email/Valid/Loose.pm

    r424 r995  
    33use strict; 
    44use vars qw($VERSION); 
    5 $VERSION = '0.02'; 
     5$VERSION = '0.03'; 
    66 
    77use Email::Valid (); 
     
    4545} 
    4646 
     47# XXX hack _rearrange to allowi '-foobar@example.com' 
     48 
     49my $Keys_Re = join '|', keys %Email::Valid::AUTOLOAD; 
     50 
     51sub _rearrange { 
     52    my $self = shift; 
     53    my(@names)  = @{ shift() }; 
     54    my(@params) = @{ shift() }; 
     55    my(%args); 
     56 
     57    ref $self ? %args = %$self : Email::Valid::_initialize( \%args ); 
     58    return %args unless @params; 
     59 
     60    unless ($params[0] =~ /^-(?:$Keys_Re)$/) { 
     61        while(@params) { 
     62            Carp::croak('unexpected number of parameters') unless @names; 
     63            $args{ lc shift @names } = shift @params; 
     64        } 
     65        return %args; 
     66    } 
     67 
     68    while(@params) { 
     69        my $param = lc substr(shift @params, 1); 
     70        $args{ $param } = shift @params; 
     71    } 
     72 
     73    %args; 
     74} 
     75 
    47761; 
    4877__END__ 
  • Email-Valid-Loose/trunk/t/01_loose.t

    r424 r995  
    11use strict; 
    2 use Test::More tests => 6
     2use Test::More
    33 
    44use Email::Valid::Loose; 
     
    77    'miyagawa@cpan.org', 
    88    'rfc822.@docomo.ne.jp', 
     9    '-aaaa@foobar.ezweb.ne.jp', 
    910); 
    1011 
     
    1617); 
    1718 
     19plan tests => (@valid + @invalid); 
     20 
    1821for (@valid) { 
    19     ok( Email::Valid::Loose->address($_) ); 
     22    ok( Email::Valid::Loose->address($_), $_ ); 
    2023} 
    2124 
    2225for (@invalid) { 
    23     ok( !Email::Valid::Loose->address($_) ); 
     26    ok( !Email::Valid::Loose->address($_), $_ ); 
    2427} 
    2528