Contact/Language/EN.pm

filter: Statementstmt 73.2% 41 / 56 Branchbran 78.5% 11 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 62.5% 10 / 16 Podpod 100% 11 / 11 totaltotal 75.2% 73 / 97 CC 3 SCAR 5.3
CC
3
Cov
74%
_middle
3.2
female_given_name
2.0
female_middle_name
2.0
CRAP 1.7
« Contact.pm ↑ Summary Contact/Country/US.pm »
1 package Data::Random::Contact::Language::EN;
2 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 $Data::Random::Contact::Language::EN::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 %Names;
11 my @Words;
12  
13 {
14 1 my $array;
15  
16 1 ▶ while (<DATA>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline DATA)) 101150 1 101151
17 101150 ▶ next unless /\S/;
Branch: 1 branch
BranchTrueFalseTotal
unless /\S/ 3 101147 101150
18  
19 101147 ▶ if (/__([^_]+)(?:_([^_]+))?__/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/__([^_]+)(?:_([^_]+))?__/) { } 4 101143 101147
20 4 ▶ if ( $1 eq 'names' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($1 eq 'names') { } 3 1 4
21 3 $array = $Names{$2} = [];
22 }
23 else {
24 1 $array = \@Words;
25 }
26 }
27 else {
28 101143 ▶ die "No array yet!" unless defined $array;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $array 0 101143 101143
29  
30 101143 chomp;
31  
32 101143 push @{$array}, $_;
33 }
34 }
35 }
36  
37 2 ▶sub male_given_name {
Subroutine male_given_name: called CC=1 SCAR=0.0
Pod documented
38 2 return $Names{male}[ int( rand( scalar @{ $Names{male} } ) ) ];
39 }
40  
41 0 ▶sub female_given_name {
Subroutine female_given_name: not called CC=1 SCAR=6.9
Pod documented
42 0 return $Names{female}[ int( rand( scalar @{ $Names{female} } ) ) ];
43 }
44  
45 1 ▶sub male_middle_name {
Subroutine male_middle_name: called CC=1 SCAR=0.0
Pod documented
46 1 my $self = shift;
47  
48 1 return $self->_middle( $self->male_given_name() );
49 }
50  
51 0 ▶sub female_middle_name {
Subroutine female_middle_name: not called CC=1 SCAR=6.9
Pod documented
52 0 my $self = shift;
53  
54 0 return $self->_middle( $self->female_given_name() );
55 }
56  
57 1 ▶sub _middle {
Subroutine _middle: called CC=3 SCAR=11.8
58 1 my $self = shift;
59 1 my $name = shift;
60  
61 1 my $middle_p = Data::Random::Contact::_percent();
62  
63 1 ▶ if ( $middle_p <= 25 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($middle_p <= 25) { } 0 1 1
elsif ($middle_p <= 75) { } 1 0 1
64 0 return $name;
65 }
66 elsif ( $middle_p <= 75 ) {
67 1 return substr( $name, 0, 1 );
68 }
69 }
70  
71 1 my @MaleSalutations = qw( Dr Mr );
72  
73 1 ▶sub male_salutation {
Subroutine male_salutation: called CC=1 SCAR=0.0
Pod documented
74 1 return $MaleSalutations[ int( rand( scalar @MaleSalutations ) ) ];
75 }
76  
77 1 my @FemaleSalutations = qw( Dr Ms Miss Mrs );
78  
79 0 ▶sub female_salutation {
Subroutine female_salutation: not called CC=1 SCAR=6.9
Pod documented
80 0 return $FemaleSalutations[ int( rand( scalar @FemaleSalutations ) ) ];
81 }
82  
83 1 my @MaleSuffixes = qw( Jr II III IV );
84  
85 1 ▶sub male_suffix {
Subroutine male_suffix: called CC=1 SCAR=0.0
Pod documented
86 1 return $MaleSuffixes[ int( rand( scalar @MaleSuffixes ) ) ];
87 }
88  
89 0 ▶sub female_suffix {return}
Subroutine female_suffix: not called CC=1 SCAR=6.9
Pod documented
90  
91 1 ▶sub surname {
Subroutine surname: called CC=1 SCAR=0.0
Pod documented
92 1 return $Names{surname}[ int( rand( @{ $Names{surname} } ) ) ];
93 }
94  
95 1 my @HouseholdNames = (
96 'The %s Home',
97 'The %s House',
98 'The %s Household',
99 'The %ss',
100 '%s House',
101 '%s Household',
102 );
103  
104 0 ▶sub household_name {
Subroutine household_name: not called CC=1 SCAR=6.9
Pod documented
105 0 my $surname = surname();
106 0 my $pattern = $HouseholdNames[ int( rand(@HouseholdNames) ) ];
107  
108 0 my $name = sprintf( $pattern, $surname );
109 0 $name =~ s/ss$/ses/;
110  
111 0 return $name;
112 }
113  
114 0 ▶sub organization_name {
Subroutine organization_name: not called CC=1 SCAR=6.9
Pod documented
115 0 my $num = ( int( rand(4) ) ) + 1;
116  
117 0 return join q{ }, map { $Words[ int( rand(@Words) ) ] } 1 .. $num;
118 }
119  
120 1 1;
121  
122 # ABSTRACT: English language contact data
123  
124  
125 # Name data comes from data generated by Fake Name Generator -
126 # http://www.fakenamegenerator.com
127 #
128 # The data is dual-licensed under GPLv3 _or_ CC BY-SA 3.0 (United Stated). See
129 # http://www.fakenamegenerator.com/license.php for licensing details.
130  
131  
132  
133 =pod
134  
135 =head1 NAME
136  
137 Data::Random::Contact::Language::EN - English language contact data
138  
139 =head1 VERSION
140  
141 version 0.05
142  
143 =head1 DESCRIPTION
144  
145 This module provides English language name data.
146  
147 =head1 METHODS
148  
149 This module provides the following methods:
150  
151 =head2 $en->male_given_name()
152  
153 Returns a random male given name.
154  
155 =head2 $en->female_given_name()
156  
157 Returns a random female given name.
158  
159 =head2 $en->male_middle_name()
160  
161 Returns a random male middle name. This will either be a full name or an
162 initial.
163  
164 =head2 $en->female_middle_name()
165  
166 Returns a random female middle name. This will either be a full name or an
167 initial.
168  
169 =head2 $en->male_salutation()
170  
171 Returns an appropriate salutation for a man, like "Dr" or "Mr".
172  
173 =head2 $en->female_salutation()
174  
175 Returns an appropriate salutation for a man, like "Dr", "Ms", or "Mrs".
176  
177 =head2 $en->male_suffix()
178  
179 Returns an appropriate suffix for a man, like "Jr" or "III".
180  
181 =head2 $en->female_suffix()
182  
183 This always returns C<undef>.
184  
185 =head2 $en->surname()
186  
187 Returns a random surname.
188  
189 =head2 $en->household_name()
190  
191 This returns something like "The Smith Home" or "The Abads". The name always
192 incorporates an English surname.
193  
194 =head2 $en->organization_name()
195  
196 This returns a random name based on English dictionary words. It will consist
197 of 1-4 random words separated by a single space.
198  
199 =head1 AUTHOR
200  
201 Dave Rolsky <autarch@urth.org>
202  
203 =head1 COPYRIGHT AND LICENSE
204  
205 This software is Copyright (c) 2011 by Dave Rolsky.
206  
207 This is free software, licensed under:
208  
209 The Artistic License 2.0 (GPL Compatible)
210  
211 =cut
212  
213  
214 __DATA__
« Contact.pm ↑ Summary Contact/Country/US.pm »