line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::CopyTo; |
2
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
31009
|
use Moose; |
|
1
|
|
|
|
|
659278
|
|
|
1
|
|
|
|
|
8
|
|
5
|
1
|
|
|
1
|
|
7037
|
use File::Glob qw/:glob/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
676
|
|
6
|
|
|
|
|
|
|
###use Smart::Comments; |
7
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::AfterBuild'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'dir' => ( |
10
|
|
|
|
|
|
|
is => 'ro', |
11
|
|
|
|
|
|
|
isa => 'ArrayRef', |
12
|
|
|
|
|
|
|
default => sub { [] }, |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
0
|
0
|
|
sub mvp_multivalue_args { qw/dir/ } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub after_build { |
18
|
0
|
|
|
0
|
0
|
|
my ( $self, $args ) = @_; |
19
|
0
|
|
|
|
|
|
my @dirs = @{ $self->{dir}}; |
|
0
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
### @dirs: @dirs |
21
|
0
|
|
|
|
|
|
for my $dir ( @dirs ) { |
22
|
|
|
|
|
|
|
### dir: $dir |
23
|
0
|
0
|
|
|
|
|
$dir = bsd_glob($dir) if $dir =~ /^~/; |
24
|
|
|
|
|
|
|
### afterglob: $dir |
25
|
0
|
|
|
|
|
|
my $path = Path::Class::Dir->new($dir); |
26
|
0
|
|
|
|
|
|
for my $file ( @{ $self->zilla->files } ) { |
|
0
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
$self->_write_out_file( $file, $path ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _write_out_file { |
33
|
0
|
|
|
0
|
|
|
my ( $self, $file, $build_root ) = @_; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $file_path = Path::Class::file( $file->name ); |
36
|
0
|
|
|
|
|
|
my $to_dir = $build_root->subdir( $file_path->dir ); |
37
|
0
|
|
|
|
|
|
my $to = $to_dir->file( $file_path->basename ); |
38
|
0
|
0
|
|
|
|
|
$to_dir->mkpath unless -e $to_dir; |
39
|
0
|
0
|
|
|
|
|
die "not a directory: $to_dir" unless -d $to_dir; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Carp::croak("attempted to write $to multiple times") if -e $to; |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
open my $out_fh, '>', "$to" or die "couldn't open $to to write: $!"; |
44
|
0
|
|
|
|
|
|
print {$out_fh} $file->content; |
|
0
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
close $out_fh or die "error closing $to: $!"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
49
|
1
|
|
|
1
|
|
5
|
no Moose; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
4
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Dist::Zilla::Plugin::CopyTo - Copy to other places plugin for Dist::Zilla |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 SYNOPSIS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Used to copy the updated module to other directories. You can specify more |
64
|
|
|
|
|
|
|
than one directory. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#dist.ini |
67
|
|
|
|
|
|
|
[CopyTo] |
68
|
|
|
|
|
|
|
dir = ~/git/Perl-Dist-Zilla-Plugin-CopyTo |
69
|
|
|
|
|
|
|
dir = ~/svn/Perl-Dist-Zilla-Pulgin-CopyTo |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 AUTHOR |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Woosley.Xu |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Copyright 2009, Woosley.Xu. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This program is free software; you may redistribute it and/or modify it under |
80
|
|
|
|
|
|
|
the same terms as Perl itself. |