r71360 - in /branches/upstream/libmoosex-types-netaddr-ip-perl: ./ current/ current/lib/ current/lib/MooseX/ current/lib/MooseX/Types/ current/lib/MooseX/Types/NetAddr/ current/t/

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Sun Mar 13 21:36:26 UTC 2011


Author: jawnsy-guest
Date: Sun Mar 13 21:36:13 2011
New Revision: 71360

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=71360
Log:
[svn-inject] Installing original source of libmoosex-types-netaddr-ip-perl (0.04)

Added:
    branches/upstream/libmoosex-types-netaddr-ip-perl/
    branches/upstream/libmoosex-types-netaddr-ip-perl/current/
    branches/upstream/libmoosex-types-netaddr-ip-perl/current/Changes
    branches/upstream/libmoosex-types-netaddr-ip-perl/current/MANIFEST
    branches/upstream/libmoosex-types-netaddr-ip-perl/current/META.yml
    branches/upstream/libmoosex-types-netaddr-ip-perl/current/Makefile.PL
    branches/upstream/libmoosex-types-netaddr-ip-perl/current/lib/
    branches/upstream/libmoosex-types-netaddr-ip-perl/current/lib/MooseX/
    branches/upstream/libmoosex-types-netaddr-ip-perl/current/lib/MooseX/Types/
    branches/upstream/libmoosex-types-netaddr-ip-perl/current/lib/MooseX/Types/NetAddr/
    branches/upstream/libmoosex-types-netaddr-ip-perl/current/lib/MooseX/Types/NetAddr/IP.pm
    branches/upstream/libmoosex-types-netaddr-ip-perl/current/t/
    branches/upstream/libmoosex-types-netaddr-ip-perl/current/t/MooseX-Types-NetAddr-IP.t

Added: branches/upstream/libmoosex-types-netaddr-ip-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-types-netaddr-ip-perl/current/Changes?rev=71360&op=file
==============================================================================
--- branches/upstream/libmoosex-types-netaddr-ip-perl/current/Changes (added)
+++ branches/upstream/libmoosex-types-netaddr-ip-perl/current/Changes Sun Mar 13 21:36:13 2011
@@ -1,0 +1,12 @@
+Revision history for Perl extension MooseX::Types::NetAddr::IP.
+
+0.04
+    - fixed some typos in the pod
+    - added tests for NetAddrIPv4/6 ArrayRef coercions
+0.03
+    - refactoring
+0.02  
+    - removed regexp validation
+0.01 
+    - original version; created by h2xs 1.23 
+

Added: branches/upstream/libmoosex-types-netaddr-ip-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-types-netaddr-ip-perl/current/MANIFEST?rev=71360&op=file
==============================================================================
--- branches/upstream/libmoosex-types-netaddr-ip-perl/current/MANIFEST (added)
+++ branches/upstream/libmoosex-types-netaddr-ip-perl/current/MANIFEST Sun Mar 13 21:36:13 2011
@@ -1,0 +1,6 @@
+Changes
+Makefile.PL
+MANIFEST
+t/MooseX-Types-NetAddr-IP.t
+lib/MooseX/Types/NetAddr/IP.pm
+META.yml                                 Module meta-data (added by MakeMaker)

Added: branches/upstream/libmoosex-types-netaddr-ip-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-types-netaddr-ip-perl/current/META.yml?rev=71360&op=file
==============================================================================
--- branches/upstream/libmoosex-types-netaddr-ip-perl/current/META.yml (added)
+++ branches/upstream/libmoosex-types-netaddr-ip-perl/current/META.yml Sun Mar 13 21:36:13 2011
@@ -1,0 +1,26 @@
+--- #YAML:1.0
+name:               MooseX-Types-NetAddr-IP
+version:            0.04
+abstract:           NetAddr::IP related types and coercions for Moose
+author:
+    - Todd Caine <todd.caine at gmail.com>
+license:            perl
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+build_requires:
+    ExtUtils::MakeMaker:  0
+requires:
+    Moose:             0.41
+    MooseX::Types:     0.19
+    namespace::clean:  0.08
+    NetAddr::IP:       0
+    Test::Exception:   0
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.55_02
+meta-spec:
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4

