aboutsummaryrefslogtreecommitdiffstats
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rw-r--r--script/rclass_back_to_moose.pl16
1 files changed, 8 insertions, 8 deletions
diff --git a/script/rclass_back_to_moose.pl b/script/rclass_back_to_moose.pl
index 0b5321f..d22700d 100644
--- a/script/rclass_back_to_moose.pl
+++ b/script/rclass_back_to_moose.pl
@@ -18,9 +18,9 @@ sub with_file (&) {
sub with_class_or_role_block (&) {
my ($code) = @_;
- $_ =~ s{^(?:class|role)\s*(.*?)which\s*{(.*?)^};}
+ $_ =~ s{^(class|role)\s*(.*?)which\s*{(.*?)^};}
{
- local *_ = { header => $1, body => $2 };
+ local *_ = { type => $1, header => $2, body => $3 };
$code->();
}sme;
}
@@ -29,7 +29,7 @@ sub parse_header {
my $h = $_{header};
$h =~ s/^\s*\S+\s+// || die;
my @base;
- while ($h =~ /is\s*(\S+?),?/g) {
+ while ($h =~ /is\s*([^ ,]+),?/g) {
push(@base, $1);
}
return @base;
@@ -50,16 +50,16 @@ sub sq { # short for 'strip quotes'
sub filtered_body {
local $_ = $_{body};
s/^ //g;
- s/implements *(\S+).*?{/"sub ${\sq $1} {"/ge;
- s/^does/with/g;
- s/^overrides/override/g;
+ s/^\s*implements *(\S+).*?{/"sub ${\sq $1} {"/ge;
+ s/^\s*does/with/g;
+ s/^\s*overrides/override/g;
$_;
}
sub top { "use namespace::clean -except => [ qw(meta) ];\n" }
-sub tail { "__PACKAGE__->meta->make_immutable;\n"; }
+sub tail { $_{type} eq 'class' ? "__PACKAGE__->meta->make_immutable;\n" : ""; }
-for ("lib/Reaction/InterfaceModel/Object.pm", "lib/Reaction/InterfaceModel/Action/DBIC/Result.pm") {
+for (@ARGV) {
with_file {
with_class_or_role_block {
return top.build_extends.filtered_body.tail;