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 checkwill 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 initAfter 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

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!
[...] get the new version. If you’re installing for the first time, refer to the original blog post for [...]
[...] the blog post about PureMVCGen here. Grab it, set it up, happy [...]
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!!
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.