Added: branches/upstream/libmoosex-types-netaddr-ip-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-types-netaddr-ip-perl/current/Makefile.PL?rev=71360&op=file
==============================================================================
--- branches/upstream/libmoosex-types-netaddr-ip-perl/current/Makefile.PL (added)
+++ branches/upstream/libmoosex-types-netaddr-ip-perl/current/Makefile.PL Sun Mar 13 21:36:13 2011
@@ -1,0 +1,22 @@
+
+use strict;
+use warnings;
+
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+    NAME          => 'MooseX::Types::NetAddr::IP',
+    AUTHOR        => 'Todd Caine <todd.caine at gmail.com>',
+    LICENSE       => 'perl',
+    VERSION_FROM  => 'lib/MooseX/Types/NetAddr/IP.pm',
+    ABSTRACT_FROM => 'lib/MooseX/Types/NetAddr/IP.pm',
+    INSTALLDIRS   => 'site',
+    PREREQ_PM     => {
+        'Moose'                 => '0.41',
+        'MooseX::Types'         => '0.19',
+        'namespace::clean'      => '0.08',
+        'NetAddr::IP'           => 0,
+        'Test::Exception'       => 0,
+    },
+);
+

Added: branches/upstream/libmoosex-types-netaddr-ip-perl/current/lib/MooseX/Types/NetAddr/IP.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-types-netaddr-ip-perl/current/lib/MooseX/Types/NetAddr/IP.pm?rev=71360&op=file
==============================================================================
--- branches/upstream/libmoosex-types-netaddr-ip-perl/current/lib/MooseX/Types/NetAddr/IP.pm (added)
+++ branches/upstream/libmoosex-types-netaddr-ip-perl/current/lib/MooseX/Types/NetAddr/IP.pm Sun Mar 13 21:36:13 2011
@@ -1,0 +1,106 @@
+package MooseX::Types::NetAddr::IP;
+
+use strict;
+use warnings;
+
+our $VERSION = '0.04';
+
+use NetAddr::IP ();
+use MooseX::Types::Moose qw/Str ArrayRef/;
+use namespace::clean;
+use MooseX::Types -declare => [qw( NetAddrIP NetAddrIPv4 NetAddrIPv6 )];
+
+class_type 'NetAddr::IP';
+
+subtype NetAddrIP,   as 'NetAddr::IP';  # can be either IPv4 or IPv6
+subtype NetAddrIPv4, as 'NetAddr::IP';  # can be only IPv4
+subtype NetAddrIPv6, as 'NetAddr::IP';  # can be only IPv6
+
+coerce NetAddrIP, 
+    from Str, 
+    via { 
+        return NetAddr::IP->new( $_ ) 
+            or die "'$_' is not an IP address.\n";
+    };
+
+coerce NetAddrIP, 
+    from ArrayRef[Str], 
+    via { 
+        return NetAddr::IP->new( @$_ ) 
+            or die "'@$_' is not an IP address.\n";
+    };
+
+sub createAddress ($@) {
+    my $version = shift;
+
+    my $ipaddr = NetAddr::IP->new( @_ )
+        or die "'@_' is not an IPv$version address.\n";
+
+    die "'@_' is not an IPv$version address."
+        unless $ipaddr->version == $version;
+
+    return $ipaddr;
+}
+
+coerce NetAddrIPv4,
+    from Str,
+    via { createAddress 4 => $_ };
+
+coerce NetAddrIPv4,
+    from ArrayRef[Str],
+    via { createAddress 4 => @$_ };
+
+coerce NetAddrIPv6,
+    from Str,
+    via { createAddress 6 => $_ };
+
+coerce NetAddrIPv6,
+    from ArrayRef[Str],
+    via { createAddress 6 => @$_ };
+
+1;
+__END__
+
+=head1 NAME
+
+MooseX::Types::NetAddr::IP - NetAddr::IP related types and coercions for Moose
+
+=head1 SYNOPSIS
+
+  use MooseX::Types::NetAddr::IP qw( NetAddrIP NetAddrIPv4 NetAddrIPv6 );
+
+=head1 DESCRIPTION
+
+This package provides internet address types for Moose.
+
+=head2 TYPES
+
+NetAddrIP
+
+    Coerces from Str and ArrayRef via "new" in NetAddr::IP. 
+
+NetAddrIPv4
+
+    Coerces from Str and ArrayRef via "new" in NetAddr::IP.
+
+NetAddrIPv6
+
+    Coerces from Str and ArrayRef via "new" in NetAddr::IP.
+
+=head1 SEE ALSO
+
+L<NetAddr::IP>
+
+=head1 AUTHOR
+
+Todd Caine, E<lt>todd.caine at gmail.comE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2010 by Todd Caine
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.10.1 or,
+at your option, any later version of Perl 5 you may have available.
+
+=cut

