From 04061a7131ade4c9411380e6b2b61b1547751c38 Mon Sep 17 00:00:00 2001 From: dakkar Date: Tue, 27 Sep 2011 22:09:55 +0100 Subject: "use" seems to work --- lib/Dist/Zilla/Plugin/Boilerplate.pm | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'lib/Dist/Zilla') diff --git a/lib/Dist/Zilla/Plugin/Boilerplate.pm b/lib/Dist/Zilla/Plugin/Boilerplate.pm index 87e84a8..0a0d25e 100644 --- a/lib/Dist/Zilla/Plugin/Boilerplate.pm +++ b/lib/Dist/Zilla/Plugin/Boilerplate.pm @@ -4,10 +4,13 @@ use Moose; use namespace::autoclean; use PPI; use Moose::Autobox 0.09; +use Path::Class; #use This::Is::A::Test 'foo','bar'; #use This::Is::A::Test ('foo','bar'); #use This::Is::A::Test qw(foo bar); +# ABSTRACT: foo + with( 'Dist::Zilla::Role::FileMunger', 'Dist::Zilla::Role::FileFinderUser' => { @@ -30,7 +33,10 @@ has _parsed_code => ( ); sub _build_parsed_code { my ($self) = @_; - PPI::Document->new($self->code); + +warn "parsing ".$self->code."\n"; + + PPI::Document->new(\$self->code); } sub import { @@ -59,12 +65,22 @@ sub import { 1; } +sub _find_dzil_root { + my ($self,$filename) = @_; + + my $d = file($filename)->parent; + while ($d && ! glob($d->file('dist.*'))) { $d=$d->parent } + return $d; +} + sub eval_in { my ($self,$package) = @_; my $code = $self->code;my $name = $self->plugin_name; + my $str = "{package $package;$code;1}"; + warn "evaling $str\n"; local $@; - eval "package $package;$code;1" + eval $str or $self->log_error("Couldn't eval code for boilerplate $name into $package: $@"); } -- cgit v1.2.3