blib/lib/Dist/Zilla/Plugin/CopyFilesFromRelease.pm

filter: Statementstmt 83.3% 35 / 42 Branchbran 70.0% 7 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 2 totaltotal 77.7% 49 / 63 CC 6 SCAR 11.7
CC
6
Cov
81%
__ANON__
6.0
after_release
5.0
__ANON__
2.0
CRAP 3.2
↑ Summary
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Dist::Zilla::Plugin::CopyFilesFromRelease; # git description: v0.006-14-g6b0a6f6
4 # ABSTRACT: Copy files from a release (for SCM inclusion, etc.)
5 # KEYWORDS: plugin copy files repository distribution release
6  
7 1 our $VERSION = '0.007';
8  
9 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 with qw/ Dist::Zilla::Role::AfterRelease /;
11  
12 1 ▶use Path::Tiny 0.070;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶sub mvp_multivalue_args { qw{ filename match } }
Subroutine mvp_multivalue_args: called CC=1 SCAR=0.0
Pod undocumented
16  
17 has $_ => (
18 lazy => 1,
19 isa => 'ArrayRef[Str]',
20 0 ▶ default => sub { [] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
21 traits => ['Array'],
22 handles => { $_ => 'sort' },
23 1 ) foreach qw(filename match);
24  
25 0 ▶around dump_config => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
26 0 my $orig = shift;
27 0 my $self = shift;
28  
29 0 my $config = $self->$orig;
30  
31 $config->{+__PACKAGE__} = {
32 0 ▶ map { $_ => [ $self->$_ ] } qw(filename match),
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($self) ne __PACKAGE__ ? : 0 0 0
33 blessed($self) ne __PACKAGE__ ? ( version => $VERSION ) : (),
34 };
35  
36 0 return $config;
37 1 };
38  
39 1 ▶sub after_release {
Subroutine after_release: called CC=5 SCAR=16.1
Pod undocumented
40 1 my $self = shift;
41  
42 1 my $build_dir = $self->zilla->built_in;
43 1 my $root = $self->zilla->root;
44  
45 1 my $file_match = join '|', map quotemeta, $self->filename;
46 1 $file_match = join '|', '^(?:' . $file_match . ')$', $self->match;
47 1 $file_match = qr/$file_match/;
48  
49 1 my $iterator = path($build_dir)->iterator({ recurse => 1 });
50 1 ▶ while (my $file = $iterator->()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $file = &$iterator()) 5 1 6
51 5 ▶ next if -d $file;
Branch: 1 branch
BranchTrueFalseTotal
if -d $file 1 4 5
52  
53 4 my $rel_path = $file->relative($build_dir);
54 next
55 4 ▶ unless $rel_path =~ $file_match;
Branch: 1 branch
BranchTrueFalseTotal
unless $rel_path =~ /$file_match/ 2 2 4
56 2 my $dest = path($root, $rel_path);
57 2 ▶ $file->copy($dest)
Branch: 1 branch
BranchTrueFalseTotal
$file->copy($dest) or $self->log_fatal("Unable to copy $file to ${dest}: $!") 2 0 2
58 or $self->log_fatal("Unable to copy $file to $dest: $!");
59 2 $self->log("Copied $file to $dest");
60 }
61 }
62  
63 1 __PACKAGE__->meta->make_immutable;
64  
65 __END__
↑ Summary