CLI/L10N/nl.pm

filter: Statementstmt 100% 40 / 40 Branchbran 100% 24 / 24 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 100% 73 / 73 CC 13 SCAR 17.7
CC
13
Cov
100%
singularize
9.0
numerate
5.0
BEGIN
1.0
CRAP 5.8
« CLI/Argument.pm ↑ Summary CLI/Role/CommandSet.pm »
1 #=============================================================================
2 #
3 # Module: Term::CLI::L10N::nl
4 # Author: Steven Bakker (SBAKKER), <sbakker@cpan.org>
5 # Created: 27/02/18
6 #
7 # Copyright (c) 2018 Steven Bakker; All rights reserved.
8 #
9 # This module is free software; you can redistribute it and/or modify
10 # it under the same terms as Perl itself. See "perldoc perlartistic."
11 #
12 # This software is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 #
16 #=============================================================================
17  
18 1 ▶use 5.014_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 package Term::CLI::L10N::nl;
21  
22 1 our $VERSION = 0.051003;
23  
24 1 ▶use Modern::Perl 1.20140107;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 1 ▶use parent 0.228 qw( Term::CLI::L10N );
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 1 ▶use Locale::Maketext::Lexicon::Gettext 1.00;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 1 our %Lexicon = %{ Locale::Maketext::Lexicon::Gettext->parse(<DATA>) };
31 1 close DATA;
32  
33 # $str = $lh->singularize($num, $plural);
34 # $str = $lh->singularise($num, $plural);
35 1 ▶use subs 1.00 qw( singularise );
Subroutine BEGIN: called CC=1 SCAR=0.0
36 1 *singularise = \&singularize;
37  
38 sub singularize {
39 37 ▶ my $self = shift;
Subroutine singularize: called CC=9 SCAR=22.0
Pod documented
40  
41 37 local($_) = shift;
42  
43 # -zen, -ven -> -s, -f
44 37 ▶ s/zen$/s/ and return $_;
Branch: 1 branch
BranchTrueFalseTotal
s/zen$/s/u and return $_ 1 36 37
45 36 ▶ s/ven$/f/ and return $_;
Branch: 1 branch
BranchTrueFalseTotal
s/ven$/f/u and return $_ 1 35 36
46  
47 # -eu?en, -ei?en
48 35 ▶ s/(eu|ei)([^aeiou])en$/$1$2/ and return $_;
Branch: 1 branch
BranchTrueFalseTotal
s/(eu|ei)([^aeiou])en$/$1$2/u and return $_ 1 34 35
49
50 # gelegenheden -> gelegenheid
51 34 ▶ s/heden$/heid/ and return $_;
Branch: 1 branch
BranchTrueFalseTotal
s/heden$/heid/u and return $_ 1 33 34
52  
53 # musea -> museum
54 # aquaria -> aquarium
55 33 ▶ s/([ei])a$/$1um/ and return $_;
Branch: 1 branch
BranchTrueFalseTotal
s/([ei])a$/$1um/u and return $_ 3 30 33
56  
57 # rijen -> rij
58 30 ▶ s/ijen$/ij/ and return $_;
Branch: 1 branch
BranchTrueFalseTotal
s/ijen$/ij/u and return $_ 1 29 30
59  
60 # leraren -> leraar
61 29 ▶ s/([aeiou])([^aeiou])en$/$1$1$2/ and return $_;
Branch: 1 branch
BranchTrueFalseTotal
s/([aeiou])([^aeiou])en$/$1$1$2/u and return $_ 4 25 29
62
63 # ballen -> bal
64 25 ▶ s/([^aeiou])\1en$/$1/ and return $_;
Branch: 1 branch
BranchTrueFalseTotal
s/([^aeiou])\1en$/$1/u and return $_ 1 24 25
65  
66 # schermen -> scherm
67 # auto's -> auto
68 # lepels -> lepel
69 24 return s/(?:'?en|'s|s)$//r;
70 }
71  
72  
73 # $str = $lh->numerate($num, $plural [, $singular ]);
74 #
75 # NOTE: this reverses the semantics of the
76 # plural/singular forms, because it's easier
77 # to go from plural to singular in Dutch.
78 #
79 sub numerate {
80 150 ▶ my ($handle, $num, @forms) = @_;
Subroutine numerate: called CC=5 SCAR=16.1
Pod documented
81  
82 150 my $is_plural = ($num != 1);
83  
84 150 ▶ return '' unless @forms;
Branch: 1 branch
BranchTrueFalseTotal
unless @forms 2 148 150
85 148 ▶ if (@forms == 1) { # only plural specified
Branch: 1 branch
BranchTrueFalseTotal
if (@forms == 1) { } 74 74 148
86 74 my $word = $forms[0];
87 74 ▶ if ($is_plural) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_plural) 37 37 74
88 37 return $word;
89 }
90 37 return $handle->singularize($word);
91 }
92 else { # Both plural and singular are supplied
93 74 ▶ return $is_plural ? $forms[0] : $forms[1];
Branch: 1 branch
BranchTrueFalseTotal
$is_plural ? : 37 37 74
94 }
95 }
96  
97 1 1;
98  
99 __DATA__
« CLI/Argument.pm ↑ Summary CLI/Role/CommandSet.pm »