<commit_before># $Id$
package Module::Release::FTP;

use strict;
use warnings;
use base qw(Exporter);

our @EXPORT = qw( 
	ftp_upload ftp_passive_on ftp_passive_off ftp_passive 
	ftp_class_name get_ftp_object 
	default_ftp_hostname default_ftp_user 
	default_ftp_password default_ftp_upload_dir
	);

our $VERSION = '0.10_02';

=head1 NAME

Module::Release::FTP - Interact with an FTP server

=head1 SYNOPSIS

The release script automatically loads this module when it's time
to upload a file

=head1 DESCRIPTION

=over 4

=item ftp_upload( PARAMS )

Upload the file in C<local_file> as C<remote_file> to the FTP server. You
can pass parameters to ftp_upload to change some of the behavior. Each
parameter has a default value (see the default_* subs at the end of the
module):

	Input key       Default value
	----------      -------------
	upload_dir      /incoming
	user            anonymous
	password        <PASSWORD>
	hostname        pause.perl.org

=cut

sub ftp_upload
	{
	my $self = shift;
	
	my %defaults = map { my $m = "default_ftp_$_"; $_, $self->$m() } qw(
		upload_dir
		user
		password
		hostname
		);
	
	my %params = ( %defaults, @_ );

	$self->_print( "Logging in to $params{hostname}\n" );
		
	my $ftp = $self->get_ftp_object( $params{hostname} );
	
	$ftp->login( @params{ qw(user password) } )
		or $self->_die( "Couldn't log in to $params{hostname}" );

	$ftp->binary;

	$ftp->cwd( $params{'upload_dir'} )
		or $self->_die( "Couldn't chdir to $params{'upload_dir'}" );

	$self->_print( "Putting " . $self->local_file . "\n" );
	my $remote_file = $ftp->put( $self->local_file, $self->remote_file );
	$self->_die( "PUT failed: " . $ftp->message . "\n" )
		if $remote_file ne $self->remote_file;

	my $remote_size = $ftp->size( $self->remote_file );

	no warnings 'uninitialized';
	$self->_print( "WARNING: Uploaded file is $remote_size bytes, " .<commit_msg>* Fix problem with argument to ftp_upload: it needs to be added to the %params hash as a value, not a key! Get rid of that 'odd number of elements' warning<commit_after># $Id$
package Module::Release::FTP;

use strict;
use warnings;
use base qw(Exporter);

our @EXPORT = qw( 
	ftp_upload ftp_passive_on ftp_passive_off ftp_passive 
	ftp_class_name get_ftp_object 
	default_ftp_hostname default_ftp_user 
	default_ftp_password default_ftp_upload_dir
	);

our $VERSION = '0.10_02';

=head1 NAME

Module::Release::FTP - Interact with an FTP server

=head1 SYNOPSIS

The release script automatically loads this module when it's time
to upload a file

=head1 DESCRIPTION

=over 4

=item ftp_upload( PARAMS )

Upload the file in C<local_file> as C<remote_file> to the FTP server. You
can pass parameters to ftp_upload to change some of the behavior. Each
parameter has a default value (see the default_* subs at the end of the
module):

	Input key       Default value
	----------      -------------
	upload_dir      /incoming
	user            anonymous
	password        <PASSWORD>
	hostname        pause.perl.org

=cut

sub ftp_upload
	{
	my( $self, $site ) = @_;
	
	my %defaults = map { my $m = "default_ftp_$_"; $_, $self->$m() } qw(
		upload_dir
		user
		password
		hostname
		);
	
	my %params = ( 
		%defaults, 
		defined $site ? ( hostname => $site ) : () 
		);

	$self->_print( "Logging in to $params{hostname}\n" );
		
	my $ftp = $self->get_ftp_object( $params{hostname} );
	
	$ftp->login( @params{ qw(user password) } )
		or $self->_die( "Couldn't log in to $params{hostname}" );

	$ftp->binary;

	$ftp->cwd( $params{'upload_dir'} )
		or $self->_die( "Couldn't chdir to $params{'upload_dir'}" );

	$self->_print( "Putting " . $self->local_file . "\n" );
	my $remote_file = $ftp->put( $self->local_file, $self->remote_file );
	$self->_die( "PUT failed: " . $ftp->message . "\n" )
		if $remote_file ne $self->remote_file;

	my $remote_size = $ftp->size( $self->remote_file );

	no warnings 'uninitialized';
	$self->_print( "WARNING: Uploaded file is $remote_size bytes, " .
{'fraction_non_alphanumeric': 0.13753799392097266, 'fraction_numerical': 0.004559270516717325, 'mean_word_length': 3.5972060535506403, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '441574', 'n_tokens_mistral': 1486, 'n_tokens_neox': 1385, 'n_words': 416}