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

filter: Statementstmt 45.8% 39 / 85 Branchbran 50.0% 6 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 36.3% 12 / 33 Podpod 100% 23 / 23 totaltotal 52.2% 80 / 153 CC 7 SCAR 8.3
CC
7
Cov
46%
__ANON__
6.0
__ANON__
6.0
tt_inflect
3.0
CRAP 2.3
↑ Summary
1 package Template::Plugin::Lingua::EN::Inflect;
2  
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 $VERSION = 0.03;
8  
9 6 require Template::Plugin;
10 6 ▶use base qw(Template::Plugin);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 ▶use Lingua::EN::Inflect qw( inflect );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub new {
14 10 ▶ my ($class, $context, $options) = @_;
Subroutine new: called CC=2 SCAR=9.4
Pod documented
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 $filter_factory = sub {
21 0 ▶ my $context = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
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 return sub {
25 0 ▶ tt_inflect(@_, $filtopt);
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 0 };
27 0 };
28  
29 # and a closure to represent the plugin
30 $plugin = sub {
31 0 ▶ my $plugopt = ref $_[-1] eq 'HASH' ? pop : {};
Subroutine __ANON__: not called CC=2 SCAR=17.9
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 $filter_factory = sub {
38 7 ▶ my $context = shift;
Subroutine __ANON__: called CC=2 SCAR=6.9
39 7 ▶ my $filtopt = ref $_[-1] eq 'HASH' ? pop : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[-1] eq 'HASH' ? : 2 5 7
40 return sub {
41 7 ▶ tt_inflect(@_, $filtopt);
Subroutine __ANON__: called CC=1 SCAR=0.0
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 sub tt_inflect {
55 7 ▶ my $options = ref $_[-1] eq 'HASH' ? pop : {};
Subroutine tt_inflect: called CC=3 SCAR=11.0
Pod documented
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 0 ▶sub classical { shift; return Lingua::EN::Inflect::classical(@_); }
Subroutine classical: not called CC=1 SCAR=6.9
Pod documented
63 0 ▶sub def_noun { shift; return Lingua::EN::Inflect::def_noun(@_); }
Subroutine def_noun: not called CC=1 SCAR=6.9
Pod documented
64 0 ▶sub def_verb { shift; return Lingua::EN::Inflect::def_verb(@_); }
Subroutine def_verb: not called CC=1 SCAR=6.9
Pod documented
65 0 ▶sub def_adj { shift; return Lingua::EN::Inflect::def_adj(@_); }
Subroutine def_adj: not called CC=1 SCAR=6.9
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 0 ▶sub A { shift; return Lingua::EN::Inflect::A(@_); }
Subroutine A: not called CC=1 SCAR=6.9
Pod documented
69 0 ▶sub AN { shift; return Lingua::EN::Inflect::AN(@_); }
Subroutine AN: not called CC=1 SCAR=6.9
Pod documented
70 5 ▶sub NO { shift; return Lingua::EN::Inflect::NO(@_); }
Subroutine NO: called CC=1 SCAR=0.0
Pod documented
71 0 ▶sub NUM { shift; return Lingua::EN::Inflect::NUM(@_); }
Subroutine NUM: not called CC=1 SCAR=6.9
Pod documented
72 6 ▶sub NUMWORDS { shift; return Lingua::EN::Inflect::NUMWORDS(@_); }
Subroutine NUMWORDS: called CC=1 SCAR=0.0
Pod documented
73 6 ▶sub ORD { return Lingua::EN::Inflect::ORD($_[1]); }
Subroutine ORD: called CC=1 SCAR=0.0
Pod documented
74 0 ▶sub PART_PRES { shift; return Lingua::EN::Inflect::PART_PRES(@_); }
Subroutine PART_PRES: not called CC=1 SCAR=6.9
Pod documented
75 0 ▶sub PL { shift; return Lingua::EN::Inflect::PL(@_); }
Subroutine PL: not called CC=1 SCAR=6.9
Pod documented
76 0 ▶sub PL_N { shift; return Lingua::EN::Inflect::PL_N(@_); }
Subroutine PL_N: not called CC=1 SCAR=6.9
Pod documented
77 0 ▶sub PL_V { shift; return Lingua::EN::Inflect::PL_V(@_); }
Subroutine PL_V: not called CC=1 SCAR=6.9
Pod documented
78 0 ▶sub PL_ADJ { shift; return Lingua::EN::Inflect::PL_ADJ(@_); }
Subroutine PL_ADJ: not called CC=1 SCAR=6.9
Pod documented
79 0 ▶sub PL_eq { shift; return Lingua::EN::Inflect::PL_eq(@_); }
Subroutine PL_eq: not called CC=1 SCAR=6.9
Pod documented
80 0 ▶sub PL_N_eq { shift; return Lingua::EN::Inflect::PL_N_eq(@_); }
Subroutine PL_N_eq: not called CC=1 SCAR=6.9
Pod documented
81 0 ▶sub PL_V_eq { shift; return Lingua::EN::Inflect::PL_V_eq(@_); }
Subroutine PL_V_eq: not called CC=1 SCAR=6.9
Pod documented
82 0 ▶sub PL_ADJ_eq { shift; return Lingua::EN::Inflect::PL_ADJ_eq(@_); }
Subroutine PL_ADJ_eq: not called CC=1 SCAR=6.9
Pod documented
83  
84 6 1;
85  
86 __END__
↑ Summary