Module::Release::PAUSE - Interact with the Perl Authors Upload Server (PAUSE)


Module-Release documentation Contained in the Module-Release distribution.

Index


Code Index:

NAME

Top

Module::Release::PAUSE - Interact with the Perl Authors Upload Server (PAUSE)

SYNOPSIS

Top

The release script automatically loads this module if it thinks that you want to upload to PAUSE by noticing the cpan_user configuration directive.

DESCRIPTION

Top

set_pause_ftp_site( HOSTNAME )

Set the name of the PAUSE FTP site. If you pass it something that doesn't look like a host name, it warns and doesn't set anything.

pause_ftp_site

Return the hostname for PAUSE uploads.

should_upload_to_pause

Returns true is the object thinks it should upload a distro to PAUSE.

pause_claim

Claim the file in PAUSE

pause_claim_base_url

The base URL to claim something in PAUSE. This is https://pause.perl.org/pause/authenquery.

XXX: This should read from pause_ftp_site probably

pause_claim_content

Construct the data for the POST request to claim a file in PAUSE.

pause_claim_content_type

The content type for the POST request to claim a file in PAUSE. This is application/x-www-form-urlencoded.

SEE ALSO

Top

Module::Release

SOURCE AVAILABILITY

Top

This source is in Github:

	git://github.com/briandfoy/module-release.git

AUTHOR

Top

brian d foy, <bdfoy@cpan.org>

COPYRIGHT AND LICENSE

Top


Module-Release documentation Contained in the Module-Release distribution.
package Module::Release::PAUSE;

use strict;
use warnings;
use base qw(Exporter);
use vars qw($VERSION);

our @EXPORT = qw(
	pause_ftp_site should_upload_to_pause pause_claim set_pause_ftp_site
	pause_claim_base_url pause_claim_content pause_claim_content_type
	);

$VERSION = '2.05';

sub set_pause_ftp_site
	{
	no warnings 'uninitialized';
	unless( $_[1] =~ /^[a-z0-9-]+(\.[a-z0-9-]+)+\z/ )
		{
		$_[0]->_warn( "The argument [$_[0]] does not look like a hostname" );
		return;
		}
		
	$_[0]->{pause_ftp_site} = $_[1];
	}

sub pause_ftp_site
	{
	$_[0]->{pause_ftp_site} || 'pause.perl.org';
	}

sub should_upload_to_pause
	{
	no warnings 'uninitialized';
	$_[0]->_debug(    "CPAN user: " . $_[0]->config->cpan_user . 
		           " | CPAN pass: " . $_[0]->config->cpan_pass . "\n" );
	$_[0]->config->cpan_user && $_[0]->config->cpan_pass
	}

sub pause_claim
	{
	require HTTP::Request;

	my $self = shift;
	return unless $self->should_upload_to_pause;

	my $ua  = $self->get_web_user_agent;

	my $request = HTTP::Request->new( POST => $self->pause_claim_base_url );
	
	$request->content_type( $self->pause_claim_content_type );

	$request->content( $self->pause_claim_content );

	$request->authorization_basic(
		$self->config->cpan_user, $self->config->cpan_pass );

	my $response = $ua->request( $request );

	$self->_print( "PAUSE upload ",
		$response->as_string =~ /Query succeeded/ ? "successful" : 'failed',
		"\n" );
	}

sub pause_claim_base_url { 'https://pause.perl.org/pause/authenquery' } 

sub pause_claim_content
	{
	require CGI; CGI->import( qw(-oldstyle_urls) );
	
	my $cgi = CGI->new();

	$cgi->param( 'HIDDENNAME',                     $_[0]->config->cpan_user     );
	$cgi->param( 'CAN_MULTIPART',                  1                            );
	$cgi->param( 'pause99_add_uri_upload',         $_[0]->remote_file           );
	$cgi->param( 'SUBMIT_pause99_add_uri_upload',  'Upload the checked file'    );
	$cgi->param( 'pause99_add_uri_sub',            'pause99_add_uri_subdirtext' );

	$cgi->query_string;
	}

sub pause_claim_content_type { 'application/x-www-form-urlencoded' }

1;