Dist-Man
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Dist/Man/Simple.pm view on Meta::CPAN
=head2 C<< create_distro(%args) >>
This method works as advertised in L<Dist::Man>.
=cut
sub create_distro {
my $class = shift;
my $self = $class->new( @_ );
my $modules = $self->{modules} || [];
my @modules = map { split /,/ } @{$modules};
croak "No modules specified.\n" unless @modules;
for (@modules) {
croak "Invalid module name: $_" unless /\A[a-z_]\w*(?:::[\w]+)*\Z/i;
}
croak "Must specify an author\n" unless $self->{author};
croak "Must specify an email address\n" unless $self->{email};
($self->{email_obfuscated} = $self->{email}) =~ s/@/ at /;
$self->{license} ||= 'perl';
$self->{main_module} = $modules[0];
if ( not $self->{distro} ) {
$self->{distro} = $self->{main_module};
$self->{distro} =~ s/::/-/g;
}
$self->{basedir} = $self->{dir} || $self->{distro};
$self->create_basedir;
my @files;
push @files, $self->create_modules( @modules );
push @files, $self->create_t( @modules );
push @files, $self->create_ignores;
my %build_results = $self->create_build();
push(@files, @{ $build_results{files} } );
push @files, $self->create_Changes;
push @files, $self->create_README( $build_results{instructions} );
push @files, 'MANIFEST';
$self->create_MANIFEST( grep { $_ ne 't/boilerplate.t' } @files );
return;
}
=head2 C<< new(%args) >>
This method is called to construct and initialize a new Dist::Man object.
It is never called by the end user, only internally by C<create_distro>, which
creates ephemeral Dist::Man objects. It's documented only to call it to
the attention of subclass authors.
=cut
sub new {
my $class = shift;
return bless { @_ } => $class;
}
=head1 OBJECT METHODS
All the methods documented below are object methods, meant to be called
internally by the ephemperal objects created during the execution of the class
method C<create_distro> above.
=head2 create_basedir
Creates the base directory for the distribution. If the directory already
exists, and I<$force> is true, then the existing directory will get erased.
If the directory can't be created, or re-created, it dies.
=cut
sub create_basedir {
my $self = shift;
# Make sure there's no directory
if ( -e $self->{basedir} ) {
die( "$self->{basedir} already exists. ".
"Use --force if you want to stomp on it.\n"
) unless $self->{force};
local @ARGV = $self->{basedir};
rm_rf();
die "Couldn't delete existing $self->{basedir}: $!\n"
if -e $self->{basedir};
}
CREATE_IT: {
$self->progress( "Created $self->{basedir}" );
local @ARGV = $self->{basedir};
mkpath();
die "Couldn't create $self->{basedir}: $!\n" unless -d $self->{basedir};
}
return;
}
=head2 create_modules( @modules )
This method will create a starter module file for each module named in
I<@modules>.
=cut
sub create_modules {
my $self = shift;
my @modules = @_;
my @files;
for my $module ( @modules ) {
my $rtname = lc $module;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.328 second using v1.00-cache-2.02-grep-82fe00e-cpan-b63e86051f13 )