Conjunction.pm

filter: Statementstmt 63.4% 26 / 41 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 64.2% 9 / 14 Podpod 22.2% 2 / 9 totaltotal 59.0% 39 / 66 CC 2 SCAR 3.4
CC
2
Cov
65%
conjunction
2.0
connector_type
1.8
lang
1.8
CRAP 1.4
↑ Summary ._Conjunction.pm »
1 package Template::Plugin::Lingua::Conjunction;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use base 'Template::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Lingua::Conjunction ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION = '0.02';
11  
12 # This plugin is a singleton with no state at all, so...
13 1 ▶sub load {
Subroutine load: called CC=1 SCAR=0.0
Pod documented
14 1 my($pkg, $context) = @_;
15 1 bless \$pkg, $pkg;
16 }
17  
18 3 ▶sub new { shift }
Subroutine new: called CC=1 SCAR=0.0
Pod documented
19  
20 3 ▶sub conjunction {
Subroutine conjunction: called CC=2 SCAR=6.9
Pod undocumented
21 3 my $me = shift;
22
23 # Flatten any arrays in the parameters
24 3 ▶ @_ = map { ref $_ ? @$_ : $_ } @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 1 4 5
25
26 # And call
27 3 goto &Lingua::Conjunction::conjunction;
28 }
29  
30 # Shorter alias
31 2 ▶sub list { goto &conjunction }
Subroutine list: called CC=1 SCAR=0.0
Pod undocumented
32  
33 1 for(qw(lang separator separator_phrase connector_type penultimate)) {
34 0 ▶ eval qq{
Subroutine connector_type: not called CC=1 SCAR=6.0
Subroutine lang: not called CC=1 SCAR=6.0
Subroutine penultimate: not called CC=1 SCAR=6.0
Subroutine separator: not called CC=1 SCAR=6.0
Subroutine separator_phrase: not called CC=1 SCAR=6.0
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
35 sub $_ {
36 shift;
37 unshift \@_, 'Lingua::Conjunction';
38 goto &Lingua::Conjunction::$_;
39 }
40 }
41 }
42  
43 1 1;
44  
45  
46 =head1 NAME
47  
48 Template::Plugin::Lingua::Conjunction - Template Toolkit plugin for human-readable lists
49  
50 =head1 SYNOPSIS
51  
52 [% USE Lingua.Conjunction %]
53 [% Lingua.Conjunction.conjunction("Alice", "Bob", "Charlie") %] have secrets
54 from [% Lingua.Conjunction.list("Eve", "Mallory") %]
55
56 Alice, Bob, and Charlie have secrets from Eve and Mallory.
57  
58 =head1 DESCRIPTION
59  
60 Lingua::Conjunction is a module to create sentence-style, human-readable lists
61 of items from a Perl list. For example, given the list ("foo", "bar", "baz")
62 it would return the string "foo, bar, and baz". If any of the strings in the
63 list had a comma in them, it would switch to using a semicolon. It supports
64 multiple languages and use of arbitrary separator characters. It handles any
65 number of items gracefully, even two or one.
66  
67 Template::Plugin::Lingua::Conjunction is a wrapper around this module so that
68 it can be used from the Template Toolkit.
69  
70 The main method of this plugin is C<conjunction> (or C<list> for short). It
71 takes a list of items or arrays of items which should be converted and returns
72 a human-readable string representation.
73  
74 Template::Plugin::Lingua::Conjunction also supports Lingua::Conjunction's
75 settings methods, namely C<lang>, C<separator>, C<separator_phrase>,
76 C<connector_type>, and C<penultimate>. For documentation on them, see
77 L<Lingua::Conjunction>.
78  
79 =head1 SEE ALSO
80  
81 L<Lingua::Conjunction>, L<Template::Manual>
82  
83 =head1 AUTHOR
84  
85 Brent Royal-Gordon E<lt>brentdax@cpan.orgE<gt>
86  
87 =head1 COPYRIGHT AND LICENSE
88  
89 Copyright (C) 2006 by Brent Royal-Gordon
90  
91 This library is free software; you can redistribute it and/or modify
92 it under the same terms as Perl itself, either Perl version 5.8.7 or,
93 at your option, any later version of Perl 5 you may have available.
94  
95 =cut
↑ Summary ._Conjunction.pm »