@@ -1,7 +1,16 @@
-Revision history for Perl extension Template::Plugin::Lingua::EN::Inflect
+Revision history for Template-Plugin-Lingua-EN-Inflect
+======================================================
-0.02 Fri Oct 21 08:04:19 BST 2005
- - expanded documentation a bit
+0.03 2014-06-23
+ - new maintainer: BARBIE.
+ - change file dates changed to meet W3CDTF standards.
+ - added LICENSE file.
+ - updated META.yml, added META.json.
+ - reworked Makefile.PL for clarity.
+ - extended test suite.
-0.01 Thu Sep 1 15:38:02 BST 2005
- - original version
+0.02 2005-10-21T08:04:19Z
+ - expanded documentation a bit
+
+0.01 2005-09-01T15:38:02Z
+ - original version
@@ -0,0 +1,7 @@
+LICENSE for Template-Plugin-Lingua-EN-Inflect
+
+Copyright © 2005-2014 Andrew Ford
+Copyright © 2014 Barbie for Miss Barbell Productions.
+
+This distribution is free software; you can redistribute it and/or
+modify it under the Artistic Licence v2.
@@ -1,8 +1,15 @@
Changes
-Makefile.PL
-MANIFEST This list of files
lib/Template/Plugin/Lingua/EN/Inflect.pm
+LICENSE
+Makefile.PL
+MANIFEST
+META.json
+META.yml
README
-t/00_use.t
-t/01_inflect.t
-META.yml Module meta-data (added by MakeMaker)
+t/00use.t
+t/01inflect.t
+t/90podtest.t
+t/91podcover.t
+t/94metatest.t
+t/95changedate.t
+t/96metatest.t
@@ -0,0 +1,66 @@
+{
+ "name": "Template-Plugin-Lingua-EN-Inflect",
+ "version": "0.03",
+ "abstract": "TT2 interface to Lingua::EN::Inflect module",
+ "author": [
+ "Barbie (BARBIE) <barbie@cpan.org>"
+ ],
+
+ "license": "artistic_2",
+ "dynamic_config" : 0,
+ "release_status" : "stable",
+ "meta-spec": {
+ "version": "2",
+ "url": "http://search.cpan.org/dist/CPAN-Meta/lib/CPAN/Meta/Spec.pm"
+ },
+ "generated_by": "Hand 1.0",
+ "keywords" : [
+ "template toolkit",
+ "checksum",
+ "lingua"
+ ],
+
+ "prereqs" : {
+ "runtime" : {
+ "requires" : {
+ "perl": "5.006",
+ "Template": "2.07",
+ "Template::Plugin": "2.07",
+ "Lingua::EN::Inflect": "0"
+ }
+ },
+ "test" : {
+ "requires": {
+ "IO::File": "0",
+ "Template::Test": "0",
+ "Test::More": "0.70"
+ },
+ "recommends": {
+ "Test::CPAN::Meta": "0",
+ "Test::CPAN::Meta::JSON": "0",
+ "Test::Pod": "1.00",
+ "Test::Pod::Coverage": "0.08"
+ }
+ }
+ },
+
+ "provides": {
+ "Template::Plugin::Lingua::EN::Inflect": {
+ "file": "lib/Template/Plugin/Lingua/EN/Inflect.pm",
+ "version": "0.03"
+ }
+ },
+ "no_index": {
+ "directory": ["t","examples"]
+ },
+
+ "resources": {
+ "license": "http://www.perlfoundation.org/artistic_license_2_0",
+ "bugtracker": { "web": "http://rt.cpan.org/Public/Dist/Display.html?Name=Template-Plugin-Lingua-EN-Inflect" },
+ "repository": {
+ "url": "git://github.com/barbie/template-plugin-lingua-en-inflect.git",
+ "web": "http://github.com/barbie/template-plugin-lingua-en-inflect",
+ "type": "git"
+ }
+ }
+}
@@ -1,13 +1,44 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
-name: Template-Plugin-Lingua-EN-Inflect
-version: 0.02
-version_from: lib/Template/Plugin/Lingua/EN/Inflect.pm
-installdirs: site
+--- #YAML:1.0
+name: Template-Plugin-Lingua-EN-Inflect
+version: 0.03
+abstract: TT2 interface to Lingua::EN::Inflect module
+author:
+ - Barbie <barbie@cpan.org>
+
+license: artistic_2
+distribution_type: module
+installdirs: site
+
requires:
- Lingua::EN::Inflect: 0
- Template: 2.07
- Test::More: 0.32
+ perl: 5.006
+ Template: 2.07
+ Template::Plugin: 2.07
+ Lingua::EN::Inflect: 0
+recommends:
+ Test::CPAN::Meta: 0
+ Test::CPAN::Meta::JSON: 0
+ Test::Pod: 1.00
+ Test::Pod::Coverage: 0.08
+build_requires:
+ IO::File: 0
+ Template::Test: 0
+ Test::More: 0.70
+
+provides:
+ Template::Plugin::Lingua::EN::Inflect:
+ file: lib/Template/Plugin/Lingua/EN/Inflect.pm
+ version: 0.03
+no_index:
+ directory:
+ - t
+ - examples
+
+resources:
+ license: http://www.perlfoundation.org/artistic_license_2_0
+ bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=Template-Plugin-Lingua-EN-Inflect
+ repository: http://github.com/barbie/template-plugin-lingua-en-inflect
-distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.30
+meta-spec:
+ version: 1.4
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+generated_by: Hand 1.0
@@ -1,10 +1,28 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use 5.006;
+
use ExtUtils::MakeMaker;
+
WriteMakefile(
- 'NAME' => 'Template::Plugin::Lingua::EN::Inflect',
- 'VERSION_FROM' => 'lib/Template/Plugin/Lingua/EN/Inflect.pm', # finds $VERSION
- 'PREREQ_PM' => {
- 'Test::More' => 0.32,
- 'Template' => 2.07,
- 'Lingua::EN::Inflect' => 0,
+ AUTHOR => 'Barbie <barbie@cpan.org>',
+ NAME => 'Template-Plugin-Lingua::EN::Inflect',
+ VERSION_FROM => 'lib/Template/Plugin/Lingua/EN/Inflect.pm',
+ ABSTRACT => 'TT2 interface to Lingua::EN::Inflect module',
+ NO_META => 1,
+ PREREQ_PM => {
+
+ # prereqs
+ 'Template' => '2.07',
+ 'Template::Plugin' => '2.07',
+ 'Lingua::EN::Inflect' => '0',
+
+ # for testing
+ 'IO::File' => 0,
+ 'Template::Test' => 0,
+ 'Test::More' => 0.70
+
},
);
@@ -1,136 +1,65 @@
-NAME
- Template::Plugin::Lingua::EN::Inflect - Interface to Lingua::EN::Inflect
- module
-
-SYNOPSIS
- [% USE infl = Lingua.EN.Inflect; -%]
- [% FILTER inflect(number => 42); -%]
- There PL_V(was) NO(error).
- PL_ADJ(This) PL_N(error) PL_V(was) fatal.
- [% END; -%]
-
- [% "... and "; infl.ORD(9); "ly..." %]
-
- # Output:
- # There were 42 errors.
- # These errors were fatal.
- # ... and 9thly...
-
-DESCRIPTION
- The Lingua::EN::Inflect is an interface to Damian Conway's
- Linua::EN::Inflect Perl module, which provides plural inflections,
- "a"/"an" selection for English words, and manipulation of numbers as
- words.
-
- The plugin provides an 'inflect' filter, which can be used to
- interpolate inflections in a string. The NUM() function set a persistent
- default value to be used whenever an optional number argument is
- omitted. The number to be used for a particular invocation of 'inflect'
- can also be specified with a 'number' option.
-
- For the full gory details of the inflection functionality refer to the
- Lingua::EN::Inflect manual.
-
-OBJECT METHODS
- "infl.A($string, $opt_number)"
- prepends the appropriate indefinite article to a word, depending on
- its pronunciation. If the second argument is provided and its value
- is numeric and not 1 then the value of the second argument is used
- instead.
-
- e.g. "infl.A("idea")" returns "an idea"
-
- "AN($string, $opt_number)"
- synonym for "A()"
-
- "NO($string, $opt_arg)"
- given a word and an optional count, returns the count followed by
- the correctly inflected word
-
- "NUM($string, $opt_arg)"
- sets a persistent *default number* value, which is subsequently used
- whenever an optional second *number* argument is omitted. The
- default value thus set can subsequently be removed by calling
- "NUM()" with no arguments. "NUM()" normally returns its first
- argument, however if "NUM()" is called with a second argument that
- is defined and evaluates to false then "NUM()" returns an empty
- string.
-
- "NUMWORDS($string, $opt_arg)"
- takes a number (cardinal or ordinal) and returns an English
- represen- tation of that number. In a scalar context a string is
- returned. In a list context each comma-separated chunk is returned
- as a separate element.
-
- "ORD($number)"
- takes a single argument and forms its ordinal equivalent. If the
- argument isn't a numerical integer, it just adds "-th".
-
- "PART_PRES($string, $opt_arg)"
- returns the present participle for a third person singluar verb
-
- PART_PRES("runs"); # returns "running"
-
- "PL($string, $opt_arg)"
- returns the plural of a *singular* English noun, pronoun, verb or
- adjective.
-
- "PL_N($string, $opt_arg)"
- returns the plural of a *singular* English noun or pronoun.
-
- "PL_V($string, $opt_arg)"
- returns the plural conjugation of the *singular* form of a
- conjugated verb.
-
- "PL_ADJ($string, $opt_arg)"
- returns the plural form of a *singular* form of certain types of
- adjectives.
-
- "PL_eq($string, $opt_arg)"
- "PL_N_eq($string, $opt_arg)"
- "PL_V_eq($string, $opt_arg)"
- "PL_ADJ_eq($string, $opt_arg)"
- "classical($string, $opt_arg)"
- "def_noun($string, $opt_arg)"
- "def_verb($string, $opt_arg)"
- "def_adj($string, $opt_arg)"
- "def_a($string, $opt_arg)"
- "def_an($string, $opt_arg)"
-TODO
- Finish off documenting the object methods.
-
- Provide tests for all methods in the test suite.
-
- It would also be nice to have methods that spelled out numbers that were
- less than a certain threshold and that formatted large numbers with
- commas, for example:
-
- inflect("There PL_V(was) NO(error).", number => 0);
- # outputs: "There were no errors."
+Template-Plugin-Lingua-EN-Inflect
+=================================
- inflect("There PL_V(was) NO(error).", number => 1);
- # outputs: "There was one errors."
-
- inflect("There PL_V(was) NO(error).", number => 3);
- # outputs: "There were three errors."
-
- inflect("There PL_V(was) NO(error).", number => 1042);
- # outputs: "There were 1,042 errors."
-
- This would require changes to the Lingua::EN::Inflect module.
-
-AUTHOR
- Andrew Ford <A.Ford@ford-mason.co.uk> wrote the plugin code (basing it
- heavily on the Template::Plugin::Autoformat code).
-
- Damian Conway <damian@conway.org> wrote the Lingua::EN::Inflect module,
- which does all the clever stuff.
+The Lingua::EN::Inflect is an interface to Damian Conway's
+Linua::EN::Inflect Perl module, which provides plural inflections,
+"a"/"an" selection for English words, and manipulation of numbers as words.
-COPYRIGHT
- Copyright (C) 2005 Andrew Ford. All Rights Reserved.
+The plugin provides an 'inflect' filter, which can be used to
+interpolate inflections in a string. The NUM() function sets a
+persistent default value to be used whenever an optional number
+argument is omitted. The number to be used for a particular
+invocation of 'inflect' can also be specified with a 'number' option.
- This library is free software; you can redistribute it and/or modify it
- under the same terms as Perl itself.
+INSTALLATION
-SEE ALSO
- Lingua::EN::Inflect, Template, "Template::Plugin"
+To install this module type the following:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+DEPENDENCIES
+
+This module requires these modules:
+
+ Template
+ Template::Plugin
+ Lingua-EN-Inflect
+
+For testing the module requires these modules:
+
+ IO::File
+ Test::More
+
+For optional testing the module would like these modules:
+
+ Test::CPAN::Meta
+ Test::CPAN::Meta::JSON
+ Test::Pod
+ Test::Pod::Coverage
+
+DEDICATION
+
+This distribution was originally created by Andrew Ford. Sadly in early 2014,
+Andrew was diagnosed with Pancreatic Cancer and passed away peacfully at home
+on 25th April 2014.
+
+One of his wishes was for his OpenSource work to continue. At his funeral, many
+of his colleagues and friends, spoke of how he felt like a person of the world,
+and how he embrace the idea of OpenSource being for the benefit of the world.
+
+Anyone wishing to donate in memory of Andrew, please consider the following
+charities:
+
+* Dignity in Dying - http://www.dignityindying.org.uk/
+* Marie Curie Cancer Care - http://www.mariecurie.org.uk/
+
+COPYRIGHT AND LICENSE
+
+ Copyright (C) 2005-2014 Andrew Ford
+ Copyright (C) 2014 Barbie for Miss Barbell Productions.
+
+This distribution is free software; you can redistribute it and/or
+modify it under the Artistic Licence v2.
@@ -1,8 +1,10 @@
package Template::Plugin::Lingua::EN::Inflect;
use strict;
+use warnings;
+
use vars qw($VERSION);
-$VERSION = 0.02;
+$VERSION = 0.03;
require Template::Plugin;
use base qw(Template::Plugin);
@@ -14,35 +16,34 @@ sub new {
my $plugin;
if ($options) {
- # create a closure to generate filters with additional options
- $filter_factory = sub {
- my $context = shift;
- my $filtopt = ref $_[-1] eq 'HASH' ? pop : { };
- @$filtopt{ keys %$options } = values %$options;
- return sub {
- tt_inflect(@_, $filtopt);
- };
- };
-
- # and a closure to represent the plugin
- $plugin = sub {
- my $plugopt = ref $_[-1] eq 'HASH' ? pop : { };
- @$plugopt{ keys %$options } = values %$options;
- tt_inflect(@_, $plugopt);
- };
- }
- else {
- # simple filter factory closure (no legacy options from constructor)
- $filter_factory = sub {
- my $context = shift;
- my $filtopt = ref $_[-1] eq 'HASH' ? pop : { };
- return sub {
- tt_inflect(@_, $filtopt);
- };
- };
-
- # plugin without options can be static
- $plugin = \&tt_inflect;
+ # create a closure to generate filters with additional options
+ $filter_factory = sub {
+ my $context = shift;
+ my $filtopt = ref $_[-1] eq 'HASH' ? pop : {};
+ @$filtopt{ keys %$options } = values %$options;
+ return sub {
+ tt_inflect(@_, $filtopt);
+ };
+ };
+
+ # and a closure to represent the plugin
+ $plugin = sub {
+ my $plugopt = ref $_[-1] eq 'HASH' ? pop : {};
+ @$plugopt{ keys %$options } = values %$options;
+ tt_inflect(@_, $plugopt);
+ };
+ } else {
+ # simple filter factory closure (no legacy options from constructor)
+ $filter_factory = sub {
+ my $context = shift;
+ my $filtopt = ref $_[-1] eq 'HASH' ? pop : {};
+ return sub {
+ tt_inflect(@_, $filtopt);
+ };
+ };
+
+ # plugin without options can be static
+ $plugin = \&tt_inflect;
}
# now define the filter and return the plugin
@@ -50,16 +51,14 @@ sub new {
return bless $plugin, $class;
}
-
sub tt_inflect {
- my $options = ref $_[-1] eq 'HASH' ? pop : { };
+ my $options = ref $_[-1] eq 'HASH' ? pop : {};
my $number = $options->{ number };
Lingua::EN::Inflect::NUM($number) if $number;
my $out = inflect(join('', @_));
return $out;
}
-
sub classical { shift; return Lingua::EN::Inflect::classical(@_); }
sub def_noun { shift; return Lingua::EN::Inflect::def_noun(@_); }
sub def_verb { shift; return Lingua::EN::Inflect::def_verb(@_); }
@@ -69,7 +68,7 @@ sub def_an { shift; return Lingua::EN::Inflect::def_an(@_); }
sub A { shift; return Lingua::EN::Inflect::A(@_); }
sub AN { shift; return Lingua::EN::Inflect::AN(@_); }
sub NO { shift; return Lingua::EN::Inflect::NO(@_); }
-sub NUM { shift; return Lingua::EN::Inflect::NUM(@_); }
+sub NUM { shift; return Lingua::EN::Inflect::NUM(@_); }
sub NUMWORDS { shift; return Lingua::EN::Inflect::NUMWORDS(@_); }
sub ORD { return Lingua::EN::Inflect::ORD($_[1]); }
sub PART_PRES { shift; return Lingua::EN::Inflect::PART_PRES(@_); }
@@ -82,11 +81,9 @@ sub PL_N_eq { shift; return Lingua::EN::Inflect::PL_N_eq(@_); }
sub PL_V_eq { shift; return Lingua::EN::Inflect::PL_V_eq(@_); }
sub PL_ADJ_eq { shift; return Lingua::EN::Inflect::PL_ADJ_eq(@_); }
-
1;
-__END__
-
+__END__
=head1 NAME
@@ -114,7 +111,7 @@ Linua::EN::Inflect Perl module, which provides plural inflections,
"a"/"an" selection for English words, and manipulation of numbers as words.
The plugin provides an 'inflect' filter, which can be used to
-interpolate inflections in a string. The NUM() function set a
+interpolate inflections in a string. The NUM() function sets a
persistent default value to be used whenever an optional number
argument is omitted. The number to be used for a particular
invocation of 'inflect' can also be specified with a 'number' option.
@@ -122,11 +119,8 @@ invocation of 'inflect' can also be specified with a 'number' option.
For the full gory details of the inflection functionality refer to the
L<Lingua::EN::Inflect> manual.
-
=head1 OBJECT METHODS
-
-
=over 4
=item C<infl.A($string, $opt_number)>
@@ -138,14 +132,14 @@ instead.
e.g. C<infl.A("idea")> returns C<"an idea">
-
=item C<AN($string, $opt_number)>
synonym for C<A()>
=item C<NO($string, $opt_arg)>
-given a word and an optional count, returns the count followed by the correctly inflected word
+given a word and an optional count, returns the count followed by the
+correctly inflected word
=item C<NUM($string, $opt_arg)>
@@ -168,14 +162,12 @@ element.
takes a single argument and forms its ordinal equivalent. If the
argument isn't a numerical integer, it just adds "-th".
-
=item C<PART_PRES($string, $opt_arg)>
returns the present participle for a third person singluar verb
PART_PRES("runs"); # returns "running"
-
=item C<PL($string, $opt_arg)>
returns the plural of a I<singular> English noun, pronoun, verb or adjective.
@@ -212,9 +204,17 @@ returns the plural form of a I<singular> form of certain types of adjectives.
=item C<def_an($string, $opt_arg)>
-
=back
+=head1 INTERNAL METHODS
+
+=over 4
+
+=item C<tt_inflect($string, $opt_arg)>
+
+The underlying inflect filter.
+
+=back
=head1 TODO
@@ -240,27 +240,50 @@ with commas, for example:
This would require changes to the L<Lingua::EN::Inflect> module.
+=head1 SEE ALSO
+L<Lingua::EN::Inflect>, L<Template>, C<Template::Plugin>
-=head1 AUTHOR
+=head1 DEDICATION
-Andrew Ford E<lt>A.Ford@ford-mason.co.ukE<gt> wrote the plugin
-code (basing it heavily on the Template::Plugin::Autoformat code).
+This distribution was originally created by Andrew Ford. Sadly in early 2014,
+Andrew was diagnosed with Pancreatic Cancer and passed away peacfully at home
+on 25th April 2014.
+One of his wishes was for his OpenSource work to continue. At his funeral, many
+of his colleagues and friends, spoke of how he felt like a person of the world,
+and how he embrace the idea of OpenSource being for the benefit of the world.
-Damian Conway E<lt>damian@conway.orgE<gt> wrote the
-Lingua::EN::Inflect module, which does all the clever stuff.
+Anyone wishing to donate in memory of Andrew, please consider the following
+charities:
+=over
-=head1 COPYRIGHT
+=item Dignity in Dying - L<http://www.dignityindying.org.uk/>
-Copyright (C) 2005 Andrew Ford. All Rights Reserved.
+=item Marie Curie Cancer Care - L<http://www.mariecurie.org.uk/>
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
+=back
-=head1 SEE ALSO
+=head1 AUTHOR
-L<Lingua::EN::Inflect>, L<Template>, C<Template::Plugin>
+ Original Author: Andrew Ford 2005-2014
+ Current Maintainer: Barbie <barbie@cpan.org> 2014
+
+=head1 ACKNOWLEDGEMENTS
+
+Andrew Ford wrote the original plugin code (basing it heavily on the
+Template::Plugin::Autoformat code).
+
+Damian Conway E<lt>damian@conway.orgE<gt> wrote the
+Lingua::EN::Inflect module, which does all the clever stuff.
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright (C) 2005-2014 Andrew Ford
+Copyright (C) 2014 Barbie for Miss Barbell Productions.
+
+This distribution is free software; you can redistribute it and/or
+modify it under the Artistic Licence v2.
=cut
@@ -1,4 +0,0 @@
-use strict;
-use Test::More tests => 1;
-
-BEGIN { use_ok 'Template::Plugin::Lingua::EN::Inflect' }
@@ -0,0 +1,6 @@
+#!/usr/bin/perl -w
+use strict;
+
+use Test::More tests => 1;
+
+BEGIN { use_ok 'Template::Plugin::Lingua::EN::Inflect' }
@@ -1,96 +0,0 @@
-use strict;
-use blib;
-use Template::Test;
-
-test_expect(\*DATA);
-
-__END__
---test--
-[%- # testing inflect filter with a block
- USE Lingua.EN.Inflect;
- FILTER inflect(number => 42); -%]
-There PL_V(was) NO(error).
-PL_ADJ(This) PL_N(error) PL_V(was) fatal.
-[%
- END;
- -%]
---expect--
-There were 42 errors.
-These errors were fatal.
-
---test--
-[% USE Lingua.EN.Inflect -%]
-[% "NUM(3) PL_N(error)." | inflect -%]
---expect--
-3 errors.
-
---test--
-[% USE i = Lingua.EN.Inflect -%]
-[% "NUM(0,0)There PL_V(was) NO(error)." | inflect -%]
---expect--
-There were no errors.
-
---test--
-[%- # testing inflect
- USE inflect = Lingua.EN.Inflect;
- "NUM(0,0)There PL_V(was) NO(error)." | inflect;
--%]
---expect--
-There were no errors.
-
---test--
-[% # testing inflect
- USE Lingua.EN.Inflect;
- "NUM(1,0)There PL_V(was) NO(error)." | inflect;
- -%]
---expect--
-There was 1 error.
-
---test--
-[%- # testing inflect
- USE Lingua.EN.Inflect;
- "NUM(3,0)There PL_V(was) NO(error)." | inflect;
- -%]
---expect--
-There were 3 errors.
-
---test--
-[%- # testing inflect
- USE Lingua.EN.Inflect;
- "There PL_V(was) NO(error)." | inflect(number => 5);
- -%]
---expect--
-There were 5 errors.
-
---test--
-[% # testing NO()
- USE i = Lingua.EN.Inflect;
- FOREACH n IN [ 0, 1, 2, 3, 42 ];
- i.NO('cat', n);
- ', ' UNLESS loop.last;
- END;
- -%]
---expect--
-no cats, 1 cat, 2 cats, 3 cats, 42 cats
-
---test--
-[% # testing NUMWORDS() for 1, 2, 3, ...
- USE i = Lingua.EN.Inflect;
- FOREACH n IN [ 1, 2, 3, 4, 42, 1000 ];
- i.NUMWORDS(n);
- ', ' UNLESS loop.last;
- END;
- -%]
---expect--
-one, two, three, four, forty-two, one thousand
-
---test--
-[% # testing ORD()
- USE Lingua.EN.Inflect;
- FOREACH n IN [ 1, 2, 3, 4, 5, 100 ];
- Lingua.EN.Inflect.ORD(n);
- ', ' UNLESS loop.last;
- END;
- -%]
---expect--
-1st, 2nd, 3rd, 4th, 5th, 100th
@@ -0,0 +1,97 @@
+#!/usr/bin/perl -w
+use strict;
+
+use Template::Test;
+
+test_expect(\*DATA);
+
+__END__
+--test--
+[%- # testing inflect filter with a block
+ USE Lingua.EN.Inflect;
+ FILTER inflect(number => 42); -%]
+There PL_V(was) NO(error).
+PL_ADJ(This) PL_N(error) PL_V(was) fatal.
+[%
+ END;
+ -%]
+--expect--
+There were 42 errors.
+These errors were fatal.
+
+--test--
+[% USE Lingua.EN.Inflect -%]
+[% "NUM(3) PL_N(error)." | inflect -%]
+--expect--
+3 errors.
+
+--test--
+[% USE i = Lingua.EN.Inflect -%]
+[% "NUM(0,0)There PL_V(was) NO(error)." | inflect -%]
+--expect--
+There were no errors.
+
+--test--
+[%- # testing inflect
+ USE inflect = Lingua.EN.Inflect;
+ "NUM(0,0)There PL_V(was) NO(error)." | inflect;
+-%]
+--expect--
+There were no errors.
+
+--test--
+[% # testing inflect
+ USE Lingua.EN.Inflect;
+ "NUM(1,0)There PL_V(was) NO(error)." | inflect;
+ -%]
+--expect--
+There was 1 error.
+
+--test--
+[%- # testing inflect
+ USE Lingua.EN.Inflect;
+ "NUM(3,0)There PL_V(was) NO(error)." | inflect;
+ -%]
+--expect--
+There were 3 errors.
+
+--test--
+[%- # testing inflect
+ USE Lingua.EN.Inflect;
+ "There PL_V(was) NO(error)." | inflect(number => 5);
+ -%]
+--expect--
+There were 5 errors.
+
+--test--
+[% # testing NO()
+ USE i = Lingua.EN.Inflect;
+ FOREACH n IN [ 0, 1, 2, 3, 42 ];
+ i.NO('cat', n);
+ ', ' UNLESS loop.last;
+ END;
+ -%]
+--expect--
+no cats, 1 cat, 2 cats, 3 cats, 42 cats
+
+--test--
+[% # testing NUMWORDS() for 1, 2, 3, ...
+ USE i = Lingua.EN.Inflect;
+ FOREACH n IN [ 1, 2, 3, 4, 42, 1000 ];
+ i.NUMWORDS(n);
+ ', ' UNLESS loop.last;
+ END;
+ -%]
+--expect--
+one, two, three, four, forty-two, one thousand
+
+--test--
+[% # testing ORD()
+ USE Lingua.EN.Inflect;
+ FOREACH n IN [ 1, 2, 3, 4, 5, 100 ];
+ Lingua.EN.Inflect.ORD(n);
+ ', ' UNLESS loop.last;
+ END;
+ -%]
+--expect--
+1st, 2nd, 3rd, 4th, 5th, 100th
@@ -0,0 +1,12 @@
+#!/usr/bin/perl -w
+use strict;
+
+use Test::More;
+
+# Skip if doing a regular install
+plan skip_all => "Author tests not required for installation"
+ unless ( $ENV{AUTOMATED_TESTING} );
+
+eval "use Test::Pod 1.00";
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok();
@@ -0,0 +1,12 @@
+#!/usr/bin/perl -w
+use strict;
+
+use Test::More;
+
+# Skip if doing a regular install
+plan skip_all => "Author tests not required for installation"
+ unless ( $ENV{AUTOMATED_TESTING} );
+
+eval "use Test::Pod::Coverage 0.08";
+plan skip_all => "Test::Pod::Coverage 0.08 required for testing POD coverage" if $@;
+all_pod_coverage_ok({ also_private => ['new'] });
@@ -0,0 +1,36 @@
+#!/usr/bin/perl -w
+use strict;
+
+use Test::More;
+
+# Skip if doing a regular install
+plan skip_all => "Author tests not required for installation"
+ unless ( $ENV{AUTOMATED_TESTING} );
+
+eval "use Test::CPAN::Meta";
+plan skip_all => "Test::CPAN::Meta required for testing META.yml" if $@;
+
+plan 'no_plan';
+
+my $meta = meta_spec_ok(undef,undef,@_);
+
+use Template::Plugin::Lingua::EN::Inflect;
+my $version = $Template::Plugin::Lingua::EN::Inflect::VERSION;
+
+is($meta->{version},$version,
+ 'META.yml distribution version matches');
+
+if($meta->{provides}) {
+ for my $mod (keys %{$meta->{provides}}) {
+ is($meta->{provides}{$mod}{version},$version,
+ "META.yml entry [$mod] version matches distribution version");
+
+ eval "require $mod";
+ my $VERSION = '$' . $mod . '::VERSION';
+ my $v = eval "$VERSION";
+ is($meta->{provides}{$mod}{version},$v,
+ "META.json entry [$mod] version matches module version");
+
+ isnt($meta->{provides}{$mod}{version},0);
+ }
+}
@@ -0,0 +1,39 @@
+#!/usr/bin/perl -w
+use strict;
+
+use Test::More;
+use IO::File;
+
+# Skip if doing a regular install
+plan skip_all => "Author tests not required for installation"
+ unless ( $ENV{AUTOMATED_TESTING} );
+
+my $fh = IO::File->new('Changes','r') or plan skip_all => "Cannot open Changes file";
+
+plan 'no_plan';
+
+use Template::Plugin::Lingua::EN::Inflect;
+my $version = $Template::Plugin::Lingua::EN::Inflect::VERSION;
+
+my $latest = 0;
+while(<$fh>) {
+ next unless(m!^\d!);
+ $latest = 1 if(m!^$version!);
+
+ # 2012-08-26T01:02 or 2012-08-26T01:02:03 or 2012-08-26T01:02:03.04 or 2012-08-26T01:02+01:00
+
+ like($_, qr! \d[\d._]+\s+ # version
+ ( \d{4}-\d{2}-\d{2} # 2012-08-26 - YYYY-MM-DD
+ ( T\d{2}:\d{2} # T01:02 - Thh:mm
+ ( :\d{2} # :02 - :ss
+ ( \.\d+ # .2 - .ss (microseconds)
+ )?
+ )?
+ ( (Z|[-+]\d+:\d+) # +01:00 - timezone
+ )?
+ )?
+ )
+ !x,'... version has a date');
+}
+
+is($latest,1,'... latest version not listed');
@@ -0,0 +1,36 @@
+#!/usr/bin/perl -w
+use strict;
+
+use Test::More;
+
+# Skip if doing a regular install
+plan skip_all => "Author tests not required for installation"
+ unless ( $ENV{AUTOMATED_TESTING} );
+
+eval "use Test::CPAN::Meta::JSON";
+plan skip_all => "Test::CPAN::Meta::JSON required for testing META.json files" if $@;
+
+plan 'no_plan';
+
+my $meta = meta_spec_ok(undef,undef,@_);
+
+use Template::Plugin::Lingua::EN::Inflect;
+my $version = $Template::Plugin::Lingua::EN::Inflect::VERSION;
+
+is($meta->{version},$version,
+ 'META.json distribution version matches');
+
+if($meta->{provides}) {
+ for my $mod (keys %{$meta->{provides}}) {
+ is($meta->{provides}{$mod}{version},$version,
+ "META.json entry [$mod] version matches distribution version");
+
+ eval "require $mod";
+ my $VERSION = '$' . $mod . '::VERSION';
+ my $v = eval "$VERSION";
+ is($meta->{provides}{$mod}{version},$v,
+ "META.json entry [$mod] version matches module version");
+
+ isnt($meta->{provides}{$mod}{version},0);
+ }
+}