TemplateSkeleton.pm 

package Dist::Zilla::Plugin::GatherDir::TemplateSkeleton;

our $VERSION = '1.000';

use Moose;
extends 'Dist::Zilla::Plugin::GatherDir::Template';

use autodie;
use Moose::Autobox;
use Dist::Zilla::File::InMemory;
use namespace::autoclean;


around '_file_from_filename' => sub {
  my $orig = shift;
  my $self = shift;
  my ($filename) = @_;

  if($filename =~ m{/!}) {
    my $content = do {
      open my $fh, '<', $filename;
      local $/;
      <$fh>;
    };
    my $new_name = $filename;
    $new_name =~ s{/!}{/};

    return Dist::Zilla::File::InMemory->new({
      name    => $new_name,
      mode    => ((stat $filename)[2] & 0755) | 0200, # kill world-writeability, make sure owner-writable.
      content => $content,
    });
  }
  return $self->$orig(@_);
};

sub module_name {
  my($self) = @_;

  (my $main_module_name = $self->zilla->name) =~ s/-/::/g;
  return $main_module_name;
}

__PACKAGE__->meta->make_immutable;
no Moose;
1;

__END__
=pod

=head1 NAME

Dist::Zilla::Plugin::GatherDir::TemplateSkeleton - gather all the files in a directory and use them as templates or as literal source

=head1 VERSION

version 4.200004

=head1 DESCRIPTION

This plugin is a subclass of L<Dist::Zilla::Plugin::GatherDir::Template> with
two functional differences:

=over 4

=item *

If a source filename starts with a '!' it will simply be copied verbatim to a
file of the same name but without the '!'

=item *

Other files will be used as templates and will be able to access the main
module package name as C<< {{$plugin->module_name}} >>.

=back

=head1 AUTHOR

Grant McLean C<< <grantm@cpan.org> >>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Grant McLean

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