Added: branches/upstream/libmoosex-types-netaddr-ip-perl/current/t/MooseX-Types-NetAddr-IP.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-types-netaddr-ip-perl/current/t/MooseX-Types-NetAddr-IP.t?rev=71360&op=file
==============================================================================
--- branches/upstream/libmoosex-types-netaddr-ip-perl/current/t/MooseX-Types-NetAddr-IP.t (added)
+++ branches/upstream/libmoosex-types-netaddr-ip-perl/current/t/MooseX-Types-NetAddr-IP.t Sun Mar 13 21:36:13 2011
@@ -1,0 +1,94 @@
+
+use strict;
+use warnings;
+
+use Test::More tests => 22;
+use Test::Exception;
+use Moose::Util::TypeConstraints;
+
+use_ok 'MooseX::Types::NetAddr::IP';
+
+isa_ok find_type_constraint('NetAddr::IP') 
+    => 'Moose::Meta::TypeConstraint';
+
+{
+    package NetAddrIPTest;
+    use Moose;
+    use MooseX::Types::NetAddr::IP qw( NetAddrIP );
+    has 'address' => ( is => 'ro', isa => NetAddrIP, coerce => 1 );
+}{
+    my $ip = NetAddrIPTest->new({address => '127.0.0.1/32'})->address;
+    isa_ok $ip, "NetAddr::IP", "coerced from string";
+
+    $ip = NetAddrIPTest->new({address => ['10.0.0.255', '255.0.0.0']})->address;
+    isa_ok $ip, "NetAddr::IP", "coerced from string";
+
+    dies_ok { 
+        NetAddrIPTest->new({address => '343.0.0.1/320'}) 
+    } "invalid IP address";
+}
+
+{
+    package NetAddrIPv4Test;
+    use Moose;
+    use MooseX::Types::NetAddr::IP qw( NetAddrIPv4 );
+
+    has 'address' => ( 
+        is      => 'ro', 
+        isa     => NetAddrIPv4, 
+        coerce  => 1, 
+        handles => [qw/ network broadcast /],
+    );
+}{
+    my $ip = NetAddrIPv4Test->new({address => '127.0.0.1/24'})->address;
+    isa_ok $ip, "NetAddr::IP", "coerced from string";
+    is $ip->network->addr, '127.0.0.0';
+    is $ip->network, '127.0.0.0/24';
+    is $ip->broadcast->addr, '127.0.0.255';
+    is $ip->broadcast, '127.0.0.255/24';
+
+    $ip = NetAddrIPv4Test->new({address => ['10.0.0.255', '255.0.0.0']})->address;
+    isa_ok $ip, "NetAddr::IP", "coerced from string";
+
+    foreach my $invalidIPv4Addr (qw(
+        1080:0:0:0:8:800:200C:417A 
+        43.0.0.1/320
+        10.0.0.256
+    )) {
+        throws_ok { 
+            NetAddrIPv4Test->new({address => $invalidIPv4Addr}); 
+        } qr/'$invalidIPv4Addr' is not an IPv4 address/, "invalid IPv4 address";
+    }
+}
+
+{
+    package NetAddrIPv6Test;
+    use Moose;
+    use MooseX::Types::NetAddr::IP qw( NetAddrIPv6 );
+    has 'address' => ( is => 'ro', isa => NetAddrIPv6, coerce => 1 );
+}{
+    foreach my $ipv6Addr (qw/ 
+        ::
+        ::1
+        0:0:0:0:0:0:0:0
+        1080:0:0:0:8:800:200C:417A 
+        1080::8:800:200C:417A 
+        ::FFFF:192.168.1.1 /) {
+        my $ip = NetAddrIPv6Test->new({address => $ipv6Addr})->address;
+        isa_ok $ip, "NetAddr::IP", "coerced from string";
+    }
+
+    my $ip = NetAddrIPv6Test->new({
+                 address => [
+                     '1080:0:0:0:8:800:200C:417A', 
+                     'FFFF:FFFF:FFFF:FFFF:0000:0000:0000:0000'
+                 ],
+             })->address;
+    isa_ok $ip, "NetAddr::IP", "coerced from string";
+
+    throws_ok { 
+        NetAddrIPv6Test->new({address => '192.168.1.1'}) } 
+            qr/'192.168.1.1' is not an IPv6 address/,
+                'invalid IP address';
+}
+




More information about the Pkg-perl-cvs-commits mailing list