Announcing Mojolicious::Command::generate::routes_restsful and Mojolicious::Command::generate::routes_restsful_just_routes
Get everything you need from just a hash
My recent release of Mojolicious::Plugin::Routes::Restful inspired my to go a little beyond and create code that generates code.
I have never been a big fan of this getting something from nothing idea
I guess I can't understand the math, after I discovered that 6 x 9 = 42, it never seems to come out right.
I have used auto-generated of course and have never been that pleased with it. I have spent many a week trying to make some silly shlock together out of Dreamweaver work with real code.
I have also seen a front end just slapped onto a dump of a DB schema that was created with DBIX Class Schema Loader and even worse the same but using JAVA's Hibernate. How about a level of abstraction between??
So despite my misgivings I though I might as well do one for my routes restful code. To my surprise I have found it a really quick way to prototype out a web app and get a good working prototype in place without a good deal of fuss.
It also forces you to do a good design review of the flow of your app. Something to me that is always a weak point of most apps.
What I really liked is how much fun I had creating the generator code. It was quite simple and it really only took me a few hours to come up with both of them. It actually too me longer to fix my POD error than to write the code.
Seems the Mojo pattern for doing this type of thing is very easy to follow. Simply create a set of set of templates of what you want to create, then the process the data the user has inputted. Quick and easy with little fuss as all the funky file and folder creation commands are build into Mojo.
In Mojo parlance you are just creating a lite app to generate code which you then write to files ranter than serving it up to the web.
So go have a look at
Mojolicious::Command::generate::routes_restsful
if you want to create a prototype app from a hash
or
if you just need some route code go have a look at
Mojolicious::Command::generate::routes_restsful_just_routes
and get just the code for your routes.
The only caveat I have with my code is the test suite is rather weak. I have not figured out how to easily test what the expected outcome of a script running this code is. Though I have a look at Test::Script but I did not want to create a test suite that was larger than my code-base.
Well maybe for version 02 and 03.
Leave a comment