blib/lib/Template/Plugin/Lingua/EN/Inflect.pm

filter: Statementstmt 83.5% 71 / 85 Branchbran 50.0% 6 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 84.8% 28 / 33 Podpod 100% 23 / 23 totaltotal 83.6% 128 / 153 CC 7 SCAR 6.3
CC
7
Cov
79%
__ANON__
6.0
__ANON__
6.0
tt_inflect
3.0
CRAP 1.9
↑ Summary
1 package Template::Plugin::Lingua::EN::Inflect;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 7 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 7 $VERSION = 0.04;
8  
9 7 require Template::Plugin;
10 7 ▶use base qw(Template::Plugin);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 7 ▶use Lingua::EN::Inflect qw( inflect );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 10 ▶sub new {
Subroutine new: called CC=2 SCAR=9.4
Pod documented
14 10 my ($class, $context, $options) = @_;
15 10 my $filter_factory;
16 my $plugin;
17  
18 10 ▶ if ($options) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options) { } 0 10 10
19 # create a closure to generate filters with additional options
20 0 ▶ $filter_factory = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
21 0 my $context = shift;
22 0 ▶ my $filtopt = ref $_[-1] eq 'HASH' ? pop : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[-1] eq 'HASH' ? : 0 0 0
23 0 @$filtopt{ keys %$options } = values %$options;
24 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
25 0 tt_inflect(@_, $filtopt);
26 0 };
27 0 };
28  
29 # and a closure to represent the plugin
30 0 ▶ $plugin = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
31 0 ▶ my $plugopt = ref $_[-1] eq 'HASH' ? pop : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[-1] eq 'HASH' ? : 0 0 0
32 0 @$plugopt{ keys %$options } = values %$options;
33 0 tt_inflect(@_, $plugopt);
34 0 };
35 } else {
36 # simple filter factory closure (no legacy options from constructor)
37 7 ▶ $filter_factory = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
38 7 my $context = shift;
39 7 ▶ my $filtopt = ref $_[-1] eq 'HASH' ? pop : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[-1] eq 'HASH' ? : 2 5 7
40 7 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
41 7 tt_inflect(@_, $filtopt);
42 7 };
43 10 };
44  
45 # plugin without options can be static
46 10 $plugin = \&tt_inflect;
47 }
48  
49 # now define the filter and return the plugin
50 10 $context->define_filter('inflect', [ $filter_factory => 1 ]);
51 10 return bless $plugin, $class;
52 }
53  
54 7 ▶sub tt_inflect {
Subroutine tt_inflect: called CC=3 SCAR=11.0
Pod documented
55 7 ▶ my $options = ref $_[-1] eq 'HASH' ? pop : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[-1] eq 'HASH' ? : 7 0 7
56 7 my $number = $options->{ number };
57 7 ▶ Lingua::EN::Inflect::NUM($number) if $number;
Branch: 1 branch
BranchTrueFalseTotal
if $number 2 5 7
58 7 my $out = inflect(join('', @_));
59 7 return $out;
60 }
61  
62 2 ▶sub classical { shift; return Lingua::EN::Inflect::classical(@_); }
Subroutine classical: called CC=1 SCAR=0.0
Pod documented
63 1 ▶sub def_noun { shift; return Lingua::EN::Inflect::def_noun(@_); }
Subroutine def_noun: called CC=1 SCAR=0.0
Pod documented
64 1 ▶sub def_verb { shift; return Lingua::EN::Inflect::def_verb(@_); }
Subroutine def_verb: called CC=1 SCAR=0.0
Pod documented
65 1 ▶sub def_adj { shift; return Lingua::EN::Inflect::def_adj(@_); }
Subroutine def_adj: called CC=1 SCAR=0.0
Pod documented
66 0 ▶sub def_a { shift; return Lingua::EN::Inflect::def_a(@_); }
Subroutine def_a: not called CC=1 SCAR=6.9
Pod documented
67 0 ▶sub def_an { shift; return Lingua::EN::Inflect::def_an(@_); }
Subroutine def_an: not called CC=1 SCAR=6.9
Pod documented
68 4 ▶sub A { shift; return Lingua::EN::Inflect::A(@_); }
Subroutine A: called CC=1 SCAR=0.0
Pod documented
69 2 ▶sub AN { shift; return Lingua::EN::Inflect::AN(@_); }
Subroutine AN: called CC=1 SCAR=0.0
Pod documented
70 12 ▶sub NO { shift; return Lingua::EN::Inflect::NO(@_); }
Subroutine NO: called CC=1 SCAR=0.0
Pod documented
71 2 ▶sub NUM { shift; return Lingua::EN::Inflect::NUM(@_); }
Subroutine NUM: called CC=1 SCAR=0.0
Pod documented
72 8 ▶sub NUMWORDS { shift; return Lingua::EN::Inflect::NUMWORDS(@_); }
Subroutine NUMWORDS: called CC=1 SCAR=0.0
Pod documented
73 8 ▶sub ORD { return Lingua::EN::Inflect::ORD($_[1]); }
Subroutine ORD: called CC=1 SCAR=0.0
Pod documented
74 1 ▶sub PART_PRES { shift; return Lingua::EN::Inflect::PART_PRES(@_); }
Subroutine PART_PRES: called CC=1 SCAR=0.0
Pod documented
75 8 ▶sub PL { shift; return Lingua::EN::Inflect::PL(@_); }
Subroutine PL: called CC=1 SCAR=0.0
Pod documented
76 2 ▶sub PL_N { shift; return Lingua::EN::Inflect::PL_N(@_); }
Subroutine PL_N: called CC=1 SCAR=0.0
Pod documented
77 2 ▶sub PL_V { shift; return Lingua::EN::Inflect::PL_V(@_); }
Subroutine PL_V: called CC=1 SCAR=0.0
Pod documented
78 2 ▶sub PL_ADJ { shift; return Lingua::EN::Inflect::PL_ADJ(@_); }
Subroutine PL_ADJ: called CC=1 SCAR=0.0
Pod documented
79 1 ▶sub PL_eq { shift; return Lingua::EN::Inflect::PL_eq(@_); }
Subroutine PL_eq: called CC=1 SCAR=0.0
Pod documented
80 2 ▶sub PL_N_eq { shift; return Lingua::EN::Inflect::PL_N_eq(@_); }
Subroutine PL_N_eq: called CC=1 SCAR=0.0
Pod documented
81 2 ▶sub PL_V_eq { shift; return Lingua::EN::Inflect::PL_V_eq(@_); }
Subroutine PL_V_eq: called CC=1 SCAR=0.0
Pod documented
82 2 ▶sub PL_ADJ_eq { shift; return Lingua::EN::Inflect::PL_ADJ_eq(@_); }
Subroutine PL_ADJ_eq: called CC=1 SCAR=0.0
Pod documented
83  
84 7 1;
85  
86 __END__
↑ Summary