App-Aphra

 view release on metacpan or  search on metacpan

lib/App/Aphra.pm  view on Meta::CPAN

    ],
    VARIABLES    => {
      site => $self->site_vars,
    },
    INCLUDE_PATH => $self->include_path,
    OUTPUT_PATH  => $self->config->{target},
    WRAPPER      => $self->config->{wrapper},
  );
}

sub run {
  my $self = shift;

  $self->config;

  @ARGV or die "Must give a command\n";

  my $cmd = shift @ARGV;

  if (my $method = $self->commands->{$cmd}) {
    $self->$method;
  } else {
    die "$cmd is not a valid command\n";
  }
}

sub build {
  my $self = shift;

  my $src = $self->config->{source};

  -e $src or die "Cannot find $src\n";
  -d $src or die "$src is not a directory\n";

  find({ wanted => $self->_make_do_this, no_chdir => 1 },
       $self->config->{source});
}

sub _make_do_this {
  my $self = shift;

  return sub {
    return unless -f;

    my $f = App::Aphra::File->new({
      app => $self, filename => $_,
    });

    $f->process;
  };
}

sub serve {
  my $self = shift;

  require App::HTTPThis;
  if ($@) {
    croak "App::HTTPThis must be installed for 'serve' command";
  }

  local @ARGV = $self->config->{target};
  App::HTTPThis->new->run;
}

sub version {
  my $me = basename $0;
  say "\n$me version: $VERSION\n";
}

sub help {
  my $self = shift;
  my $me = basename $0;
  $self->version;

  say <<ENDOFHELP;
$me is a simple static sitebuilder which uses the Template Toolkit to
process input templates and turn them into a web site.
ENDOFHELP
}

__PACKAGE__->meta->make_immutable;

1;

=head1 AUTHOR

Dave Cross <dave@perlhacks.com>

=head1 COPYRIGHT AND LICENCE

Copyright (c) 2017-2023, Magnum Solutions Ltd. All Rights Reserved.

This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=cut

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.694 second using v1.00-cache-2.02-grep-82fe00e-cpan-cec75d87357c )