PITA::XML::Platform - Data object representing a platform configuration


PITA-XML documentation Contained in the PITA-XML distribution.

Index


Code Index:

NAME

Top

PITA::XML::Platform - Data object representing a platform configuration

SYNOPSIS

Top

  # Create a platform configuration
  my $platform = PITA::XML::Platform->new(
      scheme => 'perl5',
      path   => '/usr/bin/perl',
      env    => \%ENV,
      config => \%Config::Config,
  );

  # Get the current perl5 platform configuration
  my $current = PITA::XML::Platform->autodetect_perl5;

DESCRIPTION

Top

PITA::XML::Platform is an object for holding information about the platform that a package is being tested on

It can be created either as part of the parsing of a PITA::XML file, or if you wish you can create one from the local system configuration.

Primarily it just holds information about the host's environment and the Perl configuration.

METHODS

Top

As the functionality for PITA::XML is still in flux, the methods will be documented once we stop changing them daily :)

SUPPORT

Top

Bugs should be reported via the CPAN bug tracker at

http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PITA-XML

For other issues, contact the author.

AUTHOR

Top

Adam Kennedy <adamk@cpan.org>, http://ali.as/

SEE ALSO

Top

PITA::XML

The Perl Image-based Testing Architecture (http://ali.as/pita/)

COPYRIGHT

Top


PITA-XML documentation Contained in the PITA-XML distribution.
package PITA::XML::Platform;

use 5.005;
use strict;
use Carp         ();
use Params::Util qw{ _STRING _HASH };

use vars qw{$VERSION};
BEGIN {
	$VERSION = '0.51';
}





#####################################################################
# Constructor and Accessors

sub new {
	my $class = shift;
	my $self  = bless { @_ }, $class;

	# Check the object
	$self->_init;

	$self;
}

sub autodetect_perl5 {
	my $class = shift;

	# Source the information
	my $path = $^X;
	require Config;

	# Hand it off to the constructor
	$class->new(
		scheme => 'perl5',
		path   => $path,
		env    => { %ENV },            # Only provide a copy
		config => { %Config::Config }, # Only provide a copy
	);
}

# Format-check the parameters
sub _init {
	my $self = shift;

	# Check the platform scheme
	unless ( PITA::XML->_SCHEME($self->scheme) ) {
		Carp::croak('Invalid or missing platform testing scheme');
	}

	# Check the path we used
	unless ( _STRING($self->path) ) {
		Carp::croak('Invalid or missing scheme path');
	}

	# Check we have an environment
	unless ( _HASH($self->env) ) {
		Carp::croak('Invalid, missing, or empty environment');
	}

	# Check we have a config
	unless ( _HASH($self->config) ) {
		Carp::croak('Invalid, missing, or empty config');
	}

	$self;
}

sub scheme {
	$_[0]->{scheme};
}

sub path {
	$_[0]->{path};
}

sub env {
	$_[0]->{env};
}

sub config {
	$_[0]->{config};
}

1;