Alt-CPAN-Uploader-tinyua
view release on metacpan or search on metacpan
# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.025.
Changes
LICENSE
MANIFEST
META.json
META.yml
Makefile.PL
README
bin/cpan-upload
dist.ini
lib/Alt/CPAN/Uploader/tinyua.pm
lib/CPAN/Uploader.pm
t/00-load.t
},
"test" : {
"requires" : {
"Test::More" : "0"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/sergeyromanov/p5-alt-cpan-uploader-tinyua/issues"
},
"homepage" : "https://github.com/sergeyromanov/p5-alt-cpan-uploader-tinyua",
"repository" : {
"type" : "git",
"url" : "https://github.com/sergeyromanov/p5-alt-cpan-uploader-tinyua.git",
"web" : "https://github.com/sergeyromanov/p5-alt-cpan-uploader-tinyua"
}
},
"version" : "0.000001"
}
HTTP::Tiny::Multipart: '0'
HTTP::Tiny::UA: '0'
IO::Socket::SSL: '1.56'
Net::SSLeay: '1.49'
Term::ReadKey: '0'
URI: '0'
constant: '0'
strict: '0'
warnings: '0'
resources:
bugtracker: https://github.com/sergeyromanov/p5-alt-cpan-uploader-tinyua/issues
homepage: https://github.com/sergeyromanov/p5-alt-cpan-uploader-tinyua
repository: https://github.com/sergeyromanov/p5-alt-cpan-uploader-tinyua.git
version: '0.000001'
Makefile.PL view on Meta::CPAN
my %WriteMakefileArgs = (
"ABSTRACT" => "because we are too hip to use LWP::UserAgent",
"AUTHOR" => "Sergey Romanov <sromanov\@cpan.org>",
"CONFIGURE_REQUIRES" => {
"ExtUtils::MakeMaker" => 0
},
"DISTNAME" => "Alt-CPAN-Uploader-tinyua",
"EXE_FILES" => [
"bin/cpan-upload"
],
"LICENSE" => "perl",
"NAME" => "Alt::CPAN::Uploader::tinyua",
"PREREQ_PM" => {
"Alt::Assert" => 0,
"Carp" => 0,
"Data::Dumper" => 0,
"File::Basename" => 0,
"File::HomeDir" => 0,
"File::Spec" => 0,
bin/cpan-upload view on Meta::CPAN
#!perl
use strict;
use warnings;
package
cpan_upload;
# PODNAME: cpan-upload
# ABSTRACT: upload a distribution to the CPAN
use CPAN::Uploader;
use Getopt::Long::Descriptive 0.084;
=head1 USAGE
usage: cpan-upload [options] file-to-upload-1 [ file-to-upload-2 ... ]
-v --verbose enable verbose logging
-h --help display this help message
--dry-run do not actually upload anything
-u --user your PAUSE username
-p --password the password to your PAUSE account
-d --directory a dir in your CPAN space in which to put the file
--http-proxy URL of the http proxy to use in uploading
=head1 CONFIGURATION
If you have a C<.pause> file in your home directory, it will be checked for a
username and password. It should look like this:
user EXAMPLE
password your-secret-password
You can GnuPG-encrypt this file if you wish:
bin/cpan-upload view on Meta::CPAN
=item L<Config::Identity>
=back
=cut
my %arg;
# This nonsensical hack is to cope with Module::Install wanting to call
# cpan-upload -verbose; it should be made to use CPAN::Uploader instead.
$ARGV[0] = '--verbose' if @ARGV == 2 and $ARGV[0] eq '-verbose';
# Process arguments
my ($opt, $usage) = describe_options(
"usage: %c [options] file-to-upload",
[ "verbose|v" => "enable verbose logging" ],
[ "help|h" => "display this help message" ],
[ "dry-run" => "do not actually upload anything" ],
[],
[ "user|u=s" => "your PAUSE username" ],
[ "password|p=s" => "the password to your PAUSE account" ],
[ "directory|d=s" => "a dir in your CPAN space in which to put the files" ],
[ "http-proxy=s" => "URL of the http proxy to use in uploading" ],
[ "config|c=s" => "config file to use; defaults to ~/.pause" ],
);
if ($opt->help) {
print $usage->text;
exit;
}
my $from_file = CPAN::Uploader->read_config_file($opt->config);
bin/cpan-upload view on Meta::CPAN
require Term::ReadKey;
local $| = 1;
print "PAUSE Password: ";
Term::ReadKey::ReadMode('noecho');
chop($arg{password} = <STDIN>);
Term::ReadKey::ReadMode('restore');
print "\n";
}
foreach my $file (@ARGV) {
CPAN::Uploader->upload_file(
$file,
\%arg,
);
}
lib/CPAN/Uploader.pm view on Meta::CPAN
use strict;
use warnings;
package CPAN::Uploader;
# ABSTRACT: upload things to the CPAN
$CPAN::Uploader::VERSION = '0.103007';
=head1 ORIGIN
This code is mostly derived from C<cpan-upload-http> by Brad Fitzpatrick, which
in turn was based on C<cpan-upload> by Neil Bowers. I (I<rjbs>) didn't want to
have to use a C<system> call to run either of those, so I refactored the code
into this module.
=cut
use Carp ();
use File::Basename ();
use File::HomeDir ();
use File::Spec;
use HTTP::Tiny::UA;
use HTTP::Tiny::Multipart;
use URI;
use constant ALT => 'tinyua';
my $UPLOAD_URI = $ENV{CPAN_UPLOADER_UPLOAD_URI}
|| 'https://pause.perl.org/pause/authenquery';
=method upload_file
CPAN::Uploader->upload_file($file, \%arg);
$uploader->upload_file($file);
Valid arguments are:
user - (required) your CPAN / PAUSE id
password - (required) your CPAN / PAUSE password
subdir - the directory (under your home directory) to upload to
http_proxy - uri of the http proxy to use
upload_uri - uri of the upload handler; usually the default (PAUSE) is right
debug - if set to true, spew lots more debugging output
This method attempts to actually upload the named file to the CPAN. It will
raise an exception on error.
=cut
sub upload_file {
my ($self, $file, $arg) = @_;
Carp::confess(q{don't supply %arg when calling upload_file on an object})
if $arg and ref $self;
# class call with no args is no good
Carp::confess(q{need to supply %arg when calling upload_file from the class})
if not (ref $self) and not $arg;
$self = $self->new($arg) if $arg;
if ($arg->{dry_run}) {
require Data::Dumper;
$self->log("By request, cowardly refusing to do anything at all.");
$self->log(
"The following arguments would have been used to upload: \n"
. '$self: ' . Data::Dumper::Dumper($self)
. '$file: ' . Data::Dumper::Dumper($file)
);
} else {
$self->_upload($file);
}
}
sub _ua_string {
my ($self) = @_;
my $class = ref $self || $self;
my $version = defined $class->VERSION ? $class->VERSION : 'dev';
return "$class/$version";
}
sub target { shift->{target} || 'PAUSE' }
sub _upload {
my $self = shift;
my $file = shift;
$self->log("registering upload with " . $self->target . " web server");
my $agent = HTTP::Tiny::UA->new(
agent => $self->_ua_string,
($self->{http_proxy} ? (http_proxy => $self->{http_proxy}) : ()),
);
my $uri = URI->new($self->{upload_uri} || $UPLOAD_URI);
$uri->userinfo(join ':', $self->{user}, $self->{password});
# Make the request to the PAUSE web server
$self->log("POSTing upload for $file to $uri");
my $response = $agent->post_multipart($uri, {
HIDDENNAME => $self->{user},
CAN_MULTIPART => 1,
pause99_add_uri_upload => File::Basename::basename($file),
SUBMIT_pause99_add_uri_httpupload => " Upload this file from my disk ",
pause99_add_uri_uri => "",
pause99_add_uri_httpupload => {
filename => $file,
content => do {open my $fh, '<', $file; binmode $fh; local $/ = <$fh>},
},
($self->{subdir} ? (pause99_add_uri_subdirtext => $self->{subdir}) : ()),
});
# So, how'd we do?
if (not defined $response) {
die "Request completely failed - we got undef back: $!";
}
lib/CPAN/Uploader.pm view on Meta::CPAN
"----- RESPONSE END -------\n"
);
$self->log($self->target . " add message sent ok [" . $response->status . "]");
}
}
=method new
my $uploader = CPAN::Uploader->new(\%arg);
This method returns a new uploader. You probably don't need to worry about
this method.
Valid arguments are the same as those to C<upload_file>.
=cut
sub new {
my ($class, $arg) = @_;
$arg->{$_} or Carp::croak("missing $_ argument") for qw(user password);
bless $arg => $class;
}
=method read_config_file
my $config = CPAN::Uploader->read_config_file( $filename );
This reads the config file and returns a hashref of its contents that can be
used as configuration for CPAN::Uploader.
If no filename is given, it looks for F<.pause> in the user's home directory
(from the env var C<HOME>, or the current directory if C<HOME> isn't set).
See L<cpan-upload/CONFIGURATION> for the config format.
=cut
sub read_config_file {
my ($class, $filename) = @_;
unless (defined $filename) {
my $home = File::HomeDir->my_home || '.';
$filename = File::Spec->catfile($home, '.pause');
lib/CPAN/Uploader.pm view on Meta::CPAN
Carp::croak "multiple enties for $k" if $conf{$k};
$conf{$k} = $v;
}
}
return \%conf;
}
=method log
$uploader->log($message);
This method logs the given string. The default behavior is to print it to the
screen. The message should not end in a newline, as one will be added as
needed.
=cut
sub log {
shift;
print "$_[0]\n"
( run in 0.834 second using v1.01-cache-2.11-cpan-b16cb0d3907 )