NAME

VariableSet - class representing sets of session variables

AUTHOR

Steven J. McDowall <sjm@aptest.com>

COPYRIGHT

Copyright 2002-2011 Applied Testing and Technology, Inc. All Rights Reserved.

SYNOPSIS

use VariableSet;

    # create a new VariableSet object
    my $variables = new VariableSet;

    # read the set from a file
    $variables->fromFile( Config::SITE::VariableFile);

The VariableSet object is a handy container object used to track/read/manipulate a suite's variable definitions into a memory data structure.

FILE FORMAT

The format of a variable definition file is a whitespace separated collection of fields, one record per row, with the first row of the file being a definition of the field names. In this case, the fields in the file are:

NAME

the name of the variable

TYPE

the type of the variable: one of text, textbox, single, multiple, derived, or separator

FLAGS

a comma separated list of options for this variable. Flags vary by type, and are documented in the ApTest Manager User's Guide.

SIZE

the size of the input field when presenting to the user

PROMPT

the prompt to use when asking for a value from the user

VALUES

a comma separated list of potential values for this variable (if it is a single or multiple), and a default value to use for text or textbox. If it is a comma separated list, items starting with an asterisk are "defaults" for the item.

METHODS

new - create a new, unpopulated variable set object

$set = new VariableSet( suite [, template [, path [, noLocalVars ] ] ] ) ;

Creates a new VariableSet object, optionally reading in the base definition from a file.

suite is the name of the test suite to operate on. If not defined, then operate on a template.

template is the name of the template to operate upon.

path is an optional path to the suite / template. Used for testing.

noLocalVars is a boolean. If defined and true, then do not load and variable definitions from the file VARIABLES.local. Defaults to false (do load the local variables).

returns a reference to the VariableSet object.

release - release the variable set

$set->release();

toFile - output the "compiled" variable set structure

$set->toFile( filename ) ;

print - print the contents of the variable set

$set->print();

fromFile - read in the variable definitions from a file..

$set->fromFile(fileName);

loadAccountDefaults - reads in, evals, and sets default values from a file.

$set->loadAccountDefaults( vendor ) ;

addHeader - adds a new header

Adds a new header entry into the set and marks it as the current header for future variable adds.

$set->addHeader( $id, $title) ;

$id - the title identifer

$title - the text to display

addVariable - add a new variable

Adds a new variable to the set.

$set->addVariable( $varRef );

$varRef - a reference to a Variable object.

currentHeader - return the current variable header

my $header = $set->currentHeader();

getVarByName - find and return a Variable object given its id

my $var = $set->getVarByName( $id ) ;

countVars - count the number of variables

my $count = $set->countVars();

countHeaders - count the number of headers

my $count = $set->countHeaders();

countSessionVars - count the number of session variables

my $count = $set->countSessionVars();

getVarHash - get the hash of Variable objects

my $hash = $set->getVarHash();

getHeaderArray - get an arrayref of headers

my $headers = $set->getHeaderArray();

sessionVarList - get a list of variables

my $list = $set->sessionVarList();

suiteDir - accessor for test suite root

my $dir = $set->suiteDir();
    $set->suiteDir( $suite );

Gets/sets the path to the test suite data root.

visibleList - return a list of visible fields

@vlist = $vars->visibleList( [$includeSpecials [, sortIt] ] ) ;

includeSpecials is a boolean that defaults to false. If true, then the reserved atm special session variables are also included.

sortit is a boolean that indicates whether the results should be alphabetically sorted or not. The default is to NOT sort the results.

javaScriptDependencies - set up depends for JS functions

$jsInit = $set->javaScriptDependencies(showMandatory);

showMandatory is a boolean indicating whether to show which fields are mandatory or not. Defaults to true.

Returns a set of javascript declarations that match the dependencies among fields in a session.

VariableSet::Header

NAME

VariableSet::Header - class representing section headers

METHODS

new - create a new VariableSet::Header object

my $header = VariableSet::Header->new( $id, $title );

id - get the header ID

my $id = $header->id();

title - get the header title

my $title = $header->title();

variableList - get the list of variables under a header

my $list = $header->variableList();

Copyright © 2000-2013 Applied Testing and Technology, Inc. All rights reserved.