hopefully now handles overrides and role
matthewt [Mon, 30 Jun 2008 19:49:49 +0000 (19:49 +0000)]
script/rclass_back_to_moose.pl

index 68dbd57..0b5321f 100644 (file)
@@ -16,9 +16,9 @@ sub with_file (&) {
   $data > io($fname);
 }
 
-sub with_class_block (&) {
+sub with_class_or_role_block (&) {
   my ($code) = @_;
-  $_ =~ s{^class\s*(.*?)which\s*{(.*?)^};}
+  $_ =~ s{^(?:class|role)\s*(.*?)which\s*{(.*?)^};}
          {
            local *_ = { header => $1, body => $2 };
            $code->();
@@ -52,6 +52,7 @@ sub filtered_body {
   s/^  //g;
   s/implements *(\S+).*?{/"sub ${\sq $1} {"/ge;
   s/^does/with/g;
+  s/^overrides/override/g;
   $_;
 }
 
@@ -60,7 +61,7 @@ sub tail { "__PACKAGE__->meta->make_immutable;\n"; }
 
 for ("lib/Reaction/InterfaceModel/Object.pm", "lib/Reaction/InterfaceModel/Action/DBIC/Result.pm") {
   with_file {
-    with_class_block {
+    with_class_or_role_block {
       return top.build_extends.filtered_body.tail;
     };
   };