| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 60 | 1 | foreach my $file (@{ $self->zilla->files }) | |||||||||
| 61 | { | ||||||||||
| 62 | 3 | ▶ | next unless $file->name =~ /^(Makefile|Build).PL$/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 1 | $self->munge_file($file); | |||||||||
| 64 | } | ||||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 1 | 1; | |||||||||
| 71 | |||||||||||
| 72 | __END__ | ||||||||||