Newcomen

Description A static content generator.
Newcomen > Perl Modules > Newcomen::Source
Source

Index


NAME ^

Newcomen::Source - Represents a single data source of the project.

SYNOPSIS ^

use Newcomen::Source;

my $source = Newcomen::Source -> new (
   'creator' => $creator,
   'id'      => $source_id,
   'content' => $content,
);

# Set some meta data:
$source -> set (['some', 'data'], 'value');

DESCRIPTION ^

An Newcomen::Source instance represents a data source of the Newcomen project, including its content, and arbitrary meta data. See the developer section in Newcomen::Manual for a description of how Newcomen works and how Newcomen::Source fits in.

CLASS METHODS ^

new

my $source = Newcomen::Source -> new (
   'creator' => $creator,
   'id'      => $source_id,
   'content' => $content,
);

Constructor.

The creator parameter identifies the plugin that creates the source instance. It is suggested, though not required, to use the module name or module basename (i.e. the module name without the 'Newcomen::Plugin::' prefix).

The id parameter identifies the source. Usually this is the (relative or absolute) path of the file for sources on the file system. If the source is added to the crawler (Newcomen::Crawler), every source must have a unique ID.

Both the creator and id parameters are required, and these values can not be changed later on.

The optional content parameter may be used to set the initial content of the source item. If provided, it must be a string (or undef, if required). The content can be changed later on. If not provided, the initial value will be undef.

INSTANCE METHODS ^

General

creator, id

my $creator   = $source -> creator ();
my $source_id = $source -> id ();

Returns the creator ID, or the source ID, respectively. The values are set via the constructor (see new() above for a description), and can not be changed later on.

content

# Get the source's content:
my $content = $source -> content ();

# Set the content:
$source -> content ($content);

Getter/setter for the source's content. The parameter for the setter may be any string, or undef, if required. The content may also be set using the constructor, see new(). It is recommended to not change the content once it has been set, an Newcomen::Content instance should be created instead. See Newcomen::Manual for the general concepts behind these classes.

Meta Data

Meta data is stored in an Newcomen::Data instance.

delete, exists, get, set

The methods delete(), exists(), get() and set() are mapped to the Newcomen::Data methods of the same name, see there for details.

meta

my $meta = $source -> meta ();

Returns the Newcomen::Data instance storing the source's meta data.

SEE ALSO ^

Newcomen::Content, Newcomen::Crawler, Newcomen::Data, Newcomen::Manual

VERSION ^

This is version 2014052501.

AUTHOR ^

Stefan Goebel - newcomen {at} subtype {dot} de

COPYRIGHT AND LICENSE ^

Copyright 2013-2014 Stefan Goebel.

This file is part of Newcomen.

Newcomen is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the license, or (at your option) any later version.

Newcomen is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Newcomen. If not, see <http://www.gnu.org/licenses/>.