| 1 | package Dist::Zilla::Plugin::JSAN::GatherDir::Template; | ||
| 2 | 1 | ▶ | BEGIN { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | $Dist::Zilla::Plugin::JSAN::GatherDir::Template::VERSION = '0.06'; | |
| 4 | } | ||
| 5 | # ABSTRACT: gather all the files in a directory and use them as templates (copy-pasted from Dist::Zilla::Plugin::GatherDir::Template with bug-fix) | ||
| 6 | |||
| 7 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | extends 'Dist::Zilla::Plugin::GatherDir'; | ||
| 10 | with 'Dist::Zilla::Role::TextTemplate'; | ||
| 11 | |||
| 12 | 1 | ▶ | use autodie; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | 0 | ▶ | use Moose::Autobox; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 14 | use Dist::Zilla::File::FromCode; | ||
| 15 | use namespace::autoclean; | ||
| 16 | |||
| 17 | |||
| 18 | sub _file_from_filename { | ||
| 19 | my ($self, $filename) = @_; | ||
| 20 | |||
| 21 | my $template = do { | ||
| 22 | open my $fh, '<', $filename; | ||
| 23 | local $/; | ||
| 24 | <$fh>; | ||
| 25 | }; | ||
| 26 | |||
| 27 | return Dist::Zilla::File::FromCode->new({ | ||
| 28 | name => $filename, | ||
| 29 | mode => (stat $filename)[2] & 0755 | 0600, # kill world-writeability and add self-writeability | ||
| 30 | code => sub { | ||
| 31 | my ($file_obj) = @_; | ||
| 32 | $self->fill_in_string( | ||
| 33 | $template, | ||
| 34 | { | ||
| 35 | dist => \($self->zilla), | ||
| 36 | plugin => \($self), | ||
| 37 | }, | ||
| 38 | ); | ||
| 39 | }, | ||
| 40 | }); | ||
| 41 | } | ||
| 42 | |||
| 43 | __PACKAGE__->meta->make_immutable; | ||
| 44 | no Moose; | ||
| 45 | 1; | ||
| 46 | |||
| 47 | __END__ | ||