| 1 | package Dist::Inkt::Role::CopyStandardDocuments; | ||
| 2 | |||
| 3 | our $AUTHORITY = 'cpan:TOBYINK'; | ||
| 4 | our $VERSION = '0.026'; | ||
| 5 | |||
| 6 | use Moose::Role; | ||
| 7 | use Types::Path::Tiny -types; | ||
| 8 | use Path::Tiny 'path'; | ||
| 9 | use namespace::autoclean; | ||
| 10 | |||
| 11 | has standard_documents_dir => ( | ||
| 12 | is => 'ro', | ||
| 13 | isa => AbsPath, | ||
| 14 | coerce => 1, | ||
| 15 | lazy => 1, | ||
| 16 | builder => '_build_standard_documents_dir', | ||
| 17 | ); | ||
| 18 | |||
| 19 | sub _build_standard_documents_dir | ||
| 20 | { | ||
| 21 | return path('~/perl5/standard-documents'); | ||
| 22 | } | ||
| 23 | |||
| 24 | after BUILD => sub { | ||
| 25 | my $self = shift; | ||
| 26 | unshift @{ $self->targets }, 'StandardDocuments'; | ||
| 27 | }; | ||
| 28 | |||
| 29 | sub Build_StandardDocuments | ||
| 30 | { | ||
| 31 | my $self = shift; | ||
| 32 | |||
| 33 | my $src = $self->standard_documents_dir; | ||
| 34 | $src->exists or return; | ||
| 35 | $src->is_dir or return; | ||
| 36 | |||
| 37 | my $dest = $self->targetdir; | ||
| 38 | |||
| 39 | for ($src->children) | ||
| 40 | { | ||
| 41 | my $file = path($_); | ||
| 42 | $file->is_file or next; | ||
| 43 | my $relative = $file->relative($src); | ||
| 44 | my $destfile = $relative->absolute($dest); | ||
| 45 | $self->log("Copying $file"); | ||
| 46 | $file->copy($destfile); | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | 1; |