File Coverage

blib/lib/Regexp/Common/URI.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 26 27 96.3


line stmt bran cond sub pod time code
1             package Regexp::Common::URI;
2              
3 71     71   576 use 5.10.0;
  71         150  
4              
5 71     71   226 use strict;
  71         103  
  71         1845  
6 71     71   206 use warnings;
  71         92  
  71         1578  
7 71     71   269 no warnings 'syntax';
  71         70  
  71         1696  
8              
9 71     71   216 use Exporter ();
  71         68  
  71         2969  
10              
11             our @ISA = qw /Exporter/;
12             our @EXPORT_OK = qw /register_uri/;
13              
14 71     71   287 use Regexp::Common qw /pattern clean no_defaults/;
  71         109  
  71         337  
15              
16             our $VERSION = '2016060801';
17              
18             # Use 'require' here, not 'use', so we delay running them after we are compiled.
19             # We also do it using an 'eval'; this saves us from have repeated similar
20             # lines. The eval is further explained in 'perldoc -f require'.
21             my @uris = qw /fax file ftp gopher http pop prospero news tel telnet tv wais/;
22             foreach my $uri (@uris) {
23             eval "require Regexp::Common::URI::$uri";
24             die $@ if $@;
25             }
26              
27             my %uris;
28              
29             sub register_uri {
30 923     923 0 1226 my ($scheme, $uri) = @_;
31 923         2250 $uris {$scheme} = $uri;
32             }
33              
34             pattern name => [qw (URI)],
35             create => sub {my $uri = join '|' => values %uris;
36             $uri =~ s/\(\?k:/(?:/g;
37             "(?k:$uri)";
38             },
39             ;
40              
41             1;
42              
43             __END__