| Description | A static content generator. |

Newcomen::Core - Provides access to the different components of Newcomen.

use Newcomen::Core;
# Singleton access - create new or return existing instance:
my $core = Newcomen::Core -> instance ('config' => $config);
# Access the configuration:
$core -> config () -> get (['some', 'option']);
# Set global meta data:
$core -> set (['some', 'data'], 'value');
# Get the catalog instance:
my $catalog = $core -> catalog ();
The Newcomen::Core class glues together the different components of Newcomen. It is used as a singleton class, every plugin may retrieve the global core instance and thus get access to all the components. Additionally, Newcomen::Core provides a global meta data storage.
Plugins may use Newcomen::Role::Attribute::Core to access the core instance.

Toggle source: instance
sub instance {
my $package = shift;
my %options = @_;
my $instance = $options {'INSTANCE'} // 'DEFAULT';
# Creation of different instances disabled for now (remove this next line to enable it again):
$instance = 'DEFAULT';
delete $options {'INSTANCE'} if exists $options {'INSTANCE'};
unless (exists $package -> _instances () -> {$instance}) {
$package -> _instances () -> {$instance} = $package -> new (%options);
}
return $package -> _instances () -> {$instance};
}# First call, creating the instance:
my $core = Newcomen::Core -> instance ('config' => $config);
# All subsequent calls (e.g. from plugins):
my $core = Newcomen::Core -> instance ();Returns the global Newcomen::Core instance. The config parameter is only required the first time it is called (this happens internally in Newcomen), it has to be an Newcomen::Config instance. The core instance will be created when instance() is first called. Parameters will be ignored once the instance has been created.
Toggle source: clean_all
sub clean_all {
my $self = shift;
delete $self -> _instances () -> {$_} for keys %{ $self -> _instances () };
}Newcomen::Core -> clean_all ();
Deletes the instance if it exists. The next call to instance() will return a new Newcomen::Core instance.
Constructor. Not to be used directly, use instance() instead.

my $config = $core -> config (); my $crawler = $core -> crawler (); # ...
These methods return the Newcomen component of the same name, e.g. config() returns the Newcomen::Config instance, crawler() returns the Newcomen::Crawler instance etc. All of these will be instantiated by the core on first access to the component.
Arbitrary globally available data may be stored in the Newcomen::Core instance. The data will be stored in an Newcomen::Data instance. There is no initial meta data. The following methods are mapped to the Newcomen::Data methods of the same name and may be used to access the global data:
Please see Newcomen::Data's documentation for details.
my $data = $core -> global ();
This method will return the Newcomen::Data instance used as the global data storage.

Newcomen::Catalog, Newcomen::Config, Newcomen::Crawler, Newcomen::Data, Newcomen::Formatter, Newcomen::Plugins, Newcomen::Renderer, Newcomen::Role::Attribute::Core, Newcomen::Site, Newcomen::URL, Newcomen::Writer

This is version 2014052501.

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

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/>.