LCFG-Build-Skeleton

 view release on metacpan or  search on metacpan

lib/LCFG/Build/Skeleton.pm  view on Meta::CPAN


subtype 'LCFG::Types::Response'
  => as 'Str'
  => where { $_ eq 'yes' || $_ eq 'no' };

coerce 'LCFG::Types::Response' => from 'Str' =>
    via { $_ && ( $_ eq '1' || m/^ye(s|p|ah)!?$/i ) ? 'yes' : 'no' };

MooseX::Getopt::OptionTypeMap->add_option_type_to_map(
    'LCFG::Types::Response' => q{!}, );

has 'configfile' => (
    is        => 'ro',
    isa       => 'Str',
    default   => sub {
        my $class = shift;
        $class->_get_default_configfile if $class->can('_get_default_configfile');
    },
    predicate => 'has_configfile',
    documentation => 'Where defaults should be stored',
);

sub _get_default_configfile {
    my ($class) = @_;

    my $default = File::Spec->catfile( $ENV{HOME}, '.lcfg',
                                       'skeleton', 'defaults.yml' );

    return $default;
}

has 'tmpldir' => (
    is      => 'ro',
    isa     => 'Str',
    default => sub { File::Spec->catdir( $ENV{HOME}, '.lcfg',
                                         'skeleton', 'templates' ) },
    documentation => 'Local templates directory',
);

has 'name' => (
    is            => 'rw',
    isa           => 'LCFG::Types::ComponentName',
    documentation => 'Name of the project',
);

has 'abstract' => (
    is            => 'rw',
    isa           => 'Str',
    lazy          => 1,
    documentation => 'Short description of the project',
    default       => sub {
        $_[0]->lcfg_component eq 'yes'
            ? 'The LCFG ' . $_[0]->name . ' component'
            : q{};
    },
);

has 'author_name' => (
    is            => 'rw',
    isa           => 'Str',
    default       => sub { ( getpwuid $< )[6] },
    documentation => 'Name of the author',
);

has 'author_email' => (
    is            => 'rw',
    isa           => 'LCFG::Types::EmailAddress',
    builder       => '_default_email',
    documentation => 'Email address for the author',
);

sub _default_email {

    my $email;
    if ( $ENV{EMAIL} ) {
        $email = $ENV{EMAIL};
    } else {
        my $username = ( getpwuid $< )[0];

        my ( $hostname, @domain ) = split /\./, Sys::Hostname::hostname;

        my $domain = join q{.}, @domain;
        $email  = join q{@}, $username, $domain;
    }

    return $email;
}

has 'lang' => (
    is            => 'rw',
    isa           => enum( [qw/perl shell/] ),
    documentation => 'Language for component (perl/shell)',
    default       => 'perl',
);

has 'vcs' => (
    is            => 'rw',
    isa           => enum( [qw/SVN CVS None/] ),
    documentation => 'Version Control System (SVN/CVS/None)',
    default       => 'SVN',
);

has 'platforms' => (
    is            => 'rw',
    isa           => 'Maybe[Str]',
    documentation => 'Supported platforms',
);

has 'license' => (
    is            => 'rw',
    isa           => 'Str',
    documentation => 'Distribution license',
    default       => 'GPLv2',
);

has 'restart' => (
    is            => 'rw',
    isa           => 'LCFG::Types::Response',
    coerce        => 1,
    documentation => 'Restart component on RPM update (yes/no)',
    default       => 'yes',
);

has 'gencmake' => (
    is            => 'rw',
    isa           => 'LCFG::Types::Response',
    coerce        => 1,
    documentation => 'Use the CMake build system (yes/no)',
    default       => 'yes',
);

has 'genchangelog' => (
    is            => 'rw',
    isa           => 'LCFG::Types::Response',
    coerce        => 1,
    documentation => 'Generate the ChangeLog from the Revision-Control log? (yes/no)',
    default       => 'no',
);



( run in 2.842 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )