Contact/Country/US.pm

filter: Statementstmt 100% 31 / 31 Branchbran 91.6% 11 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 98.0% 50 / 51 CC 1 SCAR 0.0
CC
1
Cov
98%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Contact/Language/EN.pm ↑ Summary Contact/Types.pm »
1 package Data::Random::Contact::Country::US;
2 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 $Data::Random::Contact::Country::US::VERSION = '0.05';
4 }
5  
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 my ( @AreaCodes, @Addresses );
11  
12 {
13 1 my $array;
14 my $eval;
15  
16 1 ▶ while (<DATA>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline DATA)) 9741 1 9742
17 9741 ▶ next unless /\S/;
Branch: 1 branch
BranchTrueFalseTotal
unless /\S/ 1 9740 9741
18  
19 9740 ▶ if (/__area_code__/) {
Branch: 2 branches
BranchTrueFalseTotal
if (/__area_code__/) { } 1 9739 9740
elsif (/__address__/) { } 1 9738 9739
20 1 $array = \@AreaCodes;
21 }
22 elsif (/__address__/) {
23 1 $array = \@Addresses;
24 1 $eval = 1;
25 }
26 else {
27 9738 ▶ die "No array yet!" unless $array;
Branch: 1 branch
BranchTrueFalseTotal
unless $array 0 9738 9738
28  
29 9738 chomp;
30 9738 ▶ push @{$array}, $eval ? eval $_ : $_;
Branch: 1 branch
BranchTrueFalseTotal
$eval ? : 9444 294 9738
31 }
32 }
33 }
34  
35 3 ▶sub phone_number {
Subroutine phone_number: called CC=1 SCAR=0.0
Pod documented
36 3 my $area_code = $AreaCodes[ int( rand( scalar @AreaCodes ) )];
37  
38 # 200 - 999
39 3 my $prefix = ( int( rand( 800 ) ) + 200 );
40 3 my $suffix = sprintf( '%04d', rand( 10000 ) );
41  
42 3 return join '-', $area_code, $prefix, $suffix;
43 }
44  
45 2 ▶sub address {
Subroutine address: called CC=1 SCAR=0.0
Pod documented
46 2 my $address = $Addresses[ int( rand( scalar @Addresses ) ) ];
47 2 return { %{ $address} };
48 }
49  
50 1 1;
51  
52 # ABSTRACT: US phone number and address data
53  
54  
55 # Address data comes VegGuide.org
56 #
57 # The data is licensed under CC BY-NC-SA 3.0 (United Stated).
58  
59  
60 =pod
61  
62 =head1 NAME
63  
64 Data::Random::Contact::Country::US - US phone number and address data
65  
66 =head1 VERSION
67  
68 version 0.05
69  
70 =head1 DESCRIPTION
71  
72 This module provides US country phone and address data.
73  
74 =head1 METHODS
75  
76 This module provides the following methods:
77  
78 =head2 $country->phone_number()
79  
80 This returns a phone number like "212-555-1234". The area codes are all valid
81 US area codes. The number prefix will be a random number from 200 to 999.
82  
83 =head2 $country->address()
84  
85 This returns a hash reference with the following keys:
86  
87 =over 4
88  
89 =item * street_1
90  
91 The first line of the street address.
92  
93 =item * street_2
94  
95 The second line of the street address. This is usually C<undef>.
96  
97 =item * city
98  
99 The address's city.
100  
101 =item * region
102  
103 The address's state.
104  
105 =item * postal_code
106  
107 The address's zip code.
108  
109 =back
110  
111 Note that any address component can be C<undef>.
112  
113 =head1 AUTHOR
114  
115 Dave Rolsky <autarch@urth.org>
116  
117 =head1 COPYRIGHT AND LICENSE
118  
119 This software is Copyright (c) 2011 by Dave Rolsky.
120  
121 This is free software, licensed under:
122  
123 The Artistic License 2.0 (GPL Compatible)
124  
125 =cut
126  
127  
128 __DATA__
« Contact/Language/EN.pm ↑ Summary Contact/Types.pm »