File Coverage

blib/lib/Data/Password/Common.pm
Criterion Covered Total %
statement 33 33 100.0
branch 1 2 50.0
condition 2 3 66.6
subroutine 10 10 100.0
pod 0 1 0.0
total 46 49 93.8


line stmt bran cond sub pod time code
1 2     2   276529 use v5.10;
  2         9  
  2         170  
2 2     2   15 use strict;
  2         5  
  2         77  
3 2     2   12 use warnings;
  2         4  
  2         157  
4              
5             package Data::Password::Common;
6             # ABSTRACT: Check a password against a list of common passwords
7             our $VERSION = '0.004'; # VERSION
8              
9             # Dependencies
10 2     2   12 use File::ShareDir;
  2         5  
  2         165  
11 2     2   2792 use IO::File;
  2         2518  
  2         313  
12 2     2   1865 use Search::Dict;
  2         8908  
  2         136  
13 2     2   3734 use autodie 2.00;
  2         40779  
  2         15  
14              
15 2     2   18922 use Sub::Exporter -setup => { exports => [ 'found' => \&build_finder ] };
  2         33931  
  2         35  
16              
17             sub build_finder {
18 3     3 0 580 my ( $class, $name, $arg, $col ) = @_;
19 3   66     52 my $list_path = $arg->{list}
20             || File::ShareDir::dist_file( "Data-Password-Common", "common.txt" );
21 3         568 my $list_handle = IO::File->new( $list_path, "<:utf8" );
22              
23             return sub {
24 8 50   8   16200 return unless @_;
25 8         17 my $password = shift;
26 8         37 look $list_handle, $password;
27 8         12419 chomp( my $found = <$list_handle> );
28 8         63 return $found eq $password;
29 3         385 };
30             }
31              
32             1;
33              
34              
35             # vim: ts=2 sts=2 sw=2 et:
36              
37             __END__