NAME
Statocles::Store - The source for data documents and files
VERSION
version 0.098
DESCRIPTION
A Statocles::Store reads and writes documents and files (mostly pages).
This class also handles the parsing and inflating of "document objects".
Frontmatter Document Format
Documents are formatted with a YAML document on top, and Markdown content on the bottom, like so:
---
title: This is a title
author: preaction
---
# This is the markdown content
This is a paragraph
ATTRIBUTES
path
The path to the directory containing the documents.
document_extensions
An array of file extensions that should be considered documents. Defaults to "markdown" and "md".
METHODS
is_document
my
$bool
=
$store
->is_document(
$path
);
Returns true if the path looks like a document path (matches the "document_extensions").
has_file
my
$bool
=
$store
->has_file(
$path
)
Returns true if a file exists with the given path
.
write_file
$store
->write_file(
$path
,
$content
);
Write the given content
to the given path
. This is mostly used to write out page objects.
content
may be a simple string or a filehandle. If given a string, will write the string using UTF-8 characters. If given a filehandle, will write out the raw bytes read from it with no special encoding.
remove
$store
->remove(
$path
)
Remove the given path from the store. If the path is a directory, the entire directory is removed.
iterator
my
$iter
=
$store
->iterator;
Iterate over all the objects in this store. Returns an iterator that will yield a Statocles::Document object or a Statocles::File object.
Hidden files and folders are automatically ignored by this method.
my
$iter
=
$store
->iterator;
while
(
my
$obj
=
$iter
->() ) {
if
(
$obj
->isa(
'Statocles::Document'
) ) {
...;
}
else
{
...;
}
}
AUTHOR
Doug Bell <preaction@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.