blib/lib/File/Find/Rule/BOM.pm

filter: Statementstmt 100% 31 / 31 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 4 totaltotal 92.1% 47 / 51 SCAR 13.9
CC
4
Cov
100%
__ANON__
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
↑ Summary
1 package File::Find::Rule::BOM;
2  
3 6 ▶use base qw(File::Find::Rule);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 6 ▶use String::BOM qw(file_has_bom);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 6 our $VERSION = 0.02;
10  
11 # Detect BOM.
12 sub File::Find::Rule::bom {
13 1 ▶ my $file_find_rule = shift;
Subroutine bom: called CC=1 SCAR=0.0
Pod undocumented
14 1 return _bom($file_find_rule);
15 }
16  
17 # Detect UTF-8 BOM.
18 sub File::Find::Rule::bom_utf8 {
19 1 ▶ my $file_find_rule = shift;
Subroutine bom_utf8: called CC=1 SCAR=0.0
Pod undocumented
20 1 return _bom($file_find_rule, 'UTF-8');
21 }
22  
23 # Detect UTF-16 BOM.
24 sub File::Find::Rule::bom_utf16 {
25 1 ▶ my $file_find_rule = shift;
Subroutine bom_utf16: called CC=1 SCAR=0.0
Pod undocumented
26 1 return _bom($file_find_rule, 'UTF-16');
27 }
28  
29 # Detect UTF-32 BOM.
30 sub File::Find::Rule::bom_utf32 {
31 1 ▶ my $file_find_rule = shift;
Subroutine bom_utf32: called CC=1 SCAR=0.0
Pod undocumented
32 1 return _bom($file_find_rule, 'UTF-32');
33 }
34  
35 sub _bom {
36 4 ▶ my ($file_find_rule, $concrete_bom) = @_;
Subroutine _bom: called CC=1 SCAR=0.0
37 4 my $self = $file_find_rule->_force_object;
38 return $self->file->exec(sub{
39 16 ▶ my $file = shift;
Subroutine __ANON__: called CC=4 SCAR=13.9
40 16 my $bom = file_has_bom($file);
41 16 ▶ return 0 unless $bom;
Branch: 1 branch
BranchTrueFalseTotal
unless $bom 4 12 16
42 12 ▶ if ($concrete_bom) {
Branch: 1 branch
BranchTrueFalseTotal
if ($concrete_bom) { } 9 3 12
43 9 ▶ return $concrete_bom eq $bom ? 1 : 0
Branch: 1 branch
BranchTrueFalseTotal
$concrete_bom eq $bom ? : 3 6 9
44 } else {
45 3 return 1;
46 }
47 4 });
48 }
49  
50 6 1;
51  
52 __END__
↑ Summary