Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow non-bundling use of [AssertOS] #3

Merged
merged 2 commits into from Oct 4, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 27 additions & 3 deletions lib/Dist/Zilla/Plugin/AssertOS.pm
Expand Up @@ -6,6 +6,7 @@ use Moose;
with 'Dist::Zilla::Role::FileGatherer';
with 'Dist::Zilla::Role::InstallTool';
with 'Dist::Zilla::Role::MetaProvider';
with 'Dist::Zilla::Role::PrereqSource';

use File::Spec;

Expand All @@ -18,6 +19,12 @@ has 'os' => (
auto_deref => 1,
);

has 'bundle' => (
is => 'ro',
isa => 'Bool',
default => 1,
);

sub metadata {
return {
no_index => {
Expand All @@ -26,9 +33,24 @@ sub metadata {
};
}

sub register_prereqs {
my $self = shift;
return if $self->bundle;
$self->zilla->register_prereqs(
{
phase => 'configure',
type => 'requires',
},
'Devel::CheckOS' => '1.63',
'Devel::AssertOS' => '0',
);
}

sub gather_files {
my $self = shift;


return unless $self->bundle;

require Data::Compare;

foreach my $os ( $self->os ) {
Expand Down Expand Up @@ -85,7 +107,9 @@ sub setup_installer {
$self->log_fatal('No Makefile.PL or Build.PL was found. [AssertOS] should appear in dist.ini after [MakeMaker] or [ModuleBuild]!') unless @mfpl;

for my $mfpl ( @mfpl ) {
my $content = qq{use lib 'inc';\nuse Devel::AssertOS qw[};
my $content = qq{};
$content .= qq{use lib 'inc';\n} if $self->bundle;
$content .= qq{use Devel::AssertOS qw[};
$content .= join ' ', $self->os;
$content .= "];\n";
$mfpl->content( $content . $mfpl->content );
Expand All @@ -96,7 +120,7 @@ sub setup_installer {
__PACKAGE__->meta->make_immutable;
no Moose;

qq[run run Reynard]
qq[run run Reynard];

=pod

Expand Down