File Coverage

blib/lib/String/Normal/Config/AddressStop.pm
Criterion Covered Total %
statement 20 21 95.2
branch 3 6 50.0
condition 1 2 50.0
subroutine 4 4 100.0
pod n/a
total 28 33 84.8


line stmt bran cond sub pod time code
1             package String::Normal::Config::AddressStop;
2 9     9   29 use strict;
  9         7  
  9         179  
3 9     9   25 use warnings;
  9         10  
  9         141  
4              
5 9     9   21 use String::Normal::Config;
  9         9  
  9         1430  
6              
7             sub _data {
8 1     1   2 my %params = @_;
9              
10 1         2 my $fh;
11 1 50       3 if ($params{addres_stop}) {
12 0 0       0 open $fh, $params{addres_stop} or die "Can't read '$params{addres_stop}' $!\n";
13             } else {
14 1         3 $fh = *DATA;
15             }
16              
17 1         2 my %stop;
18 1         3 for (String::Normal::Config::_slurp( $fh )) {
19 34 100       48 next if /^#/;
20 26         31 my ($word,$count) = split ',', $_;
21 26   50     52 $count ||= 1;
22 26         33 $stop{middle}->{$word} = $count;
23             }
24              
25 1         5 return \%stop;
26             }
27              
28             1;
29              
30             =head1 NAME
31              
32             String::Normal::Config::AddressStop;
33              
34             =head1 DESCRIPTION
35              
36             This package defines removals to be performed on address types.
37              
38             =head1 STRUCTURE
39              
40             One entry per line. Each value will be removed. Special characters
41             C<^> and C<$> are NOT used. You can prepend C<#> to lines that you
42             wish to skip. For example:
43              
44             the
45             #and
46              
47             Would remove all occurances of C but not C. Special character
48             C<,> is used to override removal if the final number of tokens if less
49             then the digit specified. For example:
50              
51             the,2
52              
53             Would remove all occurances of C in "The Generic Title" but would
54             not remove any occurances in "The The".
55              
56             You can provide your own data by creating a text file containing your
57             values and provide the path to that file via the constructor:
58              
59             my $normalizer = String::Normal->new( address_stop => '/path/to/values.txt' );
60              
61             =head1 AUTHOR
62              
63             Jeff Anderson, C<< >>
64              
65             =head1 LICENSE AND COPYRIGHT
66              
67             Copyright 2016 Jeff Anderson.
68              
69             This program is free software; you can redistribute it and/or modify it
70             under the terms of the the Artistic License (2.0). You may obtain a
71             copy of the full license at:
72              
73             L
74              
75             Any use, modification, and distribution of the Standard or Modified
76             Versions is governed by this Artistic License. By using, modifying or
77             distributing the Package, you accept this license. Do not use, modify,
78             or distribute the Package, if you do not accept this license.
79              
80             If your Modified Version has been derived from a Modified Version made
81             by someone other than you, you are nevertheless required to ensure that
82             your Modified Version complies with the requirements of this license.
83              
84             This license does not grant you the right to use any trademark, service
85             mark, tradename, or logo of the Copyright Holder.
86              
87             This license includes the non-exclusive, worldwide, free-of-charge
88             patent license to make, have made, use, offer to sell, sell, import and
89             otherwise transfer the Package with respect to any patent claims
90             licensable by the Copyright Holder that are necessarily infringed by the
91             Package. If you institute patent litigation (including a cross-claim or
92             counterclaim) against any party alleging that the Package constitutes
93             direct or contributory patent infringement, then this Artistic License
94             to you shall terminate on the date that such litigation is filed.
95              
96             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
97             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
98             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
99             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
100             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
101             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
102             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
103             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
104              
105             =cut
106              
107             __DATA__