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

NAME

Giddy::Database - A Giddy database.

VERSION

version 0.013_001

SYNOPSIS

        my $db = $giddy->get_database('/path/to/database');

DESCRIPTION

This class represents Giddy databases. Aside from providing you with the ability to create and get collections from the database, it provides methods which are global to the database, like commit changes, undoing changes, etc.

CONSUMES

ATTRIBUTES

_repo

A Git::Repository object, tied to the git repository of the Giddy database. This is a required attribute. Not meant to be used externally, but knock yourself out if you feel the need to run specific Git commands.

_staged

A list of paths staged (added) to the next commit job. Automatically created.

OBJECT METHODS

get_collection( [ $path_to_coll ] )

Returns a Giddy::Collection object tied to a certain directory in the database. If a path is not provided, the root collection ('') will be used. If the collection does not exist, Giddy will attempt to create it. The path provided has to be relative to the database's full path, with no starting slash.

commit( [$commit_msg] )

Commits all pending changes with a commit message. If not provided, Giddy will use a default commit message listing the number of changes performed.

stage( @paths )

Marks files/directories as to be staged. Mostly called automatically by new_collection(), new_document(), etc., but you can use it if you need to. Paths are relative to database's path and should not contain starting slashes.

find( [ $path, [\%options] ] )

Searches the Giddy repository for documents that match the provided path. The path has to be relative to the repository's root directory, which is considered the empty string. This string will be used if $path is not provided. This is a convenience method for finding documents by path. See Giddy::Collection and "FULL PATH FINDING" in Giddy::Manual for more information.

find_one( [ $path, \%options ] )

Same as calling find($path, $options)->first().

undo( [ $num ] )

undo( $commit_checksum )

Cancels the $numth latest commit performed (if $num is 0 or not passed, the latest commit is cancelled). Any changes performed by the commit cancelled are forever lost. If a commit numbered $num isn't found, this method will croak. You can also provide a specific commit SHA-1 checksum to cancel.

For an alternative that doesn't lose information, see revert().

revert( [ $num ] )

revert( $commit_checksum )

Reverts the database back to the commit just before the commit performed $numth commits ago and creates a new commit out of it. In other words, a snapshot of the database from the source commit (performed $num + 1 commits ago) will be taken and used to replace the database's current state. Then, a new commit is performed. Thus, the changes performed between the source commit and the current commit are preserved in the log. This is different than undo(), which completely removes all commits performed between the source commit and the current commit. Actually, a revert can be cancelled by an undo() operation, as it is a commit in itself.

$num will be zero by default, in which case the latest commit is reverted.

If a commit numbered $num isn't found, this method will croak.

You can also provide a specific commit SHA-1 checksum.

log( [ $num ] )

If $num is provided (can be zero), will return a Git::Repository::Log object of the commit performed $num commits ago. So 0 will return the latest commit.

If num isn't provided, will return a Git::Repository::Log::Iterator object starting from the latest commit.

AUTHOR

Ido Perlmuter, <ido at ido50.net>

BUGS

Please report any bugs or feature requests to bug-giddy at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Giddy. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

        perldoc Giddy::Database

You can also look for information at:

LICENSE AND COPYRIGHT

Copyright 2011 Ido Perlmuter.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.