Skip to content


Added possibility to inject as a specific authorid #4

merged 1 commit into from

2 participants


If you accept I will also add tests ;) (And add me to the authors list if you dont mind)


I think I really need to fork that... sad.... thought modern ways are different


I like the idea, but I want to think about the implementation some more. Either way we can reuse the tests, so please go ahead and add them.


I want to use this soon in "production", so i'm a bit pushed here... I feel like the API that i added (and also the other pull request that is open) are both things that doesn't block future development. It would be nice if we add both (with tests) and start releasing it, moving to a newer API is not like a big deal in my eyes.

Why its relevant that its on CPAN is in this case cause i wanna use it for the DuckDuckGo own DarkPAN which is some kind of public, so i want that people can "replicate" what we can do to understand the systems, and also gain more knowledge about the perl processes if they are interested. So it would be very awesome if we come to a nice conclusion here where we wanna go.

In worst bad case, i also dont see a problem for myself, to fork it to like CPAN::Duck, and make it just an implementation for us, but i hoped that we can both stay on the same track here :-). I'm open for alternatives, or that its a "more complex" API for me now that you can make the cleaner API later, I just need the EXACTLY this code :)

@chromatic chromatic merged commit b1839f1 into chromatic:master

The user-facing API is fine. I'd like to change the customization mechanism for injected parameters though; I prefer to pass in a list of key/value pairs rather than to pass $author explicitly. I think that'll work better for multiple customization options.

As long as it's clear that the internal API will change, I'm happy to support this feature. Send me another pull request with tests and I can get this on the CPAN.


Thanks! Wonderful, will get on my TODO then. Can you also approve the other pull request (#3)? Cause I think this feature would also be important.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 14, 2011
  1. @Getty
Showing with 81 additions and 16 deletions.
  1. +44 −1 bin/darkpan-inject
  2. +37 −15 lib/CPAN/
45 bin/darkpan-inject
@@ -1,7 +1,50 @@
+# 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 );
+=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
+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
+=head1 AUTHOR
+chromatic C<< chromatic at wgz dot org >>
+Copyright (c) 2011, chromatic. Redistribution and modification permitted under
+the terms of the Artistic License 2.0.
52 lib/CPAN/
@@ -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 );
@@ -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.
+ 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
+=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
Something went wrong with that request. Please try again.