New Moose for Old.

Some of you might remember an earlier post where I was playing about with ARIS Express and created an org chart to map out some of the roles that might be used in my AD&D Character class.

At the end of the post I mused about reading the ARIS file and gleaning out the data I just typed in and generating roles with them. Well I did spend a little time puttering about and even looked at 'FreeMind' and even at a new one called jsULM2. Well all of those where nice but each requires me to do a good deal of fudging to get anything out. Mostly silly little things like calling a UML 'stereotype' or 'multiplicity' a moose role and really It would be confusing to use.

Also had a quick peek on CPAN and found Padre::Plugin::Moose so I had to look at that. After I installed it I found 'Moose Assist' under the Tool menu and it looks like this;
Mooseass.jpg

So being one who likes to play about after about 5 minutes of typing I had this;

mooseass2.jpg
I then hit the 'Generate' button and got this


package RPG::ADD::Character;

use Moose;
use Moose::Util::TypeConstraints;

has 'charisma' => (
is => 'rw',
isa => 'Int',
required => 1,
);
has 'constitution' => (
is => 'rw',
isa => 'Int',
required => 1,
);
has 'dexterity' => (
is => 'rw',
isa => 'Int',
required => 1,
);
has 'intelligence' => (
is => 'rw',
isa => 'Int',
required => 1,
);
has 'name' => (
is => 'rw',
isa => 'Str',
required => 1,
);
has 'race' => (
is => 'rw',
isa => 'Race',
required => 1,
);
has 'strength' => (
is => 'rw',
isa => 'Int',
required => 1,
);

__PACKAGE__->meta->make_immutable;

no Moose;
1;

Really quite neat. Very close if not identical to my original class.

Not exactly what I wanted, as I was looking for something to generate code from an ULM doc or alike but then I fumbled across this Padre::Plugin::Autodia
which does the opposite turn code into UML docs.

However as the main point of this exercise is to type in all the simple stuff (classes,roles, attributes) only once and these two tools let me do that. In the end I get my boilerplate code and my my pointy haired boss get her pretty pictures.

Beauty!

Still a few little things that could be improved with this, delete doesn't work and it would be nice if it saved you code in different files rather than a big bag of them all but I can live with that.

I have about 10 classes to do tomorrow so I think it will be very well exercised by me soon.

293582_10150278563348382_5622664_n.jpg

Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations