App-FuguWeb

 view release on metacpan or  search on metacpan

lib/App/FuguWeb/Config.pm  view on Meta::CPAN

my @PATH_SETTINGS = qw(out_dir source_dir module_root stylesheet);

# The three ways a page block names its content. Exactly one of them
# must appear.
my @PAGE_SOURCES = qw(body markdown index);

# App::FuguWeb::Config->load(%args):
#	root  => $dir		the project root (default: discover)
#	error => \$reason	where the failure message goes
#
#	Read and validate the description. The method returns the
#	object, or undef with the reason in $reason. Every message
#	names the file, and the block when a block is at fault.
#
#	The reason travels through a reference because the object that
#	would hold it does not exist when the load fails. The module
#	keeps no package state for it: two sites in one process must
#	not share a failure.
sub load ( $class, %args )
{
	my $reason = $args{error} // \my $ignored;

lib/App/FuguWeb/Config.pod  view on Meta::CPAN


    my $config = App::FuguWeb::Config->load(error => \my $reason)
        or die "$reason\n";

    say $config->site;
    say $_->{href} for $config->nav;
    say $_->{file} for $config->pages;

=head1 DESCRIPTION

The class reads F<.fuguwebrc>, applies the defaults, and validates the
result. The grammar, the quoting, and the yes/no spellings come from
L<Fugu::Config>; this class holds what is true of a site.

The object is immutable once loaded, and the module keeps no package
state. Two sites in one process therefore share nothing.

=head1 METHODS

=head2 load

    App::FuguWeb::Config->load(
        root  => $dir,          # default: discover
        error => \my $reason,
    )

Read and validate the description. The method returns the object, or
C<undef> with the reason in C<$reason>.

Without C<root>, the method walks up from the working directory to the
first directory that holds F<.fuguwebrc>, as C<fuguvm> finds
F<.fuguvmrc>.

The reason travels through a reference because the object that would
hold it does not exist when the load fails.

A load fails when the file is absent, when a line does not parse, or



( run in 0.641 second using v1.01-cache-2.11-cpan-d01c6094234 )