Skip to content

Commit

Permalink
use new features
Browse files Browse the repository at this point in the history
  • Loading branch information
plicease committed Dec 19, 2024
1 parent a4b66ca commit 08a17c3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 35 deletions.
13 changes: 6 additions & 7 deletions lib/Dist/Zilla/Plugin/FFI.pm
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package Dist::Zilla::Plugin::FFI {
use strict;
use warnings;
use 5.020;
use true;

use strict;
use warnings;
use 5.020;
package Dist::Zilla::Plugin::FFI {

# ABSTRACT: FFI related Dist::Zilla plugins

Expand Down Expand Up @@ -31,6 +32,4 @@ Add L<FFI::CheckLib> checks into your C<Makefile.PL>.
=cut

}

1;
}
22 changes: 9 additions & 13 deletions lib/Dist/Zilla/Plugin/FFI/Build.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use 5.020;
use true;

package Dist::Zilla::Plugin::FFI::Build {

use 5.020;
use Moose;
use experimental qw( signatures );
use List::Util qw( first );

# ABSTRACT: Add FFI::Build to your Makefile.PL
Expand Down Expand Up @@ -125,9 +128,8 @@ EOF2
isa => 'Maybe[Str]',
);

sub munge_files
sub munge_files ($self)
{
my($self) = @_;
my $file = first { $_->name eq 'Makefile.PL' } @{ $self->zilla->files };
$self->log_fatal("unable to find Makefile.PL")
unless $file;
Expand All @@ -139,8 +141,7 @@ EOF2
$file->content($content);
}

sub register_prereqs {
my ($self) = @_;
sub register_prereqs ($self) {
$self->zilla->register_prereqs( +{
phase => 'configure',
type => 'requires',
Expand Down Expand Up @@ -170,17 +171,14 @@ EOF2

}

sub metadata
sub metadata ($self)
{
my($self) = @_;
my %meta = ( dynamic_config => 1 );
\%meta;
}

sub prune_files
sub prune_files ($self)
{
my($self) = @_;

my $lang = $self->lang;

foreach my $file ((), @{ $self->zilla->files })
Expand All @@ -203,6 +201,4 @@ EOF2
}

__PACKAGE__->meta->make_immutable;
}

1;
}
24 changes: 9 additions & 15 deletions lib/Dist/Zilla/Plugin/FFI/CheckLib.pm
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package Dist::Zilla::Plugin::FFI::CheckLib {
use 5.020;
use true;

use strict;
use warnings;
use 5.020;
package Dist::Zilla::Plugin::FFI::CheckLib {

# ABSTRACT: FFI::CheckLib alternative to Dist::Zilla::Plugin::CheckLib

use Moose;
use experimental qw( signatures );

with
'Dist::Zilla::Role::FileMunger',
'Dist::Zilla::Role::InstallTool',
Expand Down Expand Up @@ -52,8 +53,7 @@ package Dist::Zilla::Plugin::FFI::CheckLib {
$config
};

sub register_prereqs {
my ($self) = @_;
sub register_prereqs ($self) {
$self->zilla->register_prereqs( +{
phase => 'configure',
type => 'requires',
Expand All @@ -63,9 +63,7 @@ package Dist::Zilla::Plugin::FFI::CheckLib {
}

my %files;
sub munge_files {
my ($self) = @_;

sub munge_files ($self) {
my @mfpl = grep
{; $_->name eq 'Makefile.PL' or $_->name eq 'Build.PL' }
@{ $self->zilla->files };
Expand All @@ -79,9 +77,7 @@ package Dist::Zilla::Plugin::FFI::CheckLib {
()
}

sub setup_installer {
my ($self) = @_;

sub setup_installer ($self) {
my @mfpl = grep
{; $_->name eq 'Makefile.PL' or $_->name eq 'Build.PL' }
@{ $self->zilla->files };
Expand All @@ -103,9 +99,7 @@ package Dist::Zilla::Plugin::FFI::CheckLib {
()
}

sub _munge_file {
my ($self, $file) = @_;

sub _munge_file ($self, $file) {
my $orig_content = $file->content;
$self->log_fatal('could not find position in ' . $file->name . ' to modify!')
unless $orig_content =~ m/use strict;\nuse warnings;\n\n/g;
Expand Down
2 changes: 2 additions & 0 deletions t/00_diag.t
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ $modules{$_} = $_ for qw(
Path::Tiny
Test2::V0
Test::DZil
experimental
namespace::autoclean
true
);


Expand Down

0 comments on commit 08a17c3

Please sign in to comment.