Module-Provision
view release on metacpan or search on metacpan
lib/Module/Provision/Base.pm view on Meta::CPAN
package Module::Provision::Base;
use namespace::autoclean;
use Class::Usul::Constants qw( EXCEPTION_CLASS NUL SPC TRUE );
use Class::Usul::Functions qw( app_prefix class2appdir classdir
distname first_char io is_arrayref throw );
use Class::Usul::Time qw( time2str );
use CPAN::Meta;
use English qw( -no_match_vars );
use File::DataClass::Types qw( ArrayRef Directory HashRef NonEmptySimpleStr
Object OctalNum Path PositiveInt
SimpleStr Undef );
use Module::Metadata;
use Perl::Version;
use Try::Tiny;
use Type::Utils qw( enum );
use Unexpected::Functions qw( Unspecified );
use Moo;
use Class::Usul::Options;
extends q(Class::Usul::Programs);
my %BUILDERS = ( 'DZ' => 'dist.ini', 'MB' => 'Build.PL', );
my $BUILDER = enum 'Builder' => [ qw( DZ MB ) ];
my $VCS = enum 'VCS' => [ qw( git none svn ) ];
# Override defaults in base class
has '+config_class' => default => sub { 'Module::Provision::Config' };
# Object attributes (public)
# Visible to the command line
option 'base' => is => 'lazy', isa => Path, format => 's',
documentation => 'Directory containing new projects',
builder => sub { $_[ 0 ]->config->base }, coerce => TRUE;
option 'branch' => is => 'lazy', isa => SimpleStr, format => 's',
documentation => 'The name of the initial branch to create', short => 'b';
option 'builder' => is => 'lazy', isa => $BUILDER, format => 's',
documentation => 'Which build system to use: DZ or MB';
option 'license' => is => 'ro', isa => NonEmptySimpleStr, format => 's',
documentation => 'License used for the project',
builder => sub { $_[ 0 ]->config->license };
option 'perms' => is => 'ro', isa => OctalNum, format => 'i',
documentation => 'Default permission for file / directory creation',
default => '640', coerce => TRUE;
option 'plugins' => is => 'ro', isa => ArrayRef[NonEmptySimpleStr],
documentation => 'Name of optional plugins to load, comma separated list',
builder => sub { [] }, format => 's', short => 'M',
coerce => sub { (is_arrayref $_[ 0 ])
? $_[ 0 ] : [ split m{ , }mx, $_[ 0 ] ] };
option 'project' => is => 'lazy', isa => NonEmptySimpleStr, format => 's',
documentation => 'Package name of the new projects main module';
option 'repository' => is => 'ro', isa => NonEmptySimpleStr, format => 's',
documentation => 'Directory containing the SVN repository',
builder => sub { $_[ 0 ]->config->repository };
option 'vcs' => is => 'lazy', isa => $VCS, format => 's',
documentation => 'Which VCS to use: git, none, or svn';
# Ingnored by the command line
has 'appbase' => is => 'lazy', isa => Path, coerce => TRUE;
has 'appldir' => is => 'lazy', isa => Path, coerce => TRUE;
has 'branch_file' => is => 'lazy', isa => Path, coerce => TRUE,
builder => sub { [ $_[ 0 ]->appbase, '.branch' ] };
has 'binsdir' => is => 'lazy', isa => Path, coerce => TRUE,
builder => sub { [ $_[ 0 ]->appldir, 'bin' ] };
has 'default_branch' => is => 'lazy', isa => SimpleStr;
has 'dist_module' => is => 'lazy', isa => Path, coerce => TRUE,
builder => sub { [ $_[ 0 ]->homedir.'.pm' ] };
has 'dist_version' => is => 'lazy', isa => Object, clearer => TRUE;
has 'distname' => is => 'lazy', isa => NonEmptySimpleStr,
builder => sub { distname $_[ 0 ]->project };
has 'exec_perms' => is => 'lazy', isa => PositiveInt;
has 'homedir' => is => 'lazy', isa => Path, coerce => TRUE;
has 'incdir' => is => 'lazy', isa => Path, coerce => TRUE,
builder => sub { [ $_[ 0 ]->appldir, 'inc' ] };
has 'initial_wd' => is => 'ro', isa => Directory,
builder => sub { io()->cwd };
has 'libdir' => is => 'lazy', isa => Path, coerce => TRUE,
builder => sub { [ $_[ 0 ]->appldir, 'lib' ] };
has 'license_keys' => is => 'lazy', isa => HashRef;
has 'manifest_paths' => is => 'lazy', isa => ArrayRef, init_arg => undef;
has 'module_abstract' => is => 'lazy', isa => NonEmptySimpleStr;
has 'module_metadata' => is => 'lazy', isa => Object | Undef, builder => sub {
Module::Metadata->new_from_file
( $_[ 0 ]->dist_module->abs2rel( $_[ 0 ]->appldir ), collect_pod => 1 ) },
clearer => TRUE;
( run in 2.314 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )