NAME

CBAIS::Actions::Append - append text to a file


SYNOPSIS

$append = new CBAIS::Actions::Append(FILE => '/etc/system', CLASS => 'TestClass');

if ($append->execute()) { print ``appended data to file /etc/system\n''; }

if ($append->undo()) { print ``undo appended data to file /etc/system\n''; }


DESCRIPTION

The CBAIS::Actions::Append class implements a CBAIS action which appends text to files. Appends are redoable (as long as the file being appended to has a comment character (string) defined). If a file does not exist it is created.

The souce file is searched for using a FileLocator. The default semantics are for a host specific file (suffix specifiers). See the CBAIS::Path::FileLocator manpage for more information.


METHODS

new

The constructor. The following hash keys are required to be passed.

FILE
the file to append to e.g. /etc/system.

CLASS
the CBAIS class this action is defined as part of.

The following keys are optional.

COMMENT
the char(s) to use for a comment in the file we are appending to. If not defined defaults to a ``#''

The following keys are  deduced.

SOURCE
host specific source file conaining the text to be appended.

WRAPPER_PATTERN
regexp which is used to match wrapper patterns. It is defined as ``</?CBAIS -%- $this->{CLASS}.Append>'', with the optional / marking the beginning/ending of an append section.

check

Check this action can execute. The existance of the source file is checked, its readability and whether it is a text file.

execute

execute this append.

verify

This method verifies that an append has taken place and the contents of the append file are up to date.

undo

undo an append which has been made to a file. The file is parsed and checked for the append text of aprevious append. If found the text is removed.