ADAMK-Release

 view release on metacpan or  search on metacpan

lib/ADAMK/Release.pm  view on Meta::CPAN

	unless ( $self->no_test ) {
		# Test the distribution normally
		$self->shell(
			qw{ ./Build disttest },
			'disttest failed',
		);
	}

	# Build the tardist
	$self->shell(
		qw{ ./Build dist },
		'Error making distribution tarball',
	);

	return;
}

sub upload {
	my $self = shift;

	my $pauseid = $self->prompt("PAUSEID:");
	unless (_STRING($pauseid) and $pauseid =~ /^[A-Z]{3,}$/) {
		$self->error("Missing or invalid PAUSEID");
	}

	my $password = $self->password("Password:");
	unless (_STRING($password) and $password =~ /^\S{5,}$/) {
		$self->error("Missing or invalid CPAN password");
	}

	# Execute the upload to CPAN
	CPAN::Uploader->upload_file( $self->dist_tardist, {
		user     => $pauseid,
		password => $password,
	});
}





######################################################################
# Content and Scanning Methods

# Get the main github repository url for this release
sub dist_resource_repository {
	my $self = shift;

	return join( '',
		"https://github.com/",
		$self->github->username,
		$self->github->repository,
		'.git',
	);
}

sub makefile_pl {
	my $self = shift;
	unless ( defined $self->{makefile_pl} ) {
		my $file = $self->dist_makefile_pl;
		return undef unless -f $file;
		$self->{makefile_pl} = File::Slurp::read_file($file);
	}
	return $self->{makefile_pl};
}

sub build_pl {
	my $self = shift;
	unless ( defined $self->{build_pl} ) {
		my $file = $self->dist_build_pl;
		return undef unless -f $file;
		$self->{build_pl} = File::Slurp::read_file($file);
	}
	return $self->{build_pl};
}

sub module_doc {
	my $self = shift;
	unless ( exists $self->{module_doc} ) {
		if ( -f $self->module_pod ) {
			$self->{module_doc} = $self->module_pod;
		} else {
			$self->{module_doc} = $self->module_pm;
		}
	}
	return $self->{module_doc};
}

sub module_version {
	my $self = shift;
	unless ( $self->{module_version} ) {
		my $file    = $self->module_pm;
		my $version = Module::Extract::VERSION->parse_version_safely($file);
		unless ( $version and $version ne 'undef' ) {
			return undef;
		}
		$self->{module_version} = $version;
	}
	return $self->{module_version};
}

sub find_ppport {
	File::Find::Rule->name('*.xs')->file->grep(qr/\bppport\.h\b/);
}

sub find_files {
	File::Find::Rule->file;
}

sub find_0644 {
	File::Find::Rule->name(qw{
		Changes
		Makefile.PL
		META.yml
		*.t
		*.pm
		*.pod
	} )->file;
}

sub find_executable {
	File::Find::Rule->name('*.exe')->not_executable->file;
}

sub find_localize {
	File::Find::Rule->file->not_binary->writable;
}

sub file_localize {
	File::LocalizeNewlines->new(
		filter  => $_[0]->find_localize,
		verbose => 1,
	);
}





######################################################################
# Paths and Files

sub dist {
	my $self   = shift;
	my $dist = $self->module;
	$dist =~ s/::/-/g;
	return $dist;
}

sub dist_dir {
	curdir();
}

sub dist_tardist {
	$_[0]->dist_file;

lib/ADAMK/Release.pm  view on Meta::CPAN

			"Failed to remove '$path'"
		);
	}
	return 1;
}

sub sudo {
	my $self    = shift;
	my $message = pop @_;
	my $cmd     = join ' ', @_;
	my $env     = $self->env(
		ADAMK_RELEASE     => 1,
		RELEASE_TESTING   => $ENV{RELEASE_TESTING}   ? 1 : 0,
		AUTOMATED_TESTING => $ENV{AUTOMATED_TESTING} ? 1 : 0,
	);
	print "> (sudo) $cmd\n" if $self->verbose;
	my $sudo = $self->bin_sudo;
	my $rv   = ! system( "$sudo bash -c '$env $cmd'" );
	if ( $rv or ! @_ ) {
		return $rv;
	}
	$self->error($message);
}

sub shell {
	my $self    = shift;
	my $message = pop @_;
	my $cmd     = join ' ', @_;
	my $env     = $self->env(
		ADAMK_RELEASE     => 1,
		RELEASE_TESTING   => $ENV{RELEASE_TESTING}   ? 1 : 0,
		AUTOMATED_TESTING => $ENV{AUTOMATED_TESTING} ? 1 : 0,
	);
	print "> $cmd\n" if $self->verbose;
	my $rv = ! system( "$env $cmd" );
	if ( $rv or ! @_ ) {
		return $rv;
	}
	$self->error($message);
}

sub env {
	my $self = shift;
	my %env  = @_;
	join ' ', map { "$_=$env{$_}" } sort keys %env;
}

sub error {
	my $self    = shift;
	my $message = sprintf(shift, @_);
	Carp::croak($message);
}

sub prompt {
	my $self = shift;
	return IO::Prompt::Tiny::prompt(@_);
}

sub password {
	my $self     = shift;
	my $password = undef;
	if ( defined $_[0] ) {
		print "$_[0] ";
	}
	eval {
		Term::ReadKey::ReadMode('noecho');
		$password = <STDIN>;
	};
	Term::ReadKey::ReadMode(0);
	return undef if not defined $password;
	chomp($password);
	return $password;
}

1;

__END__

=head1 NAME

ADAMK::Release - 

=head1 DESCRIPTION

C<ADAMK::Release> is the backend behind the C<adamk-release> script that
is used to build distribution tarballs for modules with the minimalist
repository style.

=head1 AUTHORS

Adam Kennedy E<lt>adamk@cpan.orgE<gt>

=head1 SEE ALSO

L<http://ali.as/>

=head1 COPYRIGHT

Copyright 2013 Adam Kennedy.

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

The full text of the license can be found in the
LICENSE file included with this module.



( run in 2.100 seconds using v1.01-cache-2.11-cpan-d80b1682f3f )