blib/lib/MooseX/Types/URI.pm

filter: Statementstmt 69.0% 49 / 71 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 58.3% 14 / 24 Podpod n/a totaltotal 65.6% 65 / 99 CC 1 SCAR 3.5
CC
1
Cov
68%
__ANON__
2.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.4
↑ Summary
1 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package MooseX::Types::URI; # git description: v0.09-3-ge61243d
4 # ABSTRACT: URI related types and coercions for Moose
5 # KEYWORDS: moose types constraints coercions uri path web
6  
7 2 our $VERSION = '0.10';
8  
9 2 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use URI::QueryParam;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use URI::WithBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 ▶use MooseX::Types::Moose qw{Str ScalarRef HashRef};
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 2 ▶use MooseX::Types 0.40 -declare => [qw(Uri _UriWithBase _Uri FileUri DataUri)];
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use if MooseX::Types->VERSION >= 0.42, 'namespace::autoclean';
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 my $uri = Moose::Meta::TypeConstraint->new(
21 name => Uri,
22 parent => Moose::Meta::TypeConstraint::Union->new(
23 name => join("|", _Uri, _UriWithBase),
24 type_constraints => [
25 class_type( _Uri, { class => "URI" } ),
26 class_type( _UriWithBase, { class => "URI::WithBase" } ),
27 ],
28 ),
29 0 ▶ inline_as => sub { 'local $@; blessed('.$_[1].') && ( '.$_[1].'->isa("URI") || '.$_[1].'->isa("URI::WithBase") )' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 2 );
31  
32 2 register_type_constraint($uri);
33  
34 coerce( Uri,
35 2 ▶ from Str , via { URI->new($_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
36 0 eval { +require MooseX::Types::Path::Class; 1 }
37 ? (
38 0 ▶ from "Path::Class::File", via { require URI::file; URI::file::->new($_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
39 0 ▶ from "Path::Class::Dir" , via { require URI::file; URI::file::->new($_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
40 0 ▶ from MooseX::Types::Path::Class::File() , via { require URI::file; URI::file::->new($_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
41 0 ▶ from MooseX::Types::Path::Class::Dir() , via { require URI::file; URI::file::->new($_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
42 ) : (),
43 0 ▶ from ScalarRef , via { my $u = URI->new("data:"); $u->data($$_); $u },
Subroutine __ANON__: not called CC=1 SCAR=6.9
44 1 ▶ from HashRef , via { require URI::FromHash; URI::FromHash::uri_object(%$_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
45 2 ▶);
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require MooseX::Types::Path::Class; 1 } } ? : 0 2 2
46  
47 2 class_type FileUri, { class => "URI::file", parent => $uri };
48  
49 coerce( FileUri,
50 1 ▶ from Str , via { require URI::file; URI::file::->new($_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
51 0 eval { +require MooseX::Types::Path::Class; 1 }
52 ? (
53 0 ▶ from MooseX::Types::Path::Class::File() , via { require URI::file; URI::file::->new($_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
54 0 ▶ from MooseX::Types::Path::Class::Dir() , via { require URI::file; URI::file::->new($_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
55 0 ▶ from "Path::Class::File" , via { require URI::file; URI::file::->new($_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
56 0 ▶ from "Path::Class::Dir" , via { require URI::file; URI::file::->new($_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
57 2 ▶ ) : (),
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require MooseX::Types::Path::Class; 1 } } ? : 0 2 2
58 );
59  
60 2 class_type DataUri, { class => "URI::data" };
61  
62 coerce( DataUri,
63 1 ▶ from Str , via { my $u = URI->new("data:"); $u->data($_); $u },
Subroutine __ANON__: called CC=1 SCAR=0.0
64 1 ▶ from ScalarRef , via { my $u = URI->new("data:"); $u->data($$_); $u },
Subroutine __ANON__: called CC=1 SCAR=0.0
65 2 );
66  
67 2 1;
68  
69 __END__
↑ Summary