Ado
view release on metacpan or search on metacpan
lib/Ado/Build.pm view on Meta::CPAN
package Ado::Build;
use 5.014;
use strict;
use warnings FATAL => 'all';
use File::Spec::Functions qw(catdir catfile);
use File::Path qw(make_path);
use File::Copy qw(copy);
use ExtUtils::Installed;
use ExtUtils::Install;
use parent 'Module::Build';
use Exporter qw( import ); #export functionality to Ado::BuildPlugin etc..
our @EXPORT_OK = qw(
create_build_script process_etc_files do_create_readme
process_public_files process_templates_files
ACTION_perltidy ACTION_submit PERL_DIRS);
sub PERL_DIRS {
state $dirs = [map { catdir($_[0]->base_dir, $_) } qw(bin lib etc t)];
return @$dirs;
}
sub create_build_script {
my $self = shift;
#Deciding where to install
my $prefix = $self->install_base || $self->config('siteprefix');
for my $be (qw(etc public log templates)) {
#in case of installing a plugin, check if folder exists
next unless -d $be;
$self->add_build_element($be);
$self->install_path($be => catdir($prefix, $be));
}
return $self->SUPER::create_build_script();
}
sub process_public_files {
my $self = shift;
for my $asset (@{$self->rscan_dir('public')}) {
if (-d $asset) {
make_path(catdir('blib', $asset));
next;
}
copy($asset, catfile('blib', $asset));
}
return;
}
sub process_etc_files {
my $self = shift;
my $prefix = $self->install_base || $self->config('siteprefix');
my $mode = $ENV{MOJO_MODE} ||= 'development';
for my $asset (@{$self->rscan_dir('etc')}) {
if (-d $asset) {
make_path(catdir('blib', $asset));
next;
}
# skip SQLite automatically created files
next if ($asset =~ m/ado\-(shm|wal)/);
my $asset_path = catfile($prefix, $asset);
if ($asset =~ m/ado\.sqlite/ && -s $asset_path) {
$self->log_info("Skipping $asset because it already exists at $asset_path! $/");
next;
}
copy($asset, catfile('blib', $asset));
}
return;
}
sub process_log_files {
my $self = shift;
for my $asset (@{$self->rscan_dir('log')}) {
if (-d $asset) {
make_path(catdir('blib', $asset));
next;
}
( run in 1.769 second using v1.01-cache-2.11-cpan-437f7b0c052 )