SmartLogic Logo (443) 451-3001

The SmartLogic Blog

SmartLogic is a web and mobile product development studio based in Baltimore. Contact us for help building your product or visit our website to learn more about what we do.

Introducing PureMVCGen – an ANT based PureMVC Flex Generator

December 5th, 2008 by

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 file containing 5 property settings:

  • app.prefix => what to prefix your Facade and application Mediator with
  • => 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:

app.prefix = Demo = 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 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

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

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.


  • Pingback: PureMVCGen 0.1.1 Released - Now Works on Windows « SmartLogic Solutions Blog

  • Pingback: PureMVCGen - A PureMVC Code Generator | The Flashchemist

  • Austin

    Hi, thanks for making a great tool available. I have just set up a project with it. I wished to used the multicore version of PureMVC but the multicore templates are not included in the download and thus you get an ant error. Are there templates for the multicore available. No worries if not thanks anyway!!

  • Greg Jastrab

    Austin, sorry but I haven’t gotten to the create the multicore templates yet. I’ll be sure to fit that into the next release when I have a chance to work on it.

  • Matthew Wallace

    Greg … looks like an awesome tool for sure. I am having an issue and wondered if you could point me in the right direction.

    I do the gem install just fine as you state above and it tells me that it was installed successfully. I then run the $>puremvc-gen check from within the project after setting up the file as you suggest and it says $>puremvc-gen: command not found.

    Is there any additional configuration to my system that needs to take place. I am on OS X 10.6


  • Matthew Wallace

    OK .. I answered my own question. for some reason I had to go into my home .bash_profile and export the path to my gems directory like so.

    export PATH=${PATH}:/Users/username/.gem/ruby/1.8/bin/

    it all seems to work great now.

    Thanks again for this great tool dude.


  • Greg Jastrab

    Thanks Matt, I haven’t given it any time in a while, but I hope you’ll find it useful.

    It sounds like you’re using a system ruby and not RVM, correct? When you install a gem it copies any executables to /usr/bin. I’m guessing the permissions failed to do that if you installed the gem without doing sudo. Try the following:

    gem uninstall puremvc-gen
    sudo gem install puremvc-gen
    which puremvc-gen

    The which command should tell you it’s at /usr/bin/puremvc-gen. Let me know if this doesn’t work for you.

  • mico

    Check out this new tool for Eclipse –

  • Arul Prasad

    Hi Greg,

    I was gonna patch up the multicore templates based on the standard version. Is there something I need to be aware of?

    Thanks for putting up this project!

  • Pingback: art plus code labs » Blog Archive » Pure Oxygen code generator for PureMVC

Greg Jastrab was a developer and project manager at SmartLogic from 2006 to 2011. Follow @gjastrab on twitter

Greg Jastrab's posts