/usr/share/perl5/Dist/Zilla.pm is in libdist-zilla-perl 4.300005-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 | package Dist::Zilla;
{
$Dist::Zilla::VERSION = '4.300005';
}
# ABSTRACT: distribution builder; installer not included!
use Moose 0.92; # role composition fixes
with 'Dist::Zilla::Role::ConfigDumper';
use Moose::Autobox 0.09; # ->flatten
use MooseX::LazyRequire;
use MooseX::Types::Moose qw(ArrayRef Bool HashRef Object Str);
use MooseX::Types::Perl qw(DistName LaxVersionStr);
use MooseX::Types::Path::Class qw(Dir File);
use Moose::Util::TypeConstraints;
use Dist::Zilla::Types qw(License);
use Hash::Merge::Simple ();
use Log::Dispatchouli 1.100712; # proxy_loggers, quiet_fatal
use Path::Class;
use List::Util qw(first);
use Software::License 0.101370; # meta2_name
use String::RewritePrefix;
use Try::Tiny;
use Dist::Zilla::Prereqs;
use Dist::Zilla::File::OnDisk;
use Dist::Zilla::Role::Plugin;
use Dist::Zilla::Util;
use namespace::autoclean;
has chrome => (
is => 'rw',
isa => role_type('Dist::Zilla::Role::Chrome'),
required => 1,
);
has name => (
is => 'ro',
isa => DistName,
lazy_required => 1,
);
has _version_override => (
isa => LaxVersionStr,
is => 'ro' ,
init_arg => 'version',
);
# XXX: *clearly* this needs to be really much smarter -- rjbs, 2008-06-01
has version => (
is => 'rw',
isa => LaxVersionStr,
lazy => 1,
init_arg => undef,
required => 1,
builder => '_build_version',
);
sub _build_version {
my ($self) = @_;
my $version = $self->_version_override;
for my $plugin ($self->plugins_with(-VersionProvider)->flatten) {
next unless defined(my $this_version = $plugin->provide_version);
$self->log_fatal('attempted to set version twice') if defined $version;
$version = $this_version;
}
$self->log_fatal('no version was ever set') unless defined $version;
$version;
}
has abstract => (
is => 'rw',
isa => 'Str',
lazy => 1,
required => 1,
default => sub {
my ($self) = @_;
unless ($self->main_module) {
die "no abstract given and no main_module found; make sure your main module is in ./lib\n";
}
my $file = $self->main_module;
$self->log("extracting distribution abstract from " . $file->name);
my $abstract = Dist::Zilla::Util->abstract_from_file($file);
if (!defined($abstract)) {
my $filename = $file->name;
die "Unable to extract an abstract from $filename. Please add the following comment to the file with your abstract:
# ABSTRACT: turns baubles into trinkets
";
}
return $abstract;
}
);
has _main_module_override => (
isa => 'Str',
is => 'ro' ,
init_arg => 'main_module',
predicate => '_has_main_module_override',
);
has main_module => (
is => 'ro',
isa => 'Dist::Zilla::Role::File',
lazy => 1,
init_arg => undef,
required => 1,
default => sub {
my ($self) = @_;
my $file;
my $guessing = q{};
my $guess;
if ( $self->_has_main_module_override ) {
$file = first { $_->name eq $self->_main_module_override }
$self->files->flatten;
} else {
$guessing = 'guessing '; # We're having to guess
($guess = $self->name) =~ s{-}{/}g;
$guess = "lib/$guess.pm";
$file = (first { $_->name eq $guess } $self->files->flatten)
|| $self->files
->grep(sub { $_->name =~ m{\.pm\z} and $_->name =~ m{\Alib/} })
->sort(sub { length $_[0]->name <=> length $_[1]->name })
->head;
}
if (not $file) {
my @errorlines;
push @errorlines, "Unable to find main_module in the distribution";
if ( $self->_has_main_module_override ) {
push @errorlines, "'main_module' was specified in dist.ini but the file '" . $self->_main_module_override . "' is not to be found in our dist. ( Did you add it? )";
} else {
push @errorlines,"We tried to guess '$guess' but no file like that existed";
}
if ( not $self->files->flatten ) {
push @errorlines, "Upon further inspection we didn't find any files in your dist, did you add any?";
} elsif ( not $self->files->grep(sub{ $_->name =~ m{\.pm\z} })->head ){
push @errorlines, "We didn't find any .pm files in your dist, this is probably a problem.";
}
push @errorlines,"Cannot continue without a main_module";
$self->log_fatal( join qq{\n}, @errorlines );
}
$self->log("${guessing}dist's main_module is " . $file->name);
return $file;
},
);
has license => (
is => 'ro',
isa => License,
lazy => 1,
init_arg => 'license_obj',
predicate => '_has_license',
builder => '_build_license',
handles => {
copyright_holder => 'holder',
copyright_year => 'year',
},
);
sub _build_license {
my ($self) = @_;
my $license_class = $self->_license_class;
my $copyright_holder = $self->_copyright_holder;
my $copyright_year = $self->_copyright_year;
if ($license_class) {
$license_class = String::RewritePrefix->rewrite(
{
'=' => '',
'' => 'Software::License::'
},
$license_class,
);
} else {
require Software::LicenseUtils;
my @guess = Software::LicenseUtils->guess_license_from_pod(
$self->main_module->content
);
if (@guess != 1) {
$self->log_fatal(
"no license data in config, no %Rights stash,",
"couldn't make a good guess at license from Pod; giving up"
);
}
my $filename = $self->main_module->name;
$license_class = $guess[0];
$self->log("based on POD in $filename, guessing license is $guess[0]");
}
Class::MOP::load_class($license_class);
my $license = $license_class->new({
holder => $self->_copyright_holder,
year => $self->_copyright_year,
});
$self->_clear_license_class;
$self->_clear_copyright_holder;
$self->_clear_copyright_year;
return $license;
}
has _license_class => (
is => 'ro',
isa => 'Maybe[Str]',
lazy => 1,
init_arg => 'license',
clearer => '_clear_license_class',
default => sub {
my $stash = $_[0]->stash_named('%Rights');
$stash && return $stash->license_class;
return;
}
);
has _copyright_holder => (
is => 'ro',
isa => 'Maybe[Str]',
lazy => 1,
init_arg => 'copyright_holder',
clearer => '_clear_copyright_holder',
default => sub {
return unless my $stash = $_[0]->stash_named('%Rights');
$stash && return $stash->copyright_holder;
return;
}
);
has _copyright_year => (
is => 'ro',
isa => 'Int',
lazy => 1,
init_arg => 'copyright_year',
clearer => '_clear_copyright_year',
default => sub {
# Oh man. This is a terrible idea! I mean, what if by the code gets run
# around like Dec 31, 23:59:59.9 and by the time the default gets called
# it's the next year but the default was already set up? Oh man. That
# could ruin lives! I guess we could make this a sub to defer the guess,
# but think of the performance hit! I guess we'll have to suffer through
# this until we can optimize the code to not take .1s to run, right? --
# rjbs, 2008-06-13
my $stash = $_[0]->stash_named('%Rights');
my $year = $stash && $stash->copyright_year;
return defined $year ? $year : (localtime)[5] + 1900;
}
);
has authors => (
is => 'ro',
isa => ArrayRef[Str],
lazy => 1,
required => 1,
default => sub {
my ($self) = @_;
if (my $stash = $self->stash_named('%User')) {
return $stash->authors;
}
my $author = try { $self->copyright_holder };
return [ $author ] if defined $author and length $author;
$self->log_fatal(
"No %User stash and no copyright holder;",
"can't determine dist author; configure author or a %User section",
);
},
);
has files => (
is => 'ro',
isa => ArrayRef[ role_type('Dist::Zilla::Role::File') ],
lazy => 1,
init_arg => undef,
default => sub { [] },
);
sub prune_file {
my ($self, $file) = @_;
my @files = @{ $self->files };
for my $i (0 .. $#files) {
next unless $file == $files[ $i ];
splice @{ $self->files }, $i, 1;
return;
}
return;
}
has root => (
is => 'ro',
isa => Dir,
coerce => 1,
required => 1,
);
has is_trial => (
is => 'rw', # XXX: make SetOnce -- rjbs, 2010-03-23
isa => Bool,
default => sub { $ENV{TRIAL} ? 1 : 0 }
);
has plugins => (
is => 'ro',
isa => 'ArrayRef[Dist::Zilla::Role::Plugin]',
init_arg => undef,
default => sub { [ ] },
);
has distmeta => (
is => 'ro',
isa => 'HashRef',
init_arg => undef,
lazy => 1,
builder => '_build_distmeta',
);
sub _build_distmeta {
my ($self) = @_;
my $meta = {
'meta-spec' => {
version => 2,
url => 'http://github.com/dagolden/cpan-meta/',
},
name => $self->name,
version => $self->version,
abstract => $self->abstract,
author => $self->authors,
license => $self->license->meta2_name,
# XXX: what about unstable?
release_status => ($self->is_trial or $self->version =~ /_/)
? 'testing'
: 'stable',
dynamic_config => 0, # problematic, I bet -- rjbs, 2010-06-04
generated_by => $self->_metadata_generator_id
. ' version '
. (defined $self->VERSION ? $self->VERSION : '(undef)')
};
$meta = Hash::Merge::Simple::merge($meta, $_->metadata)
for $self->plugins_with(-MetaProvider)->flatten;
return $meta;
}
sub _metadata_generator_id { 'Dist::Zilla' }
has prereqs => (
is => 'ro',
isa => 'Dist::Zilla::Prereqs',
init_arg => undef,
default => sub { Dist::Zilla::Prereqs->new },
handles => [ qw(register_prereqs) ],
);
sub plugin_named {
my ($self, $name) = @_;
my $plugin = first { $_->plugin_name eq $name } $self->plugins->flatten;
return $plugin if $plugin;
return;
}
sub plugins_with {
my ($self, $role) = @_;
$role =~ s/^-/Dist::Zilla::Role::/;
my $plugins = $self->plugins->grep(sub { $_->does($role) });
return $plugins;
}
sub find_files {
my ($self, $finder_name) = @_;
$self->log_fatal("no plugin named $finder_name found")
unless my $plugin = $self->plugin_named($finder_name);
$self->log_fatal("plugin $finder_name is not a FileFinder")
unless $plugin->does('Dist::Zilla::Role::FileFinder');
$plugin->find_files;
}
sub _check_dupe_files {
my ($self) = @_;
my %files_named;
for my $file ($self->files->flatten) {
($files_named{ $file->name} ||= [])->push($file);
}
return unless
my @dupes = grep { $files_named{$_}->length > 1 } keys %files_named;
for my $name (@dupes) {
$self->log("attempt to add $name multiple times; added by: "
. join('; ', map { $_->added_by } @{ $files_named{ $name } })
);
}
Carp::croak("aborting; duplicate files would be produced");
}
sub _write_out_file {
my ($self, $file, $build_root) = @_;
# Okay, this is a bit much, until we have ->debug. -- rjbs, 2008-06-13
# $self->log("writing out " . $file->name);
my $file_path = file($file->name);
my $to_dir = $build_root->subdir( $file_path->dir );
my $to = $to_dir->file( $file_path->basename );
$to_dir->mkpath unless -e $to_dir;
die "not a directory: $to_dir" unless -d $to_dir;
Carp::croak("attempted to write $to multiple times") if -e $to;
open my $out_fh, '>', "$to" or die "couldn't open $to to write: $!";
# This is needed, or \n is translated to \r\n on win32.
# Maybe :raw:utf8 is needed, but not sure.
# -- Kentnl - 2010-06-10
binmode( $out_fh , ":raw" );
print { $out_fh } $file->content;
close $out_fh or die "error closing $to: $!";
chmod $file->mode, "$to" or die "couldn't chmod $to: $!";
}
has logger => (
is => 'ro',
isa => 'Log::Dispatchouli::Proxy', # could be duck typed, I guess
lazy => 1,
handles => [ qw(log log_debug log_fatal) ],
default => sub {
$_[0]->chrome->logger->proxy({ proxy_prefix => '[DZ] ' })
},
);
around dump_config => sub {
my ($orig, $self) = @_;
my $config = $self->$orig;
$config->{is_trial} = $self->is_trial;
return $config;
};
has _local_stashes => (
is => 'ro',
isa => HashRef[ Object ],
lazy => 1,
default => sub { {} },
);
has _global_stashes => (
is => 'ro',
isa => HashRef[ Object ],
lazy => 1,
default => sub { {} },
);
sub stash_named {
my ($self, $name) = @_;
return $self->_local_stashes->{ $name } if $self->_local_stashes->{$name};
return $self->_global_stashes->{ $name };
}
__PACKAGE__->meta->make_immutable;
1;
=pod
=head1 NAME
Dist::Zilla - distribution builder; installer not included!
=head1 VERSION
version 4.300005
=head1 DESCRIPTION
Dist::Zilla builds distributions of code to be uploaded to the CPAN. In this
respect, it is like L<ExtUtils::MakeMaker>, L<Module::Build>, or
L<Module::Install>. Unlike those tools, however, it is not also a system for
installing code that has been downloaded from the CPAN. Since it's only run by
authors, and is meant to be run on a repository checkout rather than on
published, released code, it can do much more than those tools, and is free to
make much more ludicrous demands in terms of prerequisites.
If you have access to the web, you can learn more and find an interactive
tutorial at B<L<dzil.org|http://dzil.org/>>. If not, try
L<Dist::Zilla::Tutorial>.
=head1 ATTRIBUTES
=head2 name
The name attribute (which is required) gives the name of the distribution to be
built. This is usually the name of the distribution's main module, with the
double colons (C<::>) replaced with dashes. For example: C<Dist-Zilla>.
=head2 version
This is the version of the distribution to be created.
=head2 abstract
This is a one-line summary of the distribution. If none is given, one will be
looked for in the L</main_module> of the dist.
=head2 main_module
This is the module where Dist::Zilla might look for various defaults, like
the distribution abstract. By default, it's derived from the distribution
name. If your distribution is Foo-Bar, and F<lib/Foo/Bar.pm> exists,
that's the main_module. Otherwise, it's the shortest-named module in the
distribution. This may change!
You can override the default by specifying the file path explicitly,
ie:
main_module = lib/Foo/Bar.pm
=head2 license
This is the L<Software::License|Software::License> object for this dist's
license and copyright.
It will be created automatically, if possible, with the
C<copyright_holder> and C<copyright_year> attributes. If necessary, it will
try to guess the license from the POD of the dist's main module.
A better option is to set the C<license> name in the dist's config to something
understandable, like C<Perl_5>.
=head2 authors
This is an arrayref of author strings, like this:
[
'Ricardo Signes <rjbs@cpan.org>',
'X. Ample, Jr <example@example.biz>',
]
This is likely to change at some point in the near future.
=head2 files
This is an arrayref of objects implementing L<Dist::Zilla::Role::File> that
will, if left in this arrayref, be built into the dist.
Non-core code should avoid altering this arrayref, but sometimes there is not
other way to change the list of files. In the future, the representation used
for storing files B<will be changed>.
=head2 root
This is the root directory of the dist, as a L<Path::Class::Dir>. It will
nearly always be the current working directory in which C<dzil> was run.
=head2 is_trial
This attribute tells us whether or not the dist will be a trial release.
=head2 plugins
This is an arrayref of plugins that have been plugged into this Dist::Zilla
object.
Non-core code B<must not> alter this arrayref. Public access to this attribute
B<may go away> in the future.
=head2 distmeta
This is a hashref containing the metadata about this distribution that will be
stored in META.yml or META.json. You should not alter the metadata in this
hash; use a MetaProvider plugin instead.
=head2 prereqs
This is a L<Dist::Zilla::Prereqs> object, which is a thin layer atop
L<CPAN::Meta::Prereqs>, and describes the distribution's prerequisites.
=head2 logger
This attribute stores a L<Log::Dispatchouli::Proxy> object, used to log
messages. By default, a proxy to the dist's L<Chrome|Dist::Zilla::Chrome> is
taken.
The following methods are delegated from the Dist::Zilla object to the logger:
=over 4
=item *
log
=item *
log_debug
=item *
log_fatal
=back
=head1 METHODS
=head2 plugin_named
my $plugin = $zilla->plugin_named( $plugin_name );
=head2 plugins_with
my $roles = $zilla->plugins_with( -SomeRole );
This method returns an arrayref containing all the Dist::Zilla object's plugins
that perform a the named role. If the given role name begins with a dash, the
dash is replaced with "Dist::Zilla::Role::"
=head2 find_files
my $files = $zilla->find_files( $finder_name );
This method will look for a
L<FileFinder|Dist::Zilla::Role::FileFinder>-performing plugin with the given
name and return the result of calling C<find_files> on it. If no plugin can be
found, an exception will be raised.
=head2 stash_named
my $stash = $zilla->stash_named( $name );
This method will return the stash with the given name, or undef if none exists.
It looks for a local stash (for this dist) first, then falls back to a global
stash (from the user's global configuration).
=head1 SUPPORT
There are usually people on C<irc.perl.org> in C<#distzilla>, even if they're
idling.
The L<Dist::Zilla website|http://dzil.org/> has several valuable resources for
learning to use Dist::Zilla.
There is a mailing list to discuss Dist::Zilla. You can L<join the
list|http://www.listbox.com/subscribe/?list_id=139292> or L<browse the
archives|http://listbox.com/member/archive/139292>.
=head1 AUTHOR
Ricardo SIGNES <rjbs@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
__END__
|