Skip to content

Commit

Permalink
CPANTS work. perltidy.
Browse files Browse the repository at this point in the history
  • Loading branch information
bricas committed Feb 27, 2008
1 parent c5493ab commit 2d80ddb
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 93 deletions.
12 changes: 9 additions & 3 deletions Makefile.PL
@@ -1,11 +1,17 @@
use inc::Module::Install 0.67;
use inc::Module::Install 0.68;

if ( -e 'MANIFEST.SKIP' ) {
system( 'pod2text lib/Text/Normalize/NACO.pm > README' );
}

perl_version '5.008'; # need 5.008 for unicode

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';

test_requires 'Test::More';

auto_install;
WriteAll;
73 changes: 0 additions & 73 deletions README

This file was deleted.

18 changes: 9 additions & 9 deletions lib/Text/Normalize/NACO.pm
Expand Up @@ -44,7 +44,7 @@ use warnings;

use Text::Unidecode;

our $VERSION = '0.11';
our $VERSION = '0.12';

our @EXPORT_OK = qw( naco_normalize );

Expand Down Expand Up @@ -84,7 +84,7 @@ Accessor/Mutator for the case in which the string should be returned.

sub case {
my $self = shift;
my( $case ) = @_;
my ( $case ) = @_;

$self->{ _CASE } = $case if @_;

Expand All @@ -107,7 +107,7 @@ sub naco_normalize {

my $normalized = normalize( undef, $text );

if( $case eq 'lower' ) {
if ( $case eq 'lower' ) {
$normalized =~ tr/A-Z/a-z/;
}
else {
Expand All @@ -126,24 +126,24 @@ Normalizes $text and returns the new string.
=cut

sub normalize {
my $self = shift;
my $data = shift;
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' ) {
if ( $self ) {
if ( $self->case eq 'lower' ) {
$data =~ tr/A-Z/a-z/;
}
else {
Expand Down Expand Up @@ -174,7 +174,7 @@ Brian Cassidy E<lt>bricas@cpan.orgE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright 2007 by Brian Cassidy
Copyright 2008 by Brian Cassidy
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
Expand Down
6 changes: 3 additions & 3 deletions t/10-normalize.t
Expand Up @@ -14,14 +14,14 @@ isa_ok( $naco, 'Text::Normalize::NACO' );

my $original = ' abc ';

is( naco_normalize( $original ), 'ABC', 'naco_normalize()' );
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()' );

is( naco_normalize( $original, { case => 'lower' } ),
'abc', 'naco_normalize()' );

8 changes: 4 additions & 4 deletions t/11-normalize_suite.t
Expand Up @@ -13,13 +13,13 @@ isa_ok( $naco, 'Text::Normalize::NACO' );
for my $file ( glob( 't/*.dat' ) ) {
open( my $text, $file ) or die $!;

while( <$text> ) {
while ( <$text> ) {
s/[\r\n]//g;
my( $original, $normalized ) = split( /\t/, $_ );
is( $naco->normalize( $original ), $normalized, "\$naco->normalize( '$original' )" );
my ( $original, $normalized ) = split( /\t/, $_ );
is( $naco->normalize( $original ),
$normalized, "\$naco->normalize( '$original' )" );
}

close( $text ) or die $!;
}


3 changes: 2 additions & 1 deletion t/98-pod_coverage.t
@@ -1,4 +1,5 @@
use Test::More;
eval "use Test::Pod::Coverage 1.00";
plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@;
plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage"
if $@;
all_pod_coverage_ok();

0 comments on commit 2d80ddb

Please sign in to comment.