Dist-Zilla
view release on metacpan or search on metacpan
lib/Dist/Zilla.pm view on Meta::CPAN
#pod L<FileFinder|Dist::Zilla::Role::FileFinder>-performing plugin with the given
#pod name and return the result of calling C<find_files> on it. If no plugin can be
#pod found, an exception will be raised.
#pod
#pod =cut
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;
my @dupes;
for my $file (@{ $self->files }) {
my $filename = $file->name;
if (my $seen = $files_named{ $filename }) {
push @{ $seen }, $file;
push @dupes, $filename if @{ $seen } == 2;
} else {
$files_named{ $filename } = [ $file ];
}
}
return unless @dupes;
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 = path($file->name);
my $to_dir = path($build_root)->child( $file_path->parent );
my $to = $to_dir->child( $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;
path("$to")->spew_raw( $file->encoded_content );
chmod $file->mode, "$to" or die "couldn't chmod $to: $!";
}
#pod =attr logger
#pod
#pod This attribute stores a L<Log::Dispatchouli::Proxy> object, used to log
#pod messages. By default, a proxy to the dist's L<Chrome|Dist::Zilla::Role::Chrome> is
#pod taken.
#pod
#pod The following methods are delegated from the Dist::Zilla object to the logger:
#pod
#pod =for :list
#pod * log
#pod * log_debug
#pod * log_fatal
#pod
#pod =cut
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 { {} },
);
#pod =method stash_named
#pod
#pod my $stash = $zilla->stash_named( $name );
#pod
#pod This method will return the stash with the given name, or undef if none exists.
#pod It looks for a local stash (for this dist) first, then falls back to a global
#pod stash (from the user's global configuration).
#pod
#pod =cut
sub stash_named {
my ($self, $name) = @_;
( run in 1.552 second using v1.01-cache-2.11-cpan-39bf76dae61 )