Dist-Zilla-Plugin-Authority
view release on metacpan or search on metacpan
lib/Dist/Zilla/Plugin/Authority.pm view on Meta::CPAN
use Moose 1.03;
use PPI 1.206;
use File::Spec;
use File::HomeDir;
use Dist::Zilla::Util;
with(
'Dist::Zilla::Role::MetaProvider' => { -version => '4.102345' },
'Dist::Zilla::Role::FileMunger' => { -version => '4.102345' },
'Dist::Zilla::Role::FileFinderUser' => {
-version => '4.102345',
default_finders => [ ':InstallModules', ':ExecFiles' ],
},
'Dist::Zilla::Role::PPI' => { -version => '4.300001' },
);
#pod =attr authority
#pod
#pod The authority you want to use. It should be something like C<cpan:APOCAL>.
#pod
#pod Defaults to the username set in the %PAUSE stash in the global config.ini or dist.ini ( Dist::Zilla v4 addition! )
#pod
#pod If you prefer to not put it in config/dist.ini you can put it in "~/.pause" just like Dist::Zilla did before v4.
#pod
#pod =cut
{
use Moose::Util::TypeConstraints 1.01;
has authority => (
is => 'ro',
isa => subtype( 'Str'
=> where { $_ =~ /^\w+\:\S+$/ }
=> message { "Authority must be in the form of 'cpan:PAUSEID'" }
),
lazy => 1,
default => sub {
my $self = shift;
my $stash = $self->zilla->stash_named( '%PAUSE' );
if ( defined $stash ) {
$self->log_debug( [ 'using PAUSE id "%s" for AUTHORITY from Dist::Zilla config', uc( $stash->username ) ] );
return 'cpan:' . uc( $stash->username );
} else {
# Argh, try the .pause file?
# Code ripped off from Dist::Zilla::Plugin::UploadToCPAN v4.200001 - thanks RJBS!
my $file = File::Spec->catfile( File::HomeDir->my_home, '.pause' );
if ( -f $file ) {
open my $fh, '<', $file or $self->log_fatal( "Unable to open $file - $!" );
while (<$fh>) {
next if /^\s*(?:#.*)?$/;
my ( $k, $v ) = /^\s*(\w+)\s+(.+)$/;
if ( $k =~ /^user$/i ) {
$self->log_debug( [ 'using PAUSE id "%s" for AUTHORITY from ~/.pause', uc( $v ) ] );
return 'cpan:' . uc( $v );
}
}
close $fh or $self->log_fatal( "Unable to close $file - $!" );
$self->log_fatal( 'PAUSE user not found in ~/.pause' );
} else {
$self->log_fatal( 'PAUSE credentials not found in "config.ini" or "dist.ini" or "~/.pause"! Please set it or specify an authority for this plugin.' );
}
}
},
);
no Moose::Util::TypeConstraints;
}
#pod =attr do_metadata
#pod
#pod A boolean value to control if the authority should be added to the metadata.
#pod
#pod Defaults to true.
#pod
#pod =cut
has do_metadata => (
is => 'ro',
isa => 'Bool',
default => 1,
);
#pod =attr do_munging
#pod
#pod A boolean value to control if the $AUTHORITY variable should be added to the modules.
#pod
#pod Defaults to true.
#pod
#pod =cut
has do_munging => (
is => 'ro',
isa => 'Bool',
default => 1,
);
#pod =attr locate_comment
#pod
#pod A boolean value to control if the $AUTHORITY variable should be added where a
#pod C<# AUTHORITY> comment is found. If this is set then an appropriate comment
#pod is found, and C<our $AUTHORITY = 'cpan:PAUSEID';> is inserted preceding the
#pod comment on the same line.
#pod
#pod This basically implements what L<OurPkgVersion|Dist::Zilla::Plugin::OurPkgVersion>
#pod does for L<PkgVersion|Dist::Zilla::Plugin::PkgVersion>.
#pod
#pod Defaults to false.
#pod
#pod NOTE: If you use this method, then we will not use the pkg style of declaration! That way, we keep the line numbering consistent.
#pod
#pod =cut
has locate_comment => (
is => 'ro',
isa => 'Bool',
default => 0,
);
#pod =attr authority_style
#pod
( run in 1.788 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )