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

NAME

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

VERSION

version 0.111060

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.

history

  my @revisions = $self->history;

Returns a list of revisions. Each revision is a hash with the following keys:

object_id

The object ID of the commit.

author_name

The name of the commti author.

date

The date the commit was made.

time_ago

A string showing how long ago the edit took place.

comment

The comment the author made about the comment.

lines_added

Number of lines added.

lines_removed

Number of lines removed.

diff

  my @chunks = $self->diff('a939fe...', 'b7763d...');

Given two object IDs, returns a list of chunks showing the difference between two revisions of this path. Each chunk is a two element array. The first element is the type of chunk and the second is any detail for that chunk.

The types are:

    "+"    This chunk was added to the second revision.
    "-"    This chunk was removed in the second revision.
    " "    This chunk is the same in both revisions.

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.