aboutsummaryrefslogtreecommitdiffstats
path: root/script
diff options
context:
space:
mode:
authormatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-07-08 20:00:28 +0000
committermatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-07-08 20:00:28 +0000
commitc28a79010c94c3b9e963a96983f7458ef78838e1 (patch)
tree8182696cd726fc2208ded329cd888201114ab123 /script
parent294263ca086f397e98ddf96bb02c51e1a405f325 (diff)
downloadreaction-c28a79010c94c3b9e963a96983f7458ef78838e1.tar.gz
reaction-c28a79010c94c3b9e963a96983f7458ef78838e1.zip
fixups in conversion script
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;