aboutsummaryrefslogtreecommitdiffstats
path: root/script/moose_to_rclass.pl
diff options
context:
space:
mode:
authormatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2007-09-12 18:11:34 +0000
committermatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2007-09-12 18:11:34 +0000
commit7adfd53f17f66ffe93763e944ed1d3fc52a369dc (patch)
tree19e599e74419b41cbbe651fd226b81e8b73551d3 /script/moose_to_rclass.pl
parentc728c97cb1061330e63c7cc048e768ef74988fe6 (diff)
downloadreaction-7adfd53f17f66ffe93763e944ed1d3fc52a369dc.tar.gz
reaction-7adfd53f17f66ffe93763e944ed1d3fc52a369dc.zip
moved shit to trunk
Diffstat (limited to 'script/moose_to_rclass.pl')
-rwxr-xr-xscript/moose_to_rclass.pl33
1 files changed, 33 insertions, 0 deletions
diff --git a/script/moose_to_rclass.pl b/script/moose_to_rclass.pl
new file mode 100755
index 0000000..67d0e73
--- /dev/null
+++ b/script/moose_to_rclass.pl
@@ -0,0 +1,33 @@
+#!/usr/bin/env perl
+
+# THIS IS A FUCKING CHEESY HACK. DON'T RUN IT ON ANYTHING YOU CARE ABOUT
+# (and don't have in svn at least. Oh, and it breaks horribly on with)
+
+use strict;
+use warnings;
+
+my $data;
+
+foreach my $file (@ARGV) {
+ open IN, $file;
+ { local $/; $data = <IN>; }
+ close IN;
+ unless ($data =~ m/(.*?\n)(?:extends (.*?);)?\n+?(has.*)\n(1;\s*\n.*)/s) {
+ warn "Failed to match for ${file}\n";
+ next;
+ }
+ my ($front, $super_list, $body, $rest) = ($1, $2, $3, $4);
+ my @supers = split(/\s*,\s*/, $super_list);
+ my $pkg = (split(/\//, $file))[-1];
+ $pkg =~ s/\.pm//;
+ $body =~ s/^sub (\S+) {$/method $1 => sub {/mg;
+ $body =~ s/^}$/};/mg;
+ $body =~ s/^(\S+) '([^\+]\S+)' =>/$1 $2 =>/mg;
+ $body =~ s/^/ /mg;
+ my $is_list = join('', map { "is $_, " } @supers);
+ open OUT, '>', $file;
+ print OUT "${front}class ${pkg} ${is_list}which {\n${body}\n};\n\n${rest}";
+ close OUT;
+}
+
+exit 0;