summaryrefslogtreecommitdiff
path: root/lib/Dist/Zilla
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2011-09-27 22:21:31 +0100
committerdakkar <dakkar@thenautilus.net>2011-09-27 22:21:31 +0100
commit759cd17a95f8819076751dd50bdf43c568aacb0f (patch)
treece0e478fb937e1d60486fbf8aa69ab1c9a6b4d94 /lib/Dist/Zilla
parentignores (diff)
downloaddzil-boilerplate-759cd17a95f8819076751dd50bdf43c568aacb0f.tar.gz
dzil-boilerplate-759cd17a95f8819076751dd50bdf43c568aacb0f.tar.bz2
dzil-boilerplate-759cd17a95f8819076751dd50bdf43c568aacb0f.zip
works! apart from tag extraction…
Diffstat (limited to 'lib/Dist/Zilla')
-rw-r--r--lib/Dist/Zilla/Plugin/Boilerplate.pm26
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/Dist/Zilla/Plugin/Boilerplate.pm b/lib/Dist/Zilla/Plugin/Boilerplate.pm
index 0a0d25e..4686a22 100644
--- a/lib/Dist/Zilla/Plugin/Boilerplate.pm
+++ b/lib/Dist/Zilla/Plugin/Boilerplate.pm
@@ -14,14 +14,20 @@ use Path::Class;
with(
'Dist::Zilla::Role::FileMunger',
'Dist::Zilla::Role::FileFinderUser' => {
- default_finders => [ ':InstallModules', ':ExecFiles' ],
+ default_finders => [
+ ':InstallModules',
+ ':IncModules',
+ ':ExecFiles',
+ ':TestFiles',
+ ],
},
'Dist::Zilla::Role::PPI',
);
+sub mvp_multivalue_args { 'code' };
has code => (
is => 'ro',
- isa => 'Str',
+ isa => 'ArrayRef[Str]',
required => 1,
);
@@ -34,9 +40,8 @@ has _parsed_code => (
sub _build_parsed_code {
my ($self) = @_;
-warn "parsing ".$self->code."\n";
-
- PPI::Document->new(\$self->code);
+ my $code = $self->code->join("\n");
+ PPI::Document->new(\$code);
}
sub import {
@@ -76,9 +81,8 @@ sub _find_dzil_root {
sub eval_in {
my ($self,$package) = @_;
- my $code = $self->code;my $name = $self->plugin_name;
+ my $code = $self->code->join("\n");my $name = $self->plugin_name;
my $str = "{package $package;$code;1}";
- warn "evaling $str\n";
local $@;
eval $str
or $self->log_error("Couldn't eval code for boilerplate $name into $package: $@");
@@ -101,10 +105,14 @@ sub munge_file {
$element->module eq __PACKAGE__
}
);
+ return unless $my_uses;
for my $use ($my_uses->flatten) {
my $tags = $self->_find_tags_from_ppi($use->arguments);
if ($tags->first(sub{$_ eq $self->plugin_name})) {
- $use->insert_after($self->_parsed_code);
+ for my $elem ($self->_parsed_code->children) {
+ $use->insert_before($elem)
+ or $self->log_warn("Couldn't insert $elem before $use\n");
+ }
$use->delete;
}
}
@@ -114,7 +122,7 @@ sub munge_file {
sub _find_tags_from_ppi {
my ($self,$node) = @_;
- return (); # ehm
+ return 'foo';
}
}
package Dist::Zilla::Plugin::Boilerplate::Chrome;{