Introducing PureMVCGen - an ANT based PureMVC Flex Generator

I just published a PureMVC code generation tool I've been working on lately. It's an ANT-based tool, but is distributed via Ruby Gems, which allows it to be easily installed as a command-line tool once you have Ruby, rubygems, and ANT installed.

Once you have those programs installed, simply enter ($> just denotes you are at a prompt on the command line)

$> gem install puremvc-gen

and the tool will be installed. Read on to see how to use it...

Project Settings

Presently, there is one bit of configuration housekeeping that must be done to get started using the tool. Within the source directory of your project you will need to add a proj.properties file containing 5 property settings:

  • app.prefix => what to prefix your Facade and application Mediator with
  • project.name => the name of your main MXML file
  • core.namespace => the namespace of the project
  • core.dir => the directory corresponding to the namespace (this will eventually be inferred from core.namespace )
  • pmvc.flavor => standard | multicore (although only standard is currently supported)

An example configuration for a project called MyDemo using the namespace com.mydemo.demo would look like:

Example proj.properties
app.prefix = Demo
project.name = MyDemo
core.namespace = com.mydemo.demo
core.dir = com/mydemo/demo
pmvc.flavor = standard

Using PureMVCGen

Validating Project Properties

If you are starting a new PureMVC project and you have the proj.properties file created in the source directory:

$> puremvc-gen check

will ensure that the properties are correctly set. If they have been, at the end of the ANT output, you should see:

Display showing properties have been validated

Generating the PureMVC Skeleton

To generate the PureMVC directories, main MXML file, Facade, main Mediator, StartupCommand, and PrepareActorsCommand classes, simply enter:

$> puremvc-gen init

After this was run successfully the directory hierarchy will look something like this:

PureMVC skeleton generated from demo project properties

Other Commands

I haven't created any online documentation yet, but the tool has fairly decent instructions on the command line.

$> puremvc-gen help

 

Instructions output on command line when running "help"

A quick rundown of the command, proxy, and mediator generation commands:

  • puremvc-gen new command => generates a simple command
  • puremvc-gen new command -m (or --macro) => generates a macro command
  • puremvc-gen new mediator => generates a mediator
  • puremvc-gen new proxy => generates a proxy

All of these generation commands may be passed a -n option to specify the name for the class on the command line. Otherwise, ANT will prompt you to input the name.

Where to Git It

The project is hosted at github so feel free to checkout the source. I'll update the README file eventually so that front page will have documentation as well.

The gem is also hosted at RubyForge so you can download it there if you'd like to build it manually.

The GitHub page will eventually include a Roadmap for planned features, but please comment here with any suggestions you may have.

Finally, if you're averse to Ruby you can always download the conf/ directory of the project, and manually run the ANT commands. They are a bit more cryptic though, which is why the gem and executable it provides are nice, however it should output instructions on what settings need to be made to run it manually.

Enjoy!

Author image

About Greg Jastrab

You've successfully subscribed to SmartLogic Blog
Great! Next, complete checkout for full access to SmartLogic Blog
Welcome back! You've successfully signed in.
Unable to sign you in. Please try again.
Success! Your account is fully activated, you now have access to all content.
Error! Stripe checkout failed.
Success! Your billing info is updated.
Error! Billing info update failed.