NAME

Yukki::Model::File - the model for loading and saving files in the wiki

VERSION

version 0.110850

SYNOPSIS

my $repository = $app->model('Repository', { repository => 'main' });
my $file = $repository->file({
    path     => 'foobar',
    filetype => 'yukki',
});

DESCRIPTION

Tools for fetching files from the git repository and storing them there.

EXTENDS

Yukki::Model

ATTRIBUTES

path

This is the path to the file in the repository, but without the file suffix.

filetype

The suffix of the file. Defaults to "yukki".

repository

This is the the Yukki::Model::Repository the file will be fetched from or stored into.

METHODS

BUILDARGS

Allows full_path to be given instead of path and filetype.

full_path

This is the complete path to the file in the repository with the "filetype" tacked onto the end.

file_name

This is the base name of the file.

file_id

This is a SHA-1 of the file name in hex.

object_id

This is the git object ID of the file blob.

title

This is the title for the file. For most files this is the file name. For files with the "yukki" "filetype", the title metadata or first heading found in the file is used.

file_size

This is the size of the file in bytes.

formatted_file_size

This returns a human-readable version of the file size.

media_type

This is the MIME type detected for the file.

store

$file->store({ 
    content => 'text to put in file...', 
    comment => 'comment describing the change',
});

# OR

$file->store({
    filename => 'file.pdf',
    comment  => 'comment describing the change',
});

This stores a new version of the file, either from the given content string or a named local file.

exists

Returns true if the file exists in the repository already.

fetch

my $content = $self->fetch;
my @lines   = $self->fetch;

Returns the contents of the file.

AUTHOR

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Qubling Software LLC.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.