| 1 | 2 | ▶ | use 5.014; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | |||||||||||
| 3 | 2 | package Dist::Zilla::Plugin::MathInt64 0.10 { | |||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use Dist::Zilla::File::InMemory; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use ExtUtils::Typemaps; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | # ABSTRACT: Include the Math::Int64 C client API in your distribution | ||||||||||
| 10 | |||||||||||
| 11 | |||||||||||
| 12 | 2 | with 'Dist::Zilla::Role::Plugin'; | |||||||||
| 13 | 2 | with 'Dist::Zilla::Role::FileGatherer'; | |||||||||
| 14 | 2 | with 'Dist::Zilla::Role::FileMunger'; | |||||||||
| 15 | 2 | with 'Dist::Zilla::Role::PrereqSource'; | |||||||||
| 16 | |||||||||||
| 17 | 2 | has dir => ( | |||||||||
| 18 | is => 'ro', | ||||||||||
| 19 | ); | ||||||||||
| 20 | |||||||||||
| 21 | 2 | has typemap => ( | |||||||||
| 22 | is => 'ro', | ||||||||||
| 23 | default => 1, | ||||||||||
| 24 | ); | ||||||||||
| 25 | |||||||||||
| 26 | 2 | has typemap_path => ( | |||||||||
| 27 | is => 'ro', | ||||||||||
| 28 | default => 'typemap', | ||||||||||
| 29 | ); | ||||||||||
| 30 | |||||||||||
| 31 | 2 | ▶ | use constant _source_dir_default => do { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 2 | require File::ShareDir::Dist; | |||||||||
| 33 | 2 | require Path::Tiny; | |||||||||
| 34 | 2 | Path::Tiny->new(File::ShareDir::Dist::dist_share('Dist-Zilla-Plugin-MathInt64')); | |||||||||
| 35 | 2 | }; | |||||||||
| 36 | |||||||||||
| 37 | 2 | has _source_dir => ( | |||||||||
| 38 | is => 'ro', | ||||||||||
| 39 | lazy => 1, | ||||||||||
| 40 | default => \&_source_dir_default, | ||||||||||
| 41 | ); | ||||||||||
| 42 | |||||||||||
| 43 | sub gather_files | ||||||||||
| 44 | 5 | ▶ | { | ||||||||
|
Subroutine
gather_files: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||
| 45 | 5 | my($self) = @_; | |||||||||
| 46 | |||||||||||
| 47 | 5 | foreach my $source_name (qw( perl_math_int64.c perl_math_int64.h perl_math_int64_types.h )) | |||||||||
| 48 | { | ||||||||||
| 49 | 15 | ▶ | my $dst = defined $self->dir | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | ? join('/', $self->dir, $source_name) | ||||||||||
| 51 | : $source_name; | ||||||||||
| 52 | |||||||||||
| 53 | 15 | $self->log("create $dst"); | |||||||||
| 54 | 15 | $self->add_file( | |||||||||
| 55 | Dist::Zilla::File::InMemory->new( | ||||||||||
| 56 | name => $dst, | ||||||||||
| 57 | content => $self->_source_dir->child($source_name)->slurp, | ||||||||||
| 58 | ), | ||||||||||
| 59 | ); | ||||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 5 | ▶ | return unless $self->typemap; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | |||||||||||
| 64 | 4 | ▶ | unless(grep { $_->name eq $self->typemap_path } @{ $self->zilla->files }) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | { | ||||||||||
| 66 | 3 | $self->log("create " . $self->typemap_path); | |||||||||
| 67 | 3 | $self->add_file( | |||||||||
| 68 | Dist::Zilla::File::InMemory->new( | ||||||||||
| 69 | name => $self->typemap_path, | ||||||||||
| 70 | content => ExtUtils::Typemaps->new->as_string, | ||||||||||
| 71 | ), | ||||||||||
| 72 | ); | ||||||||||
| 73 | } | ||||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | sub munge_files | ||||||||||
| 77 | 5 | ▶ | { | ||||||||
|
Subroutine
munge_files: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||
| 78 | 5 | my($self) = @_; | |||||||||
| 79 | |||||||||||
| 80 | 5 | ▶ | return unless $self->typemap; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | |||||||||||
| 82 | 4 | my($file) = grep { $_->name eq $self->typemap_path } @{ $self->zilla->files }; | |||||||||
| 83 | |||||||||||
| 84 | 4 | ▶ | unless(defined $file) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | { | ||||||||||
| 86 | 0 | $self->log_fatal("unable to find " . $self->typemap_path . " which I should have created, perhaps another plugin pruned it?"); | |||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | 4 | $self->log("update " . $self->typemap_path); | |||||||||
| 90 | |||||||||||
| 91 | 4 | my $typemap = ExtUtils::Typemaps->new(string => $file->content); | |||||||||
| 92 | 4 | $typemap->merge( | |||||||||
| 93 | typemap => ExtUtils::Typemaps->new( | ||||||||||
| 94 | string => $self->_source_dir->child('typemap')->slurp, | ||||||||||
| 95 | ), | ||||||||||
| 96 | ); | ||||||||||
| 97 | 4 | $file->content($typemap->as_string); | |||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | sub register_prereqs | ||||||||||
| 101 | 5 | ▶ | { | ||||||||
|
Subroutine
register_prereqs: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 102 | 5 | my($self) = @_; | |||||||||
| 103 | |||||||||||
| 104 | 5 | $self->zilla->register_prereqs( | |||||||||
| 105 | { type => 'requires', phase => 'runtime' }, | ||||||||||
| 106 | 'Math::Int64' => '0.28', | ||||||||||
| 107 | ); | ||||||||||
| 108 | } | ||||||||||
| 109 | } | ||||||||||
| 110 | |||||||||||
| 111 | 2 | 1; | |||||||||
| 112 | |||||||||||
| 113 | __END__ | ||||||||||