File Coverage

blib/lib/Dist/Zilla/Plugin/Web/Role/FileMatcher.pm
Criterion Covered Total %
statement 18 18 100.0
branch 3 4 75.0
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 24 26 92.3


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::Web::Role::FileMatcher;
2             $Dist::Zilla::Plugin::Web::Role::FileMatcher::VERSION = '0.0.10';
3             # ABSTRACT: Embedd module version to sources
4              
5 3     3   1553 use Moose::Role;
  3         5  
  3         16  
6              
7              
8             has 'file_match' => (
9             is => 'rw',
10              
11             default => sub { [ '^lib/.*\\.js$' ] }
12             );
13              
14              
15             has 'exculde_match' => (
16             is => 'rw',
17              
18             default => sub { [] }
19             );
20              
21              
22             around mvp_multivalue_args => sub {
23             my ($orig, $self) = @_;
24            
25             my $original = $self->$orig;
26            
27             qw( file_match exculde_match $original)
28             };
29              
30              
31             sub for_each_matched_file {
32 4     4 0 10 my ($self, $sub) = @_;
33            
34 4         12 my $matches_regex = qr/\000/;
35 4         10 my $exclude_regex = qr/\000/;
36              
37 4         6 $matches_regex = qr/$_|$matches_regex/ for (@{$self->file_match});
  4         136  
38 4         7 $exclude_regex = qr/$_|$exclude_regex/ for (@{$self->exculde_match});
  4         120  
39              
40 4         6 for my $file (@{$self->zilla->files}) {
  4         86  
41 15 100       2150 next unless $file->name =~ $matches_regex;
42 8 50       237 next if $file->name =~ $exclude_regex;
43            
44 8         206 $sub->($file);
45             }
46             }
47              
48              
49 3     3   10048 no Moose;
  3         4  
  3         13  
50              
51              
52             1;
53              
54             __END__
55              
56             =pod
57              
58             =encoding UTF-8
59              
60             =head1 NAME
61              
62             Dist::Zilla::Plugin::Web::Role::FileMatcher - Embedd module version to sources
63              
64             =head1 VERSION
65              
66             version 0.0.10
67              
68             =head1 AUTHOR
69              
70             Nickolay Platonov <nplatonov@cpan.org>
71              
72             =head1 COPYRIGHT AND LICENSE
73              
74             This software is copyright (c) 2015 by Nickolay Platonov.
75              
76             This is free software; you can redistribute it and/or modify it under
77             the same terms as the Perl 5 programming language system itself.
78              
79             =cut