Perl::Dist::WiX::Asset::File - "Single File" asset for a Win32 Perl


Perl-Dist-WiX documentation Contained in the Perl-Dist-WiX distribution.

Index


Code Index:

NAME

Top

Perl::Dist::WiX::Asset::File - "Single File" asset for a Win32 Perl

SYNOPSIS

Top

  my $binary = Perl::Dist::Asset::File->new(
      url        => 'http://host/path/file',
      install_to => 'perl/foo.txt',
  );

DESCRIPTION

Top

Perl::Dist::Asset::File is a data class that provides encapsulation and error checking for a single file to be installed unmodified into a Perl::Dist::WiX-based Perl distribution.

It is normally created on the fly by the <Perl::Dist::WiX> install_file method (and other things that call it).

This asset exists to allow for cases where very small tweaks need to be done to distributions by dropping in specific single files.

The specification of the location to retrieve the package is done via the standard mechanism implemented in Perl::Dist::WiX::Role::Asset.

METHODS

Top

This class is a Perl::Dist::WiX::Role::Asset and shares its API.

new

The new constructor takes a series of parameters, validates then and returns a new Perl::Dist::WiX::Asset::File object.

It inherits all the params described in the Perl::Dist::WiX::Role::Asset new method documentation, and adds some additional params.

install_to

The required install_to param describes the location that the package will be installed to.

The install_to param should be a simple string that represents the entire destination path (including file name).

The new constructor returns a Perl::Dist::Asset::WiX::File object, or throws an exception (dies) if an invalid param is provided.

install

The install method installs the file in the specified place.

SUPPORT

Top

Bugs should be reported via the CPAN bug tracker at

http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Perl-Dist-WiX

For other issues, contact the author.

AUTHOR

Top

Curtis Jewell <csjewell@cpan.org>

SEE ALSO

Top

Perl::Dist::WiX, Perl::Dist::Asset

COPYRIGHT AND LICENSE

Top


Perl-Dist-WiX documentation Contained in the Perl-Dist-WiX distribution.

package Perl::Dist::WiX::Asset::File;

use 5.008001;
use Moose;
use MooseX::Types::Moose qw( Str );
use File::Spec::Functions qw( catfile );
require File::Remove;
require File::List::Object;

our $VERSION = '1.102';
$VERSION =~ s/_//ms;

with 'Perl::Dist::WiX::Role::Asset';

has install_to => (
	is       => 'ro',
	isa      => Str,
	reader   => '_get_install_to',
	required => 1,
);

sub install {
	my $self = shift;

	my $download_dir = $self->_get_download_dir();
	my $image_dir    = $self->_get_image_dir();
	my @files;


	# Get the file
	my $tgz = $self->_mirror( $self->_get_url, $download_dir );

	# Copy the file to the target location
	my $from = catfile( $download_dir, $self->_get_file );
	my $to   = catfile( $image_dir,    $self->_get_install_to );
	unless ( -f $to ) {
		push @files, $to;
	}

	$self->_copy( $from => $to );

	# Clear the download file
	File::Remove::remove( \1, $tgz );

	my $filelist =
	  File::List::Object->new->load_array(@files)
	  ->filter( $self->_filters );

	return $filelist;
} ## end sub install

no Moose;
__PACKAGE__->meta->make_immutable;

1;

__END__