File Coverage

blib/lib/Locale/Codes/Country/FR.pm
Criterion Covered Total %
statement 33 33 100.0
branch 9 10 90.0
condition 1 3 33.3
subroutine 7 7 100.0
pod 3 3 100.0
total 53 56 94.6


line stmt bran cond sub pod time code
1             package Locale::Codes::Country::FR;
2              
3 2     2   198081 use warnings;
  2         11  
  2         55  
4 2     2   10 use strict;
  2         4  
  2         31  
5              
6 2     2   734 use Data::Section::Simple;
  2         967  
  2         73  
7 2     2   746 use Locale::Codes::Country;
  2         69585  
  2         859  
8              
9             our @ISA = ('Locale::Codes::Country');
10              
11             =head1 NAME
12              
13             Locale::Codes::Country::FR - French countries
14              
15             =head1 VERSION
16              
17             Version 0.01
18              
19             =cut
20              
21             our $VERSION = '0.01';
22              
23             =head1 SYNOPSIS
24              
25             A sub-class of L which adds country names in French and
26             genders of the countries.
27              
28             =head1 SUBROUTINES/METHODS
29              
30             =head2 new
31              
32             Creates a Locale::Codes::Country::FR object.
33             =cut
34              
35             sub new {
36 3     3 1 41 my $proto = shift;
37 3   33     12 my $class = ref($proto) || $proto;
38              
39 3 50       7 return unless(defined($class));
40              
41 3         12 return bless { }, $class;
42             }
43              
44             =head2 en_country2gender
45              
46             Take a country (in English) and return 'M' and 'F'.
47             Can be used in OO or procedural mode.
48              
49             =cut
50              
51             sub en_country2gender {
52 4     4 1 11 my $arg = shift;
53            
54 4 100       12 if(ref($arg) ne __PACKAGE__) {
55 1         4 return __PACKAGE__->new()->en_country2gender($arg);
56             }
57              
58 3         6 my $country = $arg->country2fr(shift);
59              
60             # FIXME: Exceptions e.g. Mexico
61 3 100       10 if($country =~ /e$/) {
62 2         10 return 'F';
63             }
64 1         4 return 'M';
65             }
66              
67             =head2 country2fr
68              
69             Given a country in English, translate into French.
70             Can be used in OO or procedural mode.
71              
72             =cut
73              
74             sub country2fr {
75 6     6 1 453 my $arg = shift;
76            
77 6 100       14 if(ref($arg) ne __PACKAGE__) {
78 1         8 return __PACKAGE__->new()->country2fr($arg);
79             }
80              
81 5         9 my $english = shift;
82              
83 5         14 my $data = Data::Section::Simple::get_data_section('countries');
84              
85 5         788 my @line = split /\n/, $data;
86              
87 5         12 for (@line) {
88 14         27 my($en, $fr) = split /:/;
89 14 100       31 if($en eq $english) {
90 5         25 return $fr;
91             }
92             }
93             }
94              
95             =head1 AUTHOR
96              
97             Nigel Horne, C<< >>
98              
99             =head1 BUGS
100              
101             Lots of countries to be done. This initial release is a POC.
102              
103             Gender exceptions aren't handled.
104              
105             Please report any bugs or feature requests to C,
106             or through the web interface at
107             L.
108             I will be notified, and then you'll
109             automatically be notified of progress on your bug as I make changes.
110              
111             params() returns a ref which means that calling routines can change the hash
112             for other routines.
113             Take a local copy before making amendments to the table if you don't want unexpected
114             things to happen.
115              
116             =head1 SEE ALSO
117              
118             L
119              
120             =head1 SUPPORT
121              
122             You can find documentation for this module with the perldoc command.
123              
124             perldoc Locale::Codes::Country::FR
125              
126             You can also look for information at:
127              
128             =over 4
129              
130             =item * RT: CPAN's request tracker
131              
132             L
133              
134             =item * CPAN Ratings
135              
136             L
137              
138             =item * Search CPAN
139              
140             L
141              
142             =back
143              
144             =head1 LICENSE AND COPYRIGHT
145              
146             Copyright 2019 Nigel Horne.
147              
148             This program is released under the following licence: GPL2
149              
150             =cut
151              
152             1;
153             __DATA__