| 1 | package Alien::Build::Plugin::Fetch::LocalDir; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 4 | ▶ | use 5.008004; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 4 | ▶ | use Alien::Build::Plugin; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 4 | ▶ | use File::chdir; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 4 | ▶ | use Path::Tiny (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | # ABSTRACT: Plugin for fetching a local directory | ||||||||||||||||||||
| 11 | 4 | our $VERSION = '2.88'; # VERSION | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 4 | has root => undef; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 4 | has ssl => 0; | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | sub init | ||||||||||||||||||||
| 20 | 4 | ▶ | { | ||||||||||||||||||
|
Subroutine
init: called CC=4 SCAR=17.3
Pod
documented
| |||||||||||||||||||||
| 21 | 4 | my($self, $meta) = @_; | |||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 4 | ▶ | my $url = $meta->prop->{start_url} || 'patch'; | ||||||||||||||||||
|
Condition50%1/2
$meta->prop->{'start_url'} || 'patch'
MC/DC0%0/1
$meta->prop->{'start_url'} || 'patch'
$meta->prop->{'start_url'}
Truth table50%1/2
A
A= $meta->prop->{'start_url'}
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 4 | $meta->add_requires('configure' => 'Alien::Build::Plugin::Fetch::LocalDir' => '0.72' ); | |||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 4 | ▶ | if($url =~ /^file:/) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | { | ||||||||||||||||||||
| 29 | 0 | $meta->add_requires('share' => 'URI' => 0 ); | |||||||||||||||||||
| 30 | 0 | $meta->add_requires('share' => 'URI::file' => 0 ); | |||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | { | ||||||||||||||||||||
| 34 | 4 | my $root = $self->root; | |||||||||||||||||||
| 35 | 4 | ▶ | if(defined $root) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | { | ||||||||||||||||||||
| 37 | 0 | $root = Path::Tiny->new($root)->absolute->stringify; | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | else | ||||||||||||||||||||
| 40 | { | ||||||||||||||||||||
| 41 | 4 | $root = "$CWD"; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | 4 | $self->root($root); | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | $meta->register_hook( | ||||||||||||||||||||
| 47 | 4 | ▶ | fetch => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=25.6
| |||||||||||||||||||||
| 48 | 4 | my($build, $path, %options) = @_; | |||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 4 | ▶ | $build->log("plugin Fetch::LocalDir does not support http_headers option") if $options{http_headers}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 4 | ▶ | $path ||= $url; | ||||||||||||||||||
|
Condition33%1/3
$path ||= $url
MC/DC0%0/2
$path ||= $url
$path
$url
Truth table33%1/3
A ||= B
A= $pathB= $url
| |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 4 | ▶ | if($path =~ /^file:/) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 55 | { | ||||||||||||||||||||
| 56 | 0 | my $root = URI::file->new($self->root); | |||||||||||||||||||
| 57 | 0 | my $url = URI->new_abs($path, $root); | |||||||||||||||||||
| 58 | 0 | $path = $url->path; | |||||||||||||||||||
| 59 | 0 | ▶ | $path =~ s{^/([a-z]:)}{$1}i if $^O eq 'MSWin32'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 4 | $path = Path::Tiny->new($path)->absolute($self->root); | |||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 4 | ▶ | if(-d $path) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 65 | { | ||||||||||||||||||||
| 66 | return { | ||||||||||||||||||||
| 67 | 4 | type => 'file', | |||||||||||||||||||
| 68 | filename => $path->basename, | ||||||||||||||||||||
| 69 | path => $path->stringify, | ||||||||||||||||||||
| 70 | tmp => 0, | ||||||||||||||||||||
| 71 | protocol => 'file', | ||||||||||||||||||||
| 72 | }; | ||||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | else | ||||||||||||||||||||
| 75 | { | ||||||||||||||||||||
| 76 | 0 | $build->log("path $path is not a directory"); | |||||||||||||||||||
| 77 | 0 | $build->log("(you specified $url with root @{[ $self->root ]})"); | |||||||||||||||||||
| 78 | 0 | die "$path is not a directory"; | |||||||||||||||||||
| 79 | } | ||||||||||||||||||||
| 80 | } | ||||||||||||||||||||
| 81 | 4 | ); | |||||||||||||||||||
| 82 | } | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | 4 | 1; | |||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | __END__ | ||||||||||||||||||||