Browse files

switch to module::install. newlines. tabs=>spaces

  • Loading branch information...
1 parent 72e31f9 commit c5493ab4f2af0d92c3347f11dea9b9cc7aa7711d @bricas committed Aug 21, 2007
Showing with 376 additions and 303 deletions.
  1. +0 −19 Build.PL
  2. +4 −0 Changes
  3. +0 −12 MANIFEST
  4. +29 −0 MANIFEST.SKIP
  5. +11 −0 Makefile.PL
  6. +73 −0 README
  7. +184 −197 lib/Text/Normalize/NACO.pm
  8. +11 −11 t/01-use.t
  9. +27 −27 t/10-normalize.t
  10. +25 −25 t/11-normalize_suite.t
  11. +4 −4 t/98-pod_coverage.t
  12. +8 −8 t/99-pod.t
View
19 Build.PL
@@ -1,19 +0,0 @@
-use strict;
-
-use Module::Build;
-
-my $build = Module::Build->new(
- module_name => 'Text::Normalize::NACO',
- dist_author => 'Brian Cassidy <bricas@cpan.org>',
- license => 'perl',
- create_readme => 1,
- create_makefile_pl => 'traditional',
- requires => {
- 'Text::Unidecode' => 0,
- },
- build_requres => {
- 'Test::More' => 0,
- }
-);
-
-$build->create_build_script;
View
4 Changes
@@ -1,4 +1,8 @@
Revision history for Perl extension Text::Normalize::NACO
+
+0.11 Tue Aug 21 2007
+ - switch to Module::Install
+ - specify perl 5.8.0 as prereq due to unicode requirements
0.1 Tue Apr 18 2006
- use Text::Unidecode to remove diacritical marks
View
12 MANIFEST
@@ -1,12 +0,0 @@
-Build.PL
-Changes
-lib/Text/Normalize/NACO.pm
-MANIFEST
-META.yml
-t/01-use.t
-t/10-normalize.t
-t/11-normalize_suite.t
-t/98-pod_coverage.t
-t/99-pod.t
-t/titles.dat
-t/titles2.dat
View
29 MANIFEST.SKIP
@@ -0,0 +1,29 @@
+# Avoid version control files.
+\bRCS\b
+\bCVS\b
+,v$
+\B\.svn\b
+
+# Avoid Makemaker generated and utility files.
+\bMakefile$
+\bblib
+\bMakeMaker-\d
+\bpm_to_blib$
+\bblibdirs$
+^MANIFEST\.SKIP$
+
+# Avoid Module::Build generated and utility files.
+\bBuild$
+\b_build
+
+# Avoid temp and backup files.
+~$
+\.tmp$
+\.old$
+\.bak$
+\#$
+\b\.#
+\.DS_Store$
+
+# No tarballs!
+\.gz$
View
11 Makefile.PL
@@ -0,0 +1,11 @@
+use inc::Module::Install 0.67;
+
+name 'Text-Normalize-NACO';
+perl_version '5.008'; # need 5.008 for unicode
+all_from 'lib/Text/Normalize/NACO.pm';
+
+requires 'Text::Unidecode';
+requires 'Test::More';
+
+auto_install;
+WriteAll;
View
73 README
@@ -0,0 +1,73 @@
+NAME
+ Text::Normalize::NACO - Normalize text based on the NACO rules
+
+SYNOPSIS
+ # exported method
+ use Text::Normalize::NACO qw( naco_normalize );
+
+ $normalized = naco_normalize( $original );
+
+ # as an object
+ $naco = Text::Normalize::NACO->new;
+ $normalized = $naco->normalize( $original );
+
+ # normalize to lowercase
+ $naco->case( 'lower' );
+ $normalized = $naco->normalize( $original );
+
+DESCRIPTION
+ In general, normalization is defined as:
+
+ To make (a text or language) regular and consistent, especially with respect to spelling or style.
+
+ It is commonly used for comparative purposes. These particular
+ normalization rules have been set out by the Name Authority Cooperative.
+ The rules are described in detail at:
+ http://www.loc.gov/catdir/pcc/naco/normrule.html
+
+INSTALLATION
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+METHODS
+ new( %options )
+ Creates a new Text::Normalize::NACO object. You explicitly request
+ strings to be normalized in upper or lower-case by setting the "case"
+ option (defaults to "upper").
+
+ my $naco = Text::Normalize::NACO->new( case => 'lower' );
+
+ case( $case )
+ Accessor/Mutator for the case in which the string should be returned.
+
+ # lower-case
+ $naco->case( 'lower' );
+
+ # upper-case
+ $naco->case( 'upper' );
+
+ naco_normalize( $text, { %options } )
+ Exported version of "normalize". You can specify any extra options by
+ passing a hashref after the string to be normalized.
+
+ my $normalized = naco_normalize( $original, { case => 'lower' } );
+
+ normalize( $text )
+ Normalizes $text and returns the new string.
+
+ my $normalized = $naco->normalize( $original );
+
+SEE ALSO
+ * http://www.loc.gov/catdir/pcc/naco/normrule.html
+
+AUTHOR
+ Brian Cassidy <bricas@cpan.org>
+
+COPYRIGHT AND LICENSE
+ Copyright 2007 by Brian Cassidy
+
+ This library is free software; you can redistribute it and/or modify it
+ under the same terms as Perl itself.
+
View
381 lib/Text/Normalize/NACO.pm
@@ -1,197 +1,184 @@
-package Text::Normalize::NACO;
-
-=head1 NAME
-
-Text::Normalize::NACO - Normalize text based on the NACO rules
-
-=head1 SYNOPSIS
-
- # exported method
- use Text::Normalize::NACO qw( naco_normalize );
-
- $normalized = naco_normalize( $original );
-
- # as an object
- $naco = Text::Normalize::NACO->new;
- $normalized = $naco->normalize( $original );
-
- # normalize to lowercase
- $naco->case( 'lower' );
- $normalized = $naco->normalize( $original );
-
-=head1 DESCRIPTION
-
-In general, normalization is defined as:
-
- To make (a text or language) regular and consistent, especially with respect to spelling or style.
-
-It is commonly used for comparative purposes. These particular normalization rules have been set out by the
-Name Authority Cooperative. The rules are described in detail at: http://www.loc.gov/catdir/pcc/naco/normrule.html
-
-=head1 INSTALLATION
-
-To install this module via Module::Build:
-
- perl Build.PL
- ./Build # or `perl Build`
- ./Build test # or `perl Build test`
- ./Build install # or `perl Build install`
-
-To install this module via ExtUtils::MakeMaker:
-
- perl Makefile.PL
- make
- make test
- make install
-
-=cut
-
-use base qw( Exporter );
-
-use strict;
-use warnings;
-
-use Text::Unidecode;
-
-our $VERSION = '0.1';
-
-our @EXPORT_OK = qw( naco_normalize );
-
-=head1 METHODS
-
-=head2 new( %options )
-
-Creates a new Text::Normalize::NACO object. You explicitly request
-strings to be normalized in upper or lower-case by setting
-the "case" option (defaults to "upper").
-
- my $naco = Text::Normalize::NACO->new( case => 'lower' );
-
-=cut
-
-sub new {
- my $class = shift;
- my %options = @_;
- my $self = bless {}, $class;
-
- $self->case( $options{ case } || 'upper' );
-
- return $self;
-}
-
-=head2 case( $case )
-
-Accessor/Mutator for the case in which the string should be returned.
-
- # lower-case
- $naco->case( 'lower' );
-
- # upper-case
- $naco->case( 'upper' );
-
-=cut
-
-sub case {
- my $self = shift;
- my( $case ) = @_;
-
- $self->{ _CASE } = $case if @_;
-
- return $self->{ _CASE };
-}
-
-=head2 naco_normalize( $text, { %options } )
-
-Exported version of C<normalize>. You can specify any extra
-options by passing a hashref after the string to be normalized.
-
- my $normalized = naco_normalize( $original, { case => 'lower' } );
-
-=cut
-
-sub naco_normalize {
- my $text = shift;
- my $options = shift;
- my $case = $options->{ case } || 'upper';
-
- my $normalized = normalize( undef, $text );
-
- if( $case eq 'lower' ) {
- $normalized =~ tr/A-Z/a-z/;
- }
- else {
- $normalized =~ tr/a-z/A-Z/;
- }
-
- return $normalized;
-}
-
-=head2 normalize( $text )
-
-Normalizes $text and returns the new string.
-
- my $normalized = $naco->normalize( $original );
-
-=cut
-
-sub normalize {
- my $self = shift;
- my $data = shift;
-
- # Rules taken from NACO Normalization
- # http://lcweb.loc.gov/catdir/pcc/naco/normrule.html
-
- # Remove diacritical marks and convert special chars
- unidecode( $data );
-
- # Convert special chars to spaces
- $data =~ s/[\Q!(){}<>-;:.?,\/\\@*%=\$^_~\E]/ /g;
-
- # Delete special chars
- $data =~ s/[\Q'[]|\E]//g;
-
- # Convert lowercase to uppercase or vice-versa.
- if( $self ) {
- if( $self->case eq 'lower' ) {
- $data =~ tr/A-Z/a-z/;
- }
- else {
- $data =~ tr/a-z/A-Z/;
- }
- }
-
- # Remove leading and trailing spaces
- $data =~ s/^\s+|\s+$//g;
-
- # Condense multiple spaces
- $data =~ s/\s+/ /g;
-
- return $data;
-}
-
-=head1 SEE ALSO
-
-=over 4
-
-=item * http://www.loc.gov/catdir/pcc/naco/normrule.html
-
-=back
-
-=head1 AUTHOR
-
-=over 4
-
-=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>
-
-=back
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 2006 by Brian Cassidy
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
-
-1;
+package Text::Normalize::NACO;
+
+=head1 NAME
+
+Text::Normalize::NACO - Normalize text based on the NACO rules
+
+=head1 SYNOPSIS
+
+ # exported method
+ use Text::Normalize::NACO qw( naco_normalize );
+
+ $normalized = naco_normalize( $original );
+
+ # as an object
+ $naco = Text::Normalize::NACO->new;
+ $normalized = $naco->normalize( $original );
+
+ # normalize to lowercase
+ $naco->case( 'lower' );
+ $normalized = $naco->normalize( $original );
+
+=head1 DESCRIPTION
+
+In general, normalization is defined as:
+
+ To make (a text or language) regular and consistent, especially with respect to spelling or style.
+
+It is commonly used for comparative purposes. These particular normalization rules have been set out by the
+Name Authority Cooperative. The rules are described in detail at: http://www.loc.gov/catdir/pcc/naco/normrule.html
+
+=head1 INSTALLATION
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+=cut
+
+use base qw( Exporter );
+
+use strict;
+use warnings;
+
+use Text::Unidecode;
+
+our $VERSION = '0.11';
+
+our @EXPORT_OK = qw( naco_normalize );
+
+=head1 METHODS
+
+=head2 new( %options )
+
+Creates a new Text::Normalize::NACO object. You explicitly request
+strings to be normalized in upper or lower-case by setting
+the "case" option (defaults to "upper").
+
+ my $naco = Text::Normalize::NACO->new( case => 'lower' );
+
+=cut
+
+sub new {
+ my $class = shift;
+ my %options = @_;
+ my $self = bless {}, $class;
+
+ $self->case( $options{ case } || 'upper' );
+
+ return $self;
+}
+
+=head2 case( $case )
+
+Accessor/Mutator for the case in which the string should be returned.
+
+ # lower-case
+ $naco->case( 'lower' );
+
+ # upper-case
+ $naco->case( 'upper' );
+
+=cut
+
+sub case {
+ my $self = shift;
+ my( $case ) = @_;
+
+ $self->{ _CASE } = $case if @_;
+
+ return $self->{ _CASE };
+}
+
+=head2 naco_normalize( $text, { %options } )
+
+Exported version of C<normalize>. You can specify any extra
+options by passing a hashref after the string to be normalized.
+
+ my $normalized = naco_normalize( $original, { case => 'lower' } );
+
+=cut
+
+sub naco_normalize {
+ my $text = shift;
+ my $options = shift;
+ my $case = $options->{ case } || 'upper';
+
+ my $normalized = normalize( undef, $text );
+
+ if( $case eq 'lower' ) {
+ $normalized =~ tr/A-Z/a-z/;
+ }
+ else {
+ $normalized =~ tr/a-z/A-Z/;
+ }
+
+ return $normalized;
+}
+
+=head2 normalize( $text )
+
+Normalizes $text and returns the new string.
+
+ my $normalized = $naco->normalize( $original );
+
+=cut
+
+sub normalize {
+ my $self = shift;
+ my $data = shift;
+
+ # Rules taken from NACO Normalization
+ # http://lcweb.loc.gov/catdir/pcc/naco/normrule.html
+
+ # Remove diacritical marks and convert special chars
+ unidecode( $data );
+
+ # Convert special chars to spaces
+ $data =~ s/[\Q!(){}<>-;:.?,\/\\@*%=\$^_~\E]/ /g;
+
+ # Delete special chars
+ $data =~ s/[\Q'[]|\E]//g;
+
+ # Convert lowercase to uppercase or vice-versa.
+ if( $self ) {
+ if( $self->case eq 'lower' ) {
+ $data =~ tr/A-Z/a-z/;
+ }
+ else {
+ $data =~ tr/a-z/A-Z/;
+ }
+ }
+
+ # Remove leading and trailing spaces
+ $data =~ s/^\s+|\s+$//g;
+
+ # Condense multiple spaces
+ $data =~ s/\s+/ /g;
+
+ return $data;
+}
+
+=head1 SEE ALSO
+
+=over 4
+
+=item * http://www.loc.gov/catdir/pcc/naco/normrule.html
+
+=back
+
+=head1 AUTHOR
+
+Brian Cassidy E<lt>bricas@cpan.orgE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2007 by Brian Cassidy
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
View
22 t/01-use.t
@@ -1,11 +1,11 @@
-use Test::More tests => 2;
-
-use strict;
-use warnings;
-
-BEGIN {
- use_ok( 'Text::Normalize::NACO' );
-}
-
-my $naco = Text::Normalize::NACO->new;
-isa_ok( $naco, 'Text::Normalize::NACO' );
+use Test::More tests => 2;
+
+use strict;
+use warnings;
+
+BEGIN {
+ use_ok( 'Text::Normalize::NACO' );
+}
+
+my $naco = Text::Normalize::NACO->new;
+isa_ok( $naco, 'Text::Normalize::NACO' );
View
54 t/10-normalize.t
@@ -1,27 +1,27 @@
-use Test::More tests => 6;
-
-use strict;
-use warnings;
-
-BEGIN {
- use_ok( 'Text::Normalize::NACO' );
-}
-
-Text::Normalize::NACO->import( 'naco_normalize' );
-
-my $naco = Text::Normalize::NACO->new;
-isa_ok( $naco, 'Text::Normalize::NACO' );
-
-my $original = ' abc ';
-
-is( naco_normalize( $original ), 'ABC', 'naco_normalize()' );
-is( $naco->normalize( $original ), 'ABC', 'normalize()' );
-
-$original = ' ABC ';
-
-$naco->case( 'lower' );
-
-is( $naco->normalize( $original ), 'abc', 'normalize()' );
-is( naco_normalize( $original, { case => 'lower' } ), 'abc', 'naco_normalize()' );
-
-
+use Test::More tests => 6;
+
+use strict;
+use warnings;
+
+BEGIN {
+ use_ok( 'Text::Normalize::NACO' );
+}
+
+Text::Normalize::NACO->import( 'naco_normalize' );
+
+my $naco = Text::Normalize::NACO->new;
+isa_ok( $naco, 'Text::Normalize::NACO' );
+
+my $original = ' abc ';
+
+is( naco_normalize( $original ), 'ABC', 'naco_normalize()' );
+is( $naco->normalize( $original ), 'ABC', 'normalize()' );
+
+$original = ' ABC ';
+
+$naco->case( 'lower' );
+
+is( $naco->normalize( $original ), 'abc', 'normalize()' );
+is( naco_normalize( $original, { case => 'lower' } ), 'abc', 'naco_normalize()' );
+
+
View
50 t/11-normalize_suite.t
@@ -1,25 +1,25 @@
-use Test::More qw( no_plan );
-
-use strict;
-use warnings;
-
-BEGIN {
- use_ok( 'Text::Normalize::NACO' );
-}
-
-my $naco = Text::Normalize::NACO->new( case => 'lower' );
-isa_ok( $naco, 'Text::Normalize::NACO' );
-
-for my $file ( glob( 't/*.dat' ) ) {
- open( my $text, $file ) or die $!;
-
- while( <$text> ) {
- s/[\r\n]//g;
- my( $original, $normalized ) = split( /\t/, $_ );
- is( $naco->normalize( $original ), $normalized, "\$naco->normalize( '$original' )" );
- }
-
- close( $text ) or die $!;
-}
-
-
+use Test::More qw( no_plan );
+
+use strict;
+use warnings;
+
+BEGIN {
+ use_ok( 'Text::Normalize::NACO' );
+}
+
+my $naco = Text::Normalize::NACO->new( case => 'lower' );
+isa_ok( $naco, 'Text::Normalize::NACO' );
+
+for my $file ( glob( 't/*.dat' ) ) {
+ open( my $text, $file ) or die $!;
+
+ while( <$text> ) {
+ s/[\r\n]//g;
+ my( $original, $normalized ) = split( /\t/, $_ );
+ is( $naco->normalize( $original ), $normalized, "\$naco->normalize( '$original' )" );
+ }
+
+ close( $text ) or die $!;
+}
+
+
View
8 t/98-pod_coverage.t
@@ -1,4 +1,4 @@
-use Test::More;
-eval "use Test::Pod::Coverage 1.00";
-plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@;
-all_pod_coverage_ok();
+use Test::More;
+eval "use Test::Pod::Coverage 1.00";
+plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@;
+all_pod_coverage_ok();
View
16 t/99-pod.t
@@ -1,8 +1,8 @@
-use Test::More;
-
-use strict;
-use warnings;
-
-eval 'use Test::Pod 1.00';
-plan skip_all => 'Test::Pod 1.00 required for testing POD' if $@;
-all_pod_files_ok();
+use Test::More;
+
+use strict;
+use warnings;
+
+eval 'use Test::Pod 1.00';
+plan skip_all => 'Test::Pod 1.00 required for testing POD' if $@;
+all_pod_files_ok();

0 comments on commit c5493ab

Please sign in to comment.