| 1 | package Dist::Zilla::Plugin::JSAN::StaticDir; | ||
| 2 | BEGIN { | ||
| 3 | $Dist::Zilla::Plugin::JSAN::StaticDir::VERSION = '0.06'; | ||
| 4 | } | ||
| 5 | |||
| 6 | # ABSTRACT: Process "static" directory | ||
| 7 | |||
| 8 | use Moose; | ||
| 9 | |||
| 10 | use Path::Class; | ||
| 11 | |||
| 12 | with 'Dist::Zilla::Role::FileMunger'; | ||
| 13 | |||
| 14 | |||
| 15 | has 'static_dir' => ( | ||
| 16 | isa => 'Str', | ||
| 17 | is => 'rw', | ||
| 18 | default => 'static' | ||
| 19 | ); | ||
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | sub dist_name_as_dir { | ||
| 24 | my ($self) = @_; | ||
| 25 | |||
| 26 | my $name = $self->zilla->name; | ||
| 27 | |||
| 28 | return (split /-/, $name); | ||
| 29 | } | ||
| 30 | |||
| 31 | |||
| 32 | sub munge_file { | ||
| 33 | my ($self, $file) = @_; | ||
| 34 | |||
| 35 | my $static_dir = $self->static_dir; | ||
| 36 | |||
| 37 | if ($file->name =~ m|^$static_dir|) { | ||
| 38 | |||
| 39 | my $filename = dir('lib', $self->dist_name_as_dir, $file->name); | ||
| 40 | |||
| 41 | $file->name($filename . "") | ||
| 42 | } | ||
| 43 | |||
| 44 | } | ||
| 45 | |||
| 46 | |||
| 47 | no Moose; | ||
| 48 | __PACKAGE__->meta->make_immutable(); | ||
| 49 | |||
| 50 | |||
| 51 | 1; | ||
| 52 | |||
| 53 | |||
| 54 | |||
| 55 | |||
| 56 | __END__ |