File Coverage

lib/Dist/Zilla/Plugin/PruneAliases.pm
Criterion Covered Total %
statement 23 23 100.0
branch 4 4 100.0
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 34 35 97.1


line stmt bran cond sub pod time code
1 3     3   3956790 use 5.026;
  3         10  
2 3     3   15 use warnings;
  3         4  
  3         151  
3              
4             # ABSTRACT: Prune macOS aliases from your dist
5             $Dist::Zilla::Plugin::PruneAliases::VERSION = '1.00';
6              
7             use Dist::Zilla;
8 3     3   968 use Moose;
  3         2025382  
  3         108  
9 3     3   22 use namespace::autoclean;
  3         7  
  3         21  
10 3     3   18063  
  3         7  
  3         27  
11             with 'Dist::Zilla::Role::FilePruner';
12              
13              
14             my ($self) = @_;
15            
16 1     1 0 151997 my @aliases = grep { $self->_is_alias($_) } $self->zilla->files->@*;
17             $self->zilla->prune_file($_) for @aliases;
18 1         34 }
  7         50  
19 1         102  
20              
21             my ($self, $file) = @_;
22            
23             # Try to read macOS alias magic number
24 11     11   3359 open my $fh, '<:raw', $file->name or return;
25             read $fh, my $data, 16 or return;
26             close $fh;
27 11 100       50 return $data eq "book\0\0\0\0mark\0\0\0\0";
28 10 100       2303 }
29 8         99  
30 8         155  
31             __PACKAGE__->meta->make_immutable;
32              
33             1;
34              
35              
36             =pod
37              
38             =encoding UTF-8
39              
40             =head1 NAME
41              
42             Dist::Zilla::Plugin::PruneAliases - Prune macOS aliases from your dist
43              
44             =head1 VERSION
45              
46             version 1.00
47              
48             =head1 SYNOPSIS
49              
50             [PruneAliases]
51              
52             =head1 DESCRIPTION
53              
54             This tiny plugin prunes all macOS data fork alias files.
55             Works even on non-Mac operating systems.
56              
57             =head1 SEE ALSO
58              
59             L<Dist::Zilla::Plugin::PruneCruft>
60              
61             L<Mac::Alias>
62              
63             =head1 AUTHOR
64              
65             Arne Johannessen <ajnn@cpan.org>
66              
67             If you contact me by email, please make sure you include the word
68             "Perl" in your subject header to help beat the spam filters.
69              
70             =head1 COPYRIGHT AND LICENSE
71              
72             This software is Copyright (c) 2022 by Arne Johannessen.
73              
74             This is free software; you can redistribute it and/or modify it under
75             the terms of the Artistic License 2.0 or (at your option) the same terms
76             as the Perl 5 programming language system itself.
77              
78             =cut