From c28a79010c94c3b9e963a96983f7458ef78838e1 Mon Sep 17 00:00:00 2001 From: matthewt Date: Tue, 8 Jul 2008 20:00:28 +0000 Subject: fixups in conversion script --- script/rclass_back_to_moose.pl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'script') 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; -- cgit v1.2.3-54-g00ecf