| 1 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 2 | ▶ | use 5.022; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 2 | package Dist::Zilla::Plugin::AlienBuild::Mint 0.07 { | |||||||||
| 6 | |||||||||||
| 7 | 2 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | with 'Dist::Zilla::Role::FileGatherer', 'Dist::Zilla::Role::ModuleMaker'; | |||||||||
| 9 | 2 | ▶ | use experimental qw( signatures postderef ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 2 | ▶ | use Alien::Build::Wizard; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 2 | ▶ | use Dist::Zilla::File::InMemory; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 2 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | # ABSTRACT: Generate module and alienfile for use with Alien::Build | ||||||||||
| 15 | |||||||||||
| 16 | has class_name => ( | ||||||||||
| 17 | is => 'ro', | ||||||||||
| 18 | isa => 'Str', | ||||||||||
| 19 | init_arg => undef, | ||||||||||
| 20 | lazy => 1, | ||||||||||
| 21 | 1 | ▶ | default => sub ($self) { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 1 | $self->zilla->name =~ s/-/::/gr; | |||||||||
| 23 | }, | ||||||||||
| 24 | 2 | ); | |||||||||
| 25 | |||||||||||
| 26 | has generated_content => ( | ||||||||||
| 27 | is => 'ro', | ||||||||||
| 28 | isa => 'HashRef[Str]', | ||||||||||
| 29 | init_arg => undef, | ||||||||||
| 30 | lazy => 1, | ||||||||||
| 31 | 1 | ▶ | default => sub ($self) { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.4
| |||||||||||
| 32 | |||||||||||
| 33 | 1 | my $wizard = Alien::Build::Wizard->new( | |||||||||
| 34 | class_name => $self->class_name | ||||||||||
| 35 | ); | ||||||||||
| 36 | |||||||||||
| 37 | 1 | my %files = $wizard->generate_content->%*; | |||||||||
| 38 | |||||||||||
| 39 | 0 | \%files; | |||||||||
| 40 | } | ||||||||||
| 41 | 2 | ); | |||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | sub gather_files ($self) | ||||||||
|
Subroutine
gather_files: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 44 | { | ||||||||||
| 45 | 0 | my %files = $self->generated_content->%*; | |||||||||
| 46 | |||||||||||
| 47 | 0 | foreach my $filename (sort keys %files) | |||||||||
| 48 | { | ||||||||||
| 49 | # TODO: needs updating if we have other generated | ||||||||||
| 50 | # files in lib which we probably will not need. | ||||||||||
| 51 | 0 | ▶ | next if $filename =~ /^lib/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 0 | my $dz_filename = $filename; | |||||||||
| 53 | 0 | $self->log("making $filename from template"); | |||||||||
| 54 | my $file = Dist::Zilla::File::InMemory->new({ | ||||||||||
| 55 | name => $dz_filename, | ||||||||||
| 56 | 0 | content => $files{$filename}, | |||||||||
| 57 | }); | ||||||||||
| 58 | 0 | $self->add_file($file); | |||||||||
| 59 | } | ||||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 1 | ▶ | sub make_module ($self, $arg) | ||||||||
|
Subroutine
make_module: called CC=4 SCAR=27.9
Pod
undocumented
| |||||||||||
| 63 | { | ||||||||||
| 64 | 1 | my %files = $self->generated_content->%*; | |||||||||
| 65 | 0 | ▶ | $self->log_fatal("Confused by module filename") unless defined $arg->{name} ne $self->class_name; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | 0 | foreach my $filename (sort keys %files) | |||||||||
| 67 | { | ||||||||||
| 68 | # TODO: needs updating if we have other generated | ||||||||||
| 69 | # files in lib which we probably will not need. | ||||||||||
| 70 | 0 | ▶ | next unless $filename =~ /^lib/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 71 | 0 | my $dz_filename = $filename; | |||||||||
| 72 | 0 | $self->log("making module $filename from template"); | |||||||||
| 73 | my $file = Dist::Zilla::File::InMemory->new({ | ||||||||||
| 74 | name => $dz_filename, | ||||||||||
| 75 | 0 | content => $files{$filename}, | |||||||||
| 76 | }); | ||||||||||
| 77 | 0 | $self->add_file($file); | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | 2 | 1; | |||||||||
| 86 | |||||||||||
| 87 | __END__ | ||||||||||