File Coverage

blib/lib/Geo/Address/Mail/US.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 28 28 100.0


line stmt bran cond sub pod time code
1             package Geo::Address::Mail::US;
2 3     3   91002 use warnings;
  3         8  
  3         1203  
3 3     3   19 use strict;
  3         6  
  3         106  
4 3     3   2878 use Moose;
  3         1366158  
  3         29  
5 3     3   48910 use MooseX::Storage;
  3         124337  
  3         29  
6             with qw(MooseX::Storage::Deferred);
7              
8 3     3   1645 use Moose::Util::TypeConstraints;
  3         6  
  3         41  
9 3     3   12526 use Regexp::Common qw(zip);
  3         9882  
  3         86  
10              
11             extends 'Geo::Address::Mail';
12              
13             subtype 'Geo::Address::Mail::USPostalCode',
14             => as 'Str',
15             => where { $_ =~ /^$RE{zip}{US}$/ };
16              
17             has '+postal_code' => (
18             isa => 'Geo::Address::Mail::USPostalCode'
19             );
20              
21             has 'street2' => (
22             is => 'rw',
23             isa => 'Str'
24             );
25              
26             has 'state' => (
27             is => 'rw',
28             isa => 'Str'
29             );
30              
31             __PACKAGE__->meta->make_immutable;
32 3     3   13574 no Moose;
  3         7  
  3         35  
33             1;
34              
35             =head1 NAME
36              
37             Geo::Address::Mail::US - A Mailing Address in the United States
38              
39             =head1 SYNOPSIS
40              
41             Geo::Address::Mail::US is a subclass of L<Geo::Address::Mail> that provides
42             specific validation and attributes for mailing addresses located in the United
43             States.
44              
45             use Geo::Address::Mail::US;
46              
47             my $add = Geo::Address::Mail::US->new(
48             name => 'Cory G Watson',
49             street => '123 Main St',
50             street2 => 'Apt 3B',
51             city => 'Testville',
52             postal_code => '12345'
53             );
54              
55             =head1 ATTRIBUTES
56              
57             Geo::Address::Mail::US has all the attributes of L<Geo::Address::Mail>. The
58             following attributes are either modified or new.
59              
60             =head2 postal_code
61              
62             Postal codes are validated to conform to the USPS ZIP (and optional +4)
63             standard.
64              
65             =head2 street2
66              
67             Addresses in the United States often have an Apartment number, Suite number
68             or other sub-street unit. This field provides for that.
69              
70             =head2 state
71              
72             The state for this address. Added in US as not all countries have the
73             concept of a state.
74              
75             =head1 AUTHOR
76              
77             Cory G Watson, C<< <gphat at cpan.org> >>
78              
79             =head1 ACKNOWLEDGEMENTS
80              
81             =head1 COPYRIGHT & LICENSE
82              
83             Copyright 2010 Cory G Watson.
84              
85             This program is free software; you can redistribute it and/or modify it
86             under the terms of either: the GNU General Public License as published
87             by the Free Software Foundation; or the Artistic License.
88              
89             See http://dev.perl.org/licenses/ for more information.
90              
91             =cut