Alien-Base-ModuleBuild
view release on metacpan or search on metacpan
lib/Alien/Base/ModuleBuild/Repository/Local.pm view on Meta::CPAN
package Alien::Base::ModuleBuild::Repository::Local;
use strict;
use warnings;
use Carp;
use File::chdir;
use File::Copy qw/copy/;
use Path::Tiny qw( path );
use parent 'Alien::Base::ModuleBuild::Repository';
# ABSTRACT: Local file repository handler
our $VERSION = '1.17'; # VERSION
sub is_network_fetch { 0 }
sub is_secure_fetch { 1 }
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
# make location absolute
local $CWD = $self->location;
$self->location("$CWD");
return $self;
}
sub list_files {
my $self = shift;
local $CWD = $self->location;
opendir( my $dh, $CWD);
my @files =
grep { ! /^\./ }
readdir $dh;
return @files;
}
sub get_file {
my $self = shift;
my $file = shift || croak "Must specify file to copy";
my $full_file = do {
local $CWD = $self->location;
croak "Cannot find file: $file" unless -e $file;
path($file)->absolute->stringify;
};
copy $full_file, $CWD;
return $file;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Base::ModuleBuild::Repository::Local - Local file repository handler
=head1 VERSION
version 1.17
=head1 SEE ALSO
=over 4
=item L<Alien>
=item L<Alien::Base>
( run in 2.054 seconds using v1.01-cache-2.11-cpan-119454b85a5 )