🕷 zenspider.com

by ryan davis



sitemap
Looking for the Ruby Quickref?

My Latest Projects - ZenLibrary and Graffle2SQL

Published 2005-01-22 @ 18:52

Tagged ruby, rails, toys

You have 323 books from 363 authors and 67 publishers, 274 CDs from 120 artists, 44 DVDs from 40 directors, 2 games on 2 platforms, filed in 26 categories and located in 6 locations.

that is the front page of my latest webapp. A learning project to learn Ruby On Rails, a very nice web app framework that combines MVC, dynamic coding, and ruby rather well.

  • milestone 1) book title and author - 10 minutes
  • milestone 2) separate author and book tables - 20 minutes
  • milestone 3) real data from my website + location and category tables - 30 minutes

one hour and I had a rather well functioning library app w/ all my books in it. Really.

several milestones later and I have a VERY well functioning library app, fully normalized using utilities I added to help me with that (FINALLY! LoC can bite my ass!), supporting books, music, video and games with all my data in it.

It even looks pretty (not that grayson thinks so…bastard):

library screenshot

Anyone who’s coded with me knows that while I try to make my code pretty, I don’t do interfaces. But… rails made it so easy to do everything else that I actually bothered to make it pretty.

To top it off, I started a side project. Using the latest (internal) version of omnigraffle and an applescript I wrote, I now have automatic SQL generation. No more SQL for me!

Check out the schema:

library schema

This was made with OmniGraffle (very very easily I might add, using OG4, which is not publicly available yet) and then automatically converted into an SQL schema via applescript.

Just to drive it home… I did this in 845 lines of ruby. (I think that number is model/controller only, not view):

+----------------------+-------+-------+---------+---------+-----+-------+
| Name                 | Lines |   LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers          |   665 |   558 |      14 |      92 |   6 |     4 |
| Helpers              |   212 |   189 |       0 |       8 |   0 |    21 |
| Models               |   113 |    98 |      13 |      11 |   0 |     6 |
|   Units              |   120 |    84 |      12 |      12 |   1 |     5 |
|   Functionals        |   867 |   670 |      26 |     123 |   4 |     3 |
+----------------------+-------+-------+---------+---------+-----+-------+
| Total                |  1977 |  1599 |      65 |     246 |   3 |     4 |
+----------------------+-------+-------+---------+---------+-----+-------+
  Code LOC: 845     Test LOC: 754     Code to Test Ratio: 1.1:1