Language/Fast.pm

filter: Statementstmt 97.5% 39 / 40 Branchbran 90.0% 9 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 15 / 15 Podpod n/a totaltotal 96.9% 63 / 65 CC 5 SCAR 3.5
CC
5
Cov
96%
__ANON__
2.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.4
« Language.pm ↑ Summary
1 package MooseX::Types::Locale::Language::Fast;
2  
3  
4 # ****************************************************************
5 # general dependency(-ies)
6 # ****************************************************************
7  
8 1 ▶use 5.008_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 # MooseX::Types turns strict/warnings pragmas on,
10 # however, kwalitee scorer can not detect such mechanism.
11 # (Perl::Critic can it, with equivalent_modules parameter)
12 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use Locale::Language;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use MooseX::Types::Moose qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
17 Str
18 1 );
19 1 ▶use MooseX::Types (
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 -declare => [qw(
21 LanguageCode
22 Alpha2Language
23 BibliographicLanguage
24 Alpha3Language
25 TerminologicLanguage
26 LanguageName
27 )],
28 1 );
29  
30  
31 # ****************************************************************
32 # namespace clearer
33 # ****************************************************************
34  
35 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37  
38 # ****************************************************************
39 # public class variable(s)
40 # ****************************************************************
41  
42 1 our $VERSION = "0.07";
43  
44  
45 # ****************************************************************
46 # subtype(s) and coercion(s)
47 # ****************************************************************
48  
49 # ----------------------------------------------------------------
50 # language code as defined in ISO 639-1
51 # ----------------------------------------------------------------
52 1 foreach my $subtype (LanguageCode, Alpha2Language) {
53 subtype $subtype,
54 as Str,
55 6 ▶ where {
Subroutine __ANON__: called CC=1 SCAR=0.0
56 6 code2language($_);
57 },
58 4 ▶ message {
Subroutine __ANON__: called CC=2 SCAR=6.9
59 4 ▶ sprintf 'Validation failed for code failed with value (%s) '
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 2 2 4
60 .'because specified language code does not exist '
61 . 'in ISO 639-1',
62 defined $_ ? $_ : q{};
63 2 };
64 }
65  
66 # ----------------------------------------------------------------
67 # language code as defined in ISO 639-2 (alpha-3 bibliographic)
68 # ----------------------------------------------------------------
69 1 foreach my $subtype (Alpha3Language, BibliographicLanguage) {
70 subtype $subtype,
71 as Str,
72 6 ▶ where {
Subroutine __ANON__: called CC=1 SCAR=0.0
73 6 code2language($_, LOCALE_LANG_ALPHA_3);
74 },
75 4 ▶ message {
Subroutine __ANON__: called CC=2 SCAR=6.9
76 4 ▶ sprintf 'Validation failed for code failed with value (%s) '
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 2 2 4
77 . 'because specified language code does not exist '
78 . 'in ISO 639-2 (bibliographic)',
79 defined $_ ? $_ : q{};
80 2 };
81 }
82  
83 # ----------------------------------------------------------------
84 # language code as defined in ISO 639-2 (alpha-3 terminologic)
85 # ----------------------------------------------------------------
86 subtype TerminologicLanguage,
87 as Str,
88 3 ▶ where {
Subroutine __ANON__: called CC=1 SCAR=0.0
89 3 code2language($_, LOCALE_LANG_TERM);
90 },
91 2 ▶ message {
Subroutine __ANON__: called CC=2 SCAR=6.9
92 2 ▶ sprintf 'Validation failed for code failed with value (%s) '
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 1 1 2
93 . 'because specified language code does not exist '
94 . 'in ISO 639-2 (terminology)',
95 defined $_ ? $_ : q{};
96 1 };
97  
98 # ----------------------------------------------------------------
99 # language name as defined in ISO 639
100 # ----------------------------------------------------------------
101 subtype LanguageName,
102 as Str,
103 3 ▶ where {
Subroutine __ANON__: called CC=1 SCAR=0.0
104 3 language2code($_);
105 },
106 2 ▶ message {
Subroutine __ANON__: called CC=2 SCAR=6.9
107 2 ▶ sprintf 'Validation failed for name failed with value (%s) '
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 1 1 2
108 . 'because specified language name does not exist '
109 . 'in ISO 639',
110 defined $_ ? $_ : q{};
111 1 };
112  
113  
114 # ****************************************************************
115 # optionally add Getopt option type
116 # ****************************************************************
117  
118 1 eval { require MooseX::Getopt; };
119 1 ▶if (!$@) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($@) 0 1 1
120 MooseX::Getopt::OptionTypeMap->add_option_type_to_map( $_, '=s', )
121 0 for (LanguageCode, Alpha2Language, LanguageName);
122 }
123  
124  
125 # ****************************************************************
126 # return true
127 # ****************************************************************
128  
129 1 1;
130 __END__
« Language.pm ↑ Summary