- loading...
Dr Nic at RubyConf 2007 – RubiGen – Teaser
4th of November 2007 – 9am – main conference room – RubyConf 2007…. comes … RubiGen.
Turn up the volume and enjoy that 80s theme music…
4th of November 2007 – 9am – main conference room – RubyConf 2007…. comes … RubiGen.
Turn up the volume and enjoy that 80s theme music…
I took a video recorder to the RejectConf, like I did in Portland. Unfortunately, there were two reasons I didn’t record any of them.
Firstly, there didn’t seem to be any obvious place to position the camera.
Secondly, it was deemed critical that everyone does their talks in the dark. The conference isn’t run in the dark, local Ruby groups don’t run meetings in the dark but consecutive RejectConfs have been run by adminstrators with a dark fetish. Great for drinking beer and heckling presenters. Bad for video recording.
The makers of the JVC HDD camcorder – a nifty device with a 20G HDD in it – don’t make it possible to record in the dark. Not because it doesn’t have a “night time mode” – apparently it does – but when you are already in the dark, you can’t figure out how to turn it on.
Ok, fine, if I’d made an effort I could have figured it out. So, let’s use excuse #1 as the reason for not recording the presentations.
Its a valid excuse, the Pirate Cove was chock-a-block full of people. The local Berlin Ruby Group did an awesome job of finding a great “underground”-esque venue.
Fortunately a fellow Australian – Marcus Crafter – had a front row position, and a MacBook Pro. With said device, he captured my talk on RubiGen (and John Barton’s).
In 5 minutes, I make a Merb generator, using RubiGen and NewGem. Nifty stuff indeed.
There were lots of other awesome presentations (that is perhaps a dubious inference that mine was awesome), but it was dark, I had beer in both hands, and I was too busy yelling “AUSTRALIA!!!” to write notes.
What a great night
Neat. Here is Ze Frank at TED 20062004 [thx Erik Kastner]. A lot of the material is similar to the 2nd half of his Railsconf presentation; so if you missed it or miss it, check it out…
One day you will be able to write a human description of a RubyGem and it will make it for you. Ok, that’s crap. But the New Gem Generator is doing more and more cooler things lately; so let’s take a peek…
For a growing number of people, RSpec is the way to go, over the Test::Unit test suite. Now, thanks to a contribution from Robby Russell and Graeme Nelson during Railsconf.
$ newgem my_cool_gem -t rspec
$ cd my_cool_gem
$ rake # runs specs
New gems now have a website folder with an index.txt file (redcloth format). Put your glorious promotional materials and tutorials here (plus add additional .txt files as well) and the rake website task will convert them to html files and upload them to your rubyforge website.
The standard template looks like this (you’re encouraged to change some colours or fonts!)
Ready to release a new X.Y.Z version of your gem? It takes 3 minutes.
lib//version.rb .rake check_manifest)History.txt with changes. The default supported format is 2 paragraphs – a header and group of bullet points; these look nice when converted to rdoc format.$ rake deploy VERSION=X.Y.Z
This will release your RubyGem to rubyforge so people can install it; plus upload your website and your rdocs.
You’ll then be prompted to commit a copy of the trunk as a tag REL-X.Y.Z. This could be very useful one day!
You can read the pdf slides and/or watch the presentation from RejectConf:
Update: there is a patch available for edge rails to support merging by generators; add comments to the ticket.
The original Dr Nic’s Magic Models were named as such because I entertained the idea of showing them off as a live magic show. So, given 3 minutes in front of some of the Ruby community’s hottest hackers, I got my chance! Not the Original Magic Models, but the never-before-released Magic Model Generator.
How to install and use the magic_model_generator follows the video from RejectConf:
Create a rails application, and point it to your database.
$ rails magic_show -d [mysql|sqlite|postgresql|oracle|etc|etc] $ cd magic_show $ cp database.yml.sample database.yml and point it to your database.yml to your legacy database
I use the database created for the ActiveRecord test cases – activerecord_unittest. If you’ve never downloaded the activerecord gem, run rake build_[mysql|sqlite|postgresql|oracle|etc|etc]_databases, and then rake test_[mysql|sqlite|postgresql|oracle|etc|etc], then you’ve probably got more free time than I do as a result and I appreciate that. And so does my wife.
Now install the magic_model_generator gem:
$ sudo gem install magic_model_generator
Nonetheless, you’re done. That’s all the preparation I did for the video.
Next I recreated the schema.rb file and the schema_info database table via rake db:migrate.
Next I ran the generator:
$ ./script/generate magic_model
And we’re done.
The MMG is awesome.
The one major drawback of the MMG is the same drawback of all rails generators: if you want to regenerate your models (say you update your schema via migrations) then you cannot regenerate your model associations and validations without completely recreating the file, thus destroying anything else you wrote. Which is useless.
The world of version control (subversion, cvs, etc etc) already solved this problem: merging. So I’m investigating adding merging to the rails_generator. That should be neat.
Currently the newgem command doesn’t use the rails_generator for creating files. So adding merging to rails_generator won’t help newgem. That is, unless I rewrite newgem. So, I’ll look into that too.