The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Document::Object

SYNOPSIS

my $doc = new Document::Object;

$doc->state($state);

my $cid = $doc->comment( undef, { author => "Me", subject => "My Subject", text => "Comment to be appended" } ); my @comments = $doc->comment(); my $comment = $doc->comment(42);

my $text = $doc->diff($revA, $revB);

my $wid = $doc->watcher( undef, { name => "Me", email => "myself@mydomain.com" } );

DESCRIPTION

This class encapsulates information about a generic document and operations for altering its properties. A document is assumed to be a collection of one or more files, with metadata.

FUNCTIONS

new(%args)

Creates a new document object. Accepts the following arguments in %args:

 repository - a valid Document::Repository object

 doc_id - the integer document ID this object represents

get_error()

Returns the most recent error message as a string. Returns undef or a blank string if no error has been logged.

log($comment)

Gets or adds comments in change log. Returns undef on error.

content($filename[, $content])

Retrieves the contents of a file in the document from the document repository, or, if $content is defined, stores the content into the file.

Returns undef on error and logs an error message that can be retrieved via get_error().

state([$state])

Gets or sets the state of the document. The following states are valid:

 new
 open
 accepted
 rejected
 broken
 retired

If a state not in this list is used, the function will return undef and log an error.

If called with no argument, returns the current state.

get_properties()

Returns a hash of all properties for the document.

set_properties(%properties)

Updates general properties about the document. Accepts a hash of key/value pairs corresponding to properties to set. Only properties provided as arguments will be updated; other properties will be left unchanged.

Returns a hash of all properties for the document.

get_property()

Retrieves the value of one property of the document.

get_keywords()

Returns an array of the keywords for this document.

set_keywords(@keywords)

Replaces the keywords for the document with those specified.

add_keywords

Adds the given keywords to the document. This does not remove any existing keywords, but it does check to make sure we're not adding any that are already included. All added keywords are changed to lowercase, have any ';' characters changed into ',' and leading and trailing space is trimmed off.

remove_keywords

Deletes the given keywords from the document. This operates in a case insensitive manner.

comment([$cid], [$comment])

Gets or sets the comment information for a given comment ID $cid, or adds a new $comment if $cid is not defined, or returns all of the comments as an array if neither parameter is specified.