File Coverage

blib/lib/String/Ident.pm
Criterion Covered Total %
statement 23 23 100.0
branch 1 2 50.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 30 31 96.7


line stmt bran cond sub pod time code
1             package String::Ident;
2              
3 1     1   568 use warnings;
  1         2  
  1         33  
4 1     1   4 use strict;
  1         1  
  1         26  
5 1     1   11 use utf8;
  1         1  
  1         5  
6              
7             our $VERSION = 0.02;
8              
9 1     1   530 use Text::Unidecode 'unidecode';
  1         1796  
  1         246  
10              
11             sub cleanup {
12 3     3 1 617 my ($self, $text) = @_;
13              
14 3 50       10 $text = '' unless defined($text);
15 3         8 $text = unidecode($text);
16 3         2703 $text =~ s/[^-A-Za-z0-9]/-/g;
17 3         6 $text =~ s/--+/-/g;
18 3         6 $text =~ s/-$//g;
19 3         3 $text =~ s/^-//g;
20 3         7 $text = substr($text,0,30);
21 3         7 while (length($text) < 4) {
22 4         35 $text .= chr(ord('a') + rand(ord('z') - ord('a') + 1));
23             }
24              
25 3         10 return $text;
26             }
27              
28             1;
29              
30              
31             __END__