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

filter: Statementstmt 100% 40 / 40 Branchbran 100% 10 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 3 totaltotal 95.1% 59 / 62 CC 8 SCAR 9.2
CC
8
Cov
100%
setup_installer
4.0
munge_files
3.0
munge_file
3.0
CRAP 2.5
↑ 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 1 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 package Dist::Zilla::Plugin::TextTabs 0.04 {
6  
7 1 ▶ use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶ use Text::Tabs qw( expand unexpand );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # ABSTRACT: Expand or unexpand tabs in your dist
11  
12  
13 1 with 'Dist::Zilla::Role::FileMunger',
14 'Dist::Zilla::Role::FileFinderUser' => {
15 default_finders => [ ':InstallModules', ':ExecFiles' ],
16 },
17 'Dist::Zilla::Role::InstallTool',
18 ;
19  
20 1 ▶ use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 has tabstop => (
23 is => 'ro',
24 isa => 'Int',
25 default => 8,
26 );
27  
28 1 has unexpand => (
29 is => 'ro',
30 isa => 'Bool',
31 default => 0,
32 );
33  
34 1 has installer => (
35 is => 'ro',
36 isa => 'Bool',
37 default => 0,
38 );
39  
40 sub munge_files
41 4 ▶ {
Subroutine munge_files: called CC=3 SCAR=11.0
Pod undocumented
42 4 my($self) = @_;
43 4 ▶ return if $self->installer;
Branch: 1 branch
BranchTrueFalseTotal
if $self->installer 1 3 4
44 3 $self->munge_file($_) for @{ $self->found_files };
45 }
46  
47 sub munge_file
48 4 ▶ {
Subroutine munge_file: called CC=3 SCAR=11.0
Pod undocumented
49 4 my($self, $file) = @_;
50 4 ▶ $self->log(($self->unexpand ? 'un' : '') . 'expanding ' . $file->name);
Branch: 1 branch
BranchTrueFalseTotal
$self->unexpand ? : 1 3 4
51 4 local $Text::Tabs::tabstop = $self->tabstop;
52 4 ▶ $file->content(join("\n", map { $self->unexpand ? unexpand @$_ : expand @$_ } [split /\n/, $file->content]));
Branch: 1 branch
BranchTrueFalseTotal
$self->unexpand ? : 1 3 4
53 4 return;
54 }
55  
56 sub setup_installer
57 4 ▶ {
Subroutine setup_installer: called CC=4 SCAR=13.9
Pod undocumented
58 4 my($self) = @_;
59 4 ▶ return unless $self->installer;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->installer 3 1 4
60 1 foreach my $file (@{ $self->zilla->files })
61 {
62 3 ▶ next unless $file->name =~ /^(Makefile|Build).PL$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $file->name =~ /^(Makefile|Build).PL$/u 2 1 3
63 1 $self->munge_file($file);
64 }
65 }
66  
67 1 __PACKAGE__->meta->make_immutable;
68 }
69  
70 1 1;
71  
72 __END__
↑ Summary