Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added possibility to upload for a specific authorid

  • Loading branch information...
commit 1e596ac13d97e8a559dc724ae0551621632717f9 1 parent f3e5c72
@Getty Getty authored
Showing with 81 additions and 16 deletions.
  1. +44 −1 bin/darkpan-inject
  2. +37 −15 lib/CPAN/Dark.pm
View
45 bin/darkpan-inject
@@ -1,7 +1,50 @@
#!/usr/bin/perl
+# ABSTRACT: Generate and inject files into your darkpan
use strict;
use warnings;
use CPAN::Dark;
-CPAN::Dark->new->inject_files( @ARGV );
+use Getopt::Long 2.38;
+
+my $author;
+GetOptions("as=s" => \$author);
+
+my $darkpan = CPAN::Dark->new;
+
+$author ? $darkpan->inject_files_as( $author, @ARGV ) : $darkpan->inject_files( @ARGV );
+
+__END__
+
+=pod
+
+=head1 NAME
+
+darkpan-inject - Generate and inject files into your darkpan
+
+=head1 SYNOPSIS
+
+ # Inject files as the default author given in the configuration
+ darkpan-inject MyDistribution-0.001.tar.gz MyOtherDistribution-0.010.tar.gz
+
+ # Inject files as a specific author, only one can be given
+ darkpan-inject --as GETTY MyDistribution-Web-0.020.tar.gz MyOtherDistribution-Web-1.200.tar.gz
+
+=head1 DESCRIPTION
+
+Please read L<CPAN::Dark> first to understand the concept of a DarkPAN and
+for getting the information how to configure those commands so that you can
+use them to startup your own DarkPAN.
+
+=head1 SEE ALSO
+
+L<CPAN::Dark>
+
+=head1 AUTHOR
+
+chromatic C<< chromatic at wgz dot org >>
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright (c) 2011, chromatic. Redistribution and modification permitted under
+the terms of the Artistic License 2.0.
View
52 lib/CPAN/Dark.pm
@@ -73,26 +73,33 @@ sub write_gz
sub inject_files
{
my $self = shift;
- $self->create_darkpan;
+ $self->inject_file_as($self->{cpmi}->config->{author},$_) for (@_);
+}
- my $cpmi = $self->{cpmi};
+sub inject_files_as
+{
+ my $self = shift;
+ my $author = shift;
+ $self->inject_file_as($author,$_) for (@_);
+}
- for my $file (@_)
- {
- Carp::croak( "Cannot find '$file'" ) unless $file and -e $file;
+sub inject_file_as
+{
+ my ($self, $author, $file) = @_;
+ $self->create_darkpan;
+ Carp::croak( "Cannot find '$file'" ) unless $file and -e $file;
- my $meta = $self->load_metayaml( $file );
- (my $module = $meta->{name}) =~ s/-/::/g;
+ my $meta = $self->load_metayaml( $file );
+ (my $module = $meta->{name}) =~ s/-/::/g;
- $cpmi->add(
- file => $file,
- module => $module,
- version => $meta->{version},
- authorid => $cpmi->config->{author},
- );
- }
+ $self->{cpmi}->add(
+ file => $file,
+ module => $module,
+ version => $meta->{version},
+ authorid => $author,
+ );
- $cpmi->writelist->inject;
+ $self->{cpmi}->writelist->inject;
}
sub load_metayaml
@@ -120,6 +127,7 @@ CPAN::Dark - manage a DarkPAN installation
use CPAN::Dark;
CPAN::Dark->new->inject_files( @list_of_dist_tarballs );
+ CPAN::Dark->new->inject_files_as( $author, @list_of_dist_tarballs );
=head1 DESCRIPTION
@@ -152,6 +160,13 @@ The contents of this file must conform to the described file format, with one
additional parameter. Provide the C<author> configuration to set a default
author for all injected DarkPAN distributions.
+Example:
+
+ local: /home/larry/darkpan
+ remote: http://localhost/
+ author: LWALL
+ repository: /home/larry/tmp
+
=head1 METHODS
This module provides three public methods:
@@ -170,6 +185,11 @@ created and initialized, this method will attempt to create it. This method
will also throw an exception if any of the given files do not exist or are not
readable.
+=head2 C<inject_files_as( $author, @tarballs )>
+
+The same function as I<inject_files>, but you can use a different author, then
+given via L<CPAN::Mini::Inject> configuration.
+
=head2 C<create_darkpan()>
This method will create the DarkPAN represented by the current configuration,
@@ -178,6 +198,8 @@ file permissions if this happens.
=head1 SEE ALSO
+L<darkpan-inject>
+
L<CPAN::Mini>
L<CPAN::Mini::Inject>
Please sign in to comment.
Something went wrong with that request. Please try again.