File Coverage

blib/lib/Code/TidyAll/Role/HasIgnore.pm
Criterion Covered Total %
statement 28 29 96.5
branch 1 2 50.0
condition n/a
subroutine 9 9 100.0
pod n/a
total 38 40 95.0


line stmt bran cond sub pod time code
1             package Code::TidyAll::Role::HasIgnore;
2              
3 35     35   228997 use strict;
  35         102  
  35         1547  
4 35     35   194 use warnings;
  35         74  
  35         2367  
5              
6 35     35   228 use Code::TidyAll::Util::Zglob qw(zglobs_to_regex);
  35         101  
  35         2808  
7 35     35   489 use Specio::Library::Builtins;
  35         313  
  35         459  
8 35     35   370030 use Specio::Library::String;
  35         211  
  35         483  
9              
10 35     35   86981 use Moo::Role;
  35         432  
  35         457  
11              
12             our $VERSION = '0.85';
13              
14             has ignore => (
15             is => 'ro',
16             isa => t( 'ArrayRef', of => t('NonEmptyStr') ),
17             default => sub { [] },
18             );
19              
20             has ignore_regex => (
21             is => 'lazy',
22             isa => t('RegexpRef'),
23             );
24              
25             has ignores => (
26             is => 'lazy',
27             isa => t( 'ArrayRef', of => t('NonEmptyStr') ),
28             );
29              
30             has select => (
31             is => 'ro',
32             isa => t( 'ArrayRef', of => t('NonEmptyStr') ),
33             default => sub { [] },
34             );
35              
36             sub _build_ignores {
37 169     169   1990 my ($self) = @_;
38 169         758 return $self->_parse_zglob_list( $self->ignore );
39             }
40              
41             sub _parse_zglob_list {
42 264     264   1625 my ( $self, $zglobs ) = @_;
43 264 50       472 if ( my ($bad_zglob) = ( grep {m{^/}} @{$zglobs} ) ) {
  144         877  
  264         1465  
44 0         0 die qq{zglob '$bad_zglob' should not begin with slash};
45             }
46 264         5443 return $zglobs;
47             }
48              
49             sub _build_ignore_regex {
50 121     121   21276 my ($self) = @_;
51 121         226 return zglobs_to_regex( @{ $self->ignores } );
  121         2980  
52             }
53              
54             1;
55              
56             # ABSTRACT: A role for any class that has a list of ignored paths specified in zglob syntax
57              
58             __END__
59              
60             =pod
61              
62             =encoding UTF-8
63              
64             =head1 NAME
65              
66             Code::TidyAll::Role::HasIgnore - A role for any class that has a list of ignored paths specified in zglob syntax
67              
68             =head1 VERSION
69              
70             version 0.85
71              
72             =head1 SUPPORT
73              
74             Bugs may be submitted at L<https://github.com/houseabsolute/perl-code-tidyall/issues>.
75              
76             =head1 SOURCE
77              
78             The source code repository for Code-TidyAll can be found at L<https://github.com/houseabsolute/perl-code-tidyall>.
79              
80             =head1 AUTHORS
81              
82             =over 4
83              
84             =item *
85              
86             Jonathan Swartz <swartz@pobox.com>
87              
88             =item *
89              
90             Dave Rolsky <autarch@urth.org>
91              
92             =back
93              
94             =head1 COPYRIGHT AND LICENSE
95              
96             This software is copyright (c) 2011 - 2025 by Jonathan Swartz.
97              
98             This is free software; you can redistribute it and/or modify it under
99             the same terms as the Perl 5 programming language system itself.
100              
101             The full text of the license can be found in the
102             F<LICENSE> file included with this distribution.
103              
104             =cut