NAME
File::Sticker::Scribe::YamlPrefix - write and standardize meta-data from YAML file
VERSION
version 4.00
SYNOPSIS
use File::Sticker::Scribe::YamlPrefix;
my $obj = File::Sticker::Scribe::YamlPrefix->new(%args);
my %meta = $obj->read_meta($filename);
$obj->write_meta(%args);
DESCRIPTION
This will read and write meta-data from plain text files where the first part of the file contains YAML data, set up as if it is a YAML stream. That is, the file starts with '---' on one line, then there is YAML data, then there is another '---' line, and all content after that is ignored. Then it will standardize it to a common nomenclature, such as "tags" for things called tags, or Keywords or Subject etc.
This format can be useful as a way of storing meta-data in documents or in wiki pages.
DEBUGGING
whoami
Used for debugging info
METHODS
priority
The priority of this scribe. Scribes with higher priority get tried first.
allowed_file
If this scribe can be used for the given file, then this returns true. File must be plain text and NOT end with '.yml' If the file does not exist, it cannot be written to. If it does exist, the YAML-prefix area must exist also.
allowed_fields
If this scribe can be used for the known and wanted fields, then this returns true. For YAML, this always returns true.
if ($scribe->allowed_fields())
{
....
}
known_fields
Returns the fields which this scribe knows about. This scribe has no limitations.
my $known_fields = $scribe->known_fields();
read_meta
Read the meta-data from the given file.
my $meta = $obj->read_meta($filename);
delete_field_from_file
Completely remove the given field. This does no checking for multi-valued fields, it just deletes the whole thing.
$scribe->delete_field_from_file(filename=>$filename,field=>$field);
replace_all_meta
Overwrite the existing meta-data with that given.
(This supercedes the parent method because we can do it more efficiently this way)
$scribe->replace_all_meta(filename=>$filename,meta=>\%meta);
replace_one_field
Overwrite the given field. This does no checking.
$scribe->replace_one_field(filename=>$filename,field=>$field,value=>$value);
Helper Functions
Private interface.
_has_yaml
The file has YAML if the FIRST line is '---'
_yaml_and_more
Get the YAML part of the file (if any) by reading the stuff between the first set of --- lines and also the rest of the file as a separate part.
_load_meta
Quick non-checking loading of the meta-data. Does not standardize any fields.
_write_meta
Overwrites the file completely with the given metadata plus the rest of its contents This saves multi-value comma-separated fields as arrays.
BUGS
Please report any bugs or feature requests to the author.