File Coverage

blib/lib/Pinto/Locator.pm
Criterion Covered Total %
statement 20 23 86.9
branch 5 8 62.5
condition n/a
subroutine 6 9 66.6
pod 0 4 0.0
total 31 44 70.4


line stmt bran cond sub pod time code
1             # ABSTRACT: Base class for Locators
2              
3             package Pinto::Locator;
4              
5 51     51   26992 use Moose;
  51         117  
  51         369  
6 51     51   324145 use MooseX::StrictConstructor;
  51         129  
  51         468  
7 51     51   167114 use MooseX::MarkAsMethods (autoclean => 1);
  51         115  
  51         419  
8              
9 51     51   177565 use Pinto::Types qw(Dir Uri);
  51         119  
  51         519  
10 51     51   313050 use Pinto::Util qw(throw tempdir);
  51         147  
  51         16424  
11              
12             #------------------------------------------------------------------------
13              
14             our $VERSION = '0.13'; # VERSION
15              
16             #------------------------------------------------------------------------
17              
18             with qw(Pinto::Role::UserAgent);
19              
20             #------------------------------------------------------------------------
21              
22             has uri => (
23             is => 'ro',
24             isa => Uri,
25             default => 'http://backpan.perl.org',
26             coerce => 1,
27             );
28              
29             has cache_dir => (
30             is => 'ro',
31             isa => Dir,
32             default => \&tempdir,
33             );
34              
35             #------------------------------------------------------------------------
36              
37             sub locate {
38 74     74 0 1879 my ($self, %args) = @_;
39              
40 74 50       518 $args{target} || throw 'Invalid arguments';
41              
42             $args{target} = Pinto::Target->new($args{target})
43 74 50       413 if not ref $args{target};
44              
45             return $self->locate_package(%args)
46 74 100       1051 if $args{target}->isa('Pinto::Target::Package');
47              
48             return $self->locate_distribution(%args)
49 6 50       58 if $args{target}->isa('Pinto::Target::Distribution');
50            
51 0           throw 'Invalid arguments';
52             }
53              
54             #------------------------------------------------------------------------
55              
56 0     0 0   sub locate_package { die 'Abstract method'}
57              
58             #------------------------------------------------------------------------
59              
60 0     0 0   sub locate_distribution { die 'Abstract method'}
61              
62             #------------------------------------------------------------------------
63              
64       0 0   sub refresh {}
65              
66             #------------------------------------------------------------------------
67              
68             __PACKAGE__->meta->make_immutable;
69              
70             #------------------------------------------------------------------------
71             1;
72              
73             __END__
74              
75             =pod
76              
77             =encoding UTF-8
78              
79             =for :stopwords Jeffrey Ryan Thalhammer
80              
81             =head1 NAME
82              
83             Pinto::Locator - Base class for Locators
84              
85             =head1 VERSION
86              
87             version 0.13
88              
89             =head1 AUTHOR
90              
91             Jeffrey Ryan Thalhammer <jeff@stratopan.com>
92              
93             =head1 COPYRIGHT AND LICENSE
94              
95             This software is copyright (c) 2015 by Jeffrey Ryan Thalhammer.
96              
97             This is free software; you can redistribute it and/or modify it under
98             the same terms as the Perl 5 programming language system itself.
99              
100             =cut