Wednesday, November 29, 2006

Creatively Captivated

About 1 year ago, the developers of Lightsky went to the Snakes and Rubies seminar in Chicago (Dec 3, 2005). The event really got us talking and thinking. Corporately we decided to shift from PHP to Ruby on Rails. The decision has proven to be exhilarating. We started using Subversion. We started work on a core infrastructure that has been unit tested (and is being re-factored to REST). We are able to easily re-use code that is freely available (thank heaven for well tested plugins).

I owe a lot to that trip.

$ raving_ruby_fanboy += 1

Tuesday, November 28, 2006

Peepcode's Restful Rails

I just finished watching Peepcode's Restful-Rails video. I highly recommend it. I've followed the RESTful push by the rails team, but I haven't seen the true impact. And now, having watched the video, I'm in the mood to re-factor the existing code for my project. I'm going to refrain from this refactoring because of the complications of the existing code-base. However, I'm curious to see what can come of this. The next project I work on will make use of REST.

Monday, November 27, 2006

Loving the test dots ..................F.....................

For the past while, I've been working on the largest project my company ( has ever undertaken. The scope is rather large and requires lots of data import. To make sure that we got off on the right foot, we spent a lot of time (perhaps too much) developing our framework for what is to come. One of the issues was that we were dealing with a very abstract tool in the beginning (an authorization system).

It has taken a lot of back and forth work, and a lot of diagramming and what-if scenarios. But in the end, I really think the system that we have is rather impressive. I also thank heaven that it is being developed in Ruby (forget Rails for the moment). Prior to Ruby, I had programmed in RPG, VBA, Cool: Plex (a CA case tool), PHP (only 3 months!) and Lotus Notes. One thing that was missing from all of these was a tightly integrated unit test suite. Ruby does this, and does it rather well. I'm certain there are test suites out there, but to have it built right into the language's core functions is shear brilliance.

Now, if I write good tests (which is a challenge as well), I can rest assured that my code works how I say it should work. This allows me to more easily pass the tool off and let others poke around with it. And, if a test breaks, its something they should look into. I have never felt so liberated by applying the constraint of testing as much as I can.

Sunday, November 26, 2006

Creating a unified UI

I've been working on a site that makes use of a view mixin structure. If the view is defined in the for the controller, use it, otherwise use the default view for that action. The views are very atomized [list.rhtml, _list.rhtml, _list_search_panel.rhtml, _list_search_form.rhtml, _list_table.rhtml, _list_table_head.rhtml, _list_table_row.rhtml]. It works great, but there are limitations. Now, the system was not created by me, but had input from me, so I'm not going to bad-mouth it. But what it has gotten me thinking about is my need for an ActionHelper object.

The ActionHelper object would be responsible for knowing what the breadcrumb trail should be as well as the page title, and "tabs" that should be on the page, actions that can be taken, the current location in the menu list. As of right now, this idea is sort of floating around gathering mental momentum. The purpose of this ActionHelper object is to create the interface for building a unified UI.

BAB ruby class for OGL system

Jamis Buck's Dice class inspired me (a lot). A few weeks ago, I decided to start thinking about a role-playing session manager. I'm still thinking about it, but in the interim, I started work on a few classes, just to "feel better". Included below is a BAB class. It is released as OGC as described by the OGL. This class also has associated tests, if you are truly curious.

$ 5.bab.good
=> 5

$ 4.bab.poor # Suck it wizard
=> 2

$ 3.bab.medium + 5.bab.poor + 3.bab.poor # 3 Rogue / 5 Wizard / 3 Arcane Trickster
=> 5

class Bab
class InvalidCount < Exception # :nodoc:
TYPES = [:good, :medium, :poor]
attr_reader :count, :epic_count

def initialize( count )
raise InvalidCount unless count.is_a?(Integer) && count > 0
@count = count > 20 ? 20 : count
@epic_count = count > 20 ? count - 20 : 0

def good
self.count + epic_value

def medium
((self.count * 3) / 4) + epic_value

def poor
(self.count / 2) + epic_value

def epic_value
(self.epic_count + 1) / 2


class Integer
def bab

The Open Game License for Items posted on this blog.


The following text is the property of Wizards of the Coast, Inc. and is Copyright 2000 Wizards of the Coast, Inc ("Wizards"). All Rights Reserved.

1. Definitions: (a)"Contributors" means the copyright and/or trademark owners who have contributed Open Game Content; (b)"Derivative Material" means copyrighted material including derivative works and translations (including into other computer languages), potation, modification, correction, addition, extension, upgrade, improvement, compilation, abridgment or other form in which an existing work may be recast, transformed or adapted; (c) "Distribute" means to reproduce, license, rent, lease, sell, broadcast, publicly display, transmit or otherwise distribute; (d)"Open Game Content" means the game mechanic and includes the methods, procedures, processes and routines to the extent such content does not embody the Product Identity and is an enhancement over the prior art and any additional content clearly identified as Open Game Content by the Contributor, and means any work covered by this License, including translations and derivative works under copyright law, but specifically excludes Product Identity. (e) "Product Identity" means product and product line names, logos and identifying marks including trade dress; artifacts; creatures characters; stories, storylines, plots, thematic elements, dialogue, incidents, language, artwork, symbols, designs, depictions, likenesses, formats, poses, concepts, themes and graphic, photographic and other visual or audio representations; names and descriptions of characters, spells, enchantments, personalities, teams, personas, likenesses and special abilities; places, locations, environments, creatures, equipment, magical or supernatural abilities or effects, logos, symbols, or graphic designs; and any other trademark or registered trademark clearly identified as Product identity by the owner of the Product Identity, and which specifically excludes the Open Game Content; (f) "Trademark" means the logos, names, mark, sign, motto, designs that are used by a Contributor to identify itself or its products or the associated products contributed to the Open Game License by the Contributor (g) "Use", "Used" or "Using" means to use, Distribute, copy, edit, format, modify, translate and otherwise create Derivative Material of Open Game Content. (h) "You" or "Your" means the licensee in terms of this agreement.

2. The License: This License applies to any Open Game Content that contains a notice indicating that the Open Game Content may only be Used under and in terms of this License. You must affix such a notice to any Open Game Content that you Use. No terms may be added to or subtracted from this License except as described by the License itself. No other terms or conditions may be applied to any Open Game Content distributed using this License.

3.Offer and Acceptance: By Using the Open Game Content You indicate Your acceptance of the terms of this License.

4. Grant and Consideration: In consideration for agreeing to use this License, the Contributors grant You a perpetual, worldwide, royalty-free, non-exclusive license with the exact terms of this License to Use, the Open Game Content.

5.Representation of Authority to Contribute: If You are contributing original material as Open Game Content, You represent that Your Contributions are Your original creation and/or You have sufficient rights to grant the rights conveyed by this License.

6.Notice of License Copyright: You must update the COPYRIGHT NOTICE portion of this License to include the exact text of the COPYRIGHT NOTICE of any Open Game Content You are copying, modifying or distributing, and You must add the title, the copyright date, and the copyright holder's name to the COPYRIGHT NOTICE of any original Open Game Content you Distribute.

7. Use of Product Identity: You agree not to Use any Product Identity, including as an indication as to compatibility, except as expressly licensed in another, independent Agreement with the owner of each element of that Product Identity. You agree not to indicate compatibility or co-adaptability with any Trademark or Registered Trademark in conjunction with a work containing Open Game Content except as expressly licensed in another, independent Agreement with the owner of such Trademark or Registered Trademark. The use of any Product Identity in Open Game Content does not constitute a challenge to the ownership of that Product Identity. The owner of any Product Identity used in Open Game Content shall retain all rights, title and interest in and to that Product Identity.

8. Identification: If you distribute Open Game Content You must clearly indicate which portions of the work that you are distributing are Open Game Content.

9. Updating the License: Wizards or its designated Agents may publish updated versions of this License. You may use any authorized version of this License to copy, modify and distribute any Open Game Content originally distributed under any version of this License.

10 Copy of this License: You MUST include a copy of this License with every copy of the Open Game Content You Distribute.

11. Use of Contributor Credits: You may not market or advertise the Open Game Content using the name of any Contributor unless You have written permission from the Contributor to do so.

12 Inability to Comply: If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Open Game Content due to statute, judicial order, or governmental regulation then You may not Use any Open Game Material so affected.

13 Termination: This License will terminate automatically if You fail to comply with all terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses shall survive the termination of this License.

14 Reformation: If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.

Open Game License v 1.0 Copyright 2000, Wizards of the Coast, Inc.

Jeremy Friesen copyright

OPEN GAME CONTENT: Open game content will in box, as indicated below.

This is open game content

OSX and Textmate and Ruby

This morning I spent an hour reviewing Textmate's Rails and Ruby bundle. Trying to eek out any bits of efficiency that I can. I was particularly interested in the Rails > Model > Show DB Schema for Current Class command. I tried to run it, and it squacked. The process.rb file said that rubygems was missing. Odd.

So time for a little hacking. I added `echo $PATH` and it returned rather odd results (at least as I was envisioning). It had omitted /usr/local/bin, which is where my primary ruby installation can be found. I checked the Textmate documentation, and all should have been well. In my ~/.bash_profile I was prepending /usr/local/bin, but this was not registering. So the fix I settled on was modifying /etc/profile (and restarting my machine).

With the changes in place the command worked splendidly.

As if to pretend like I'll post to this thing

This afternoon and evening, I spent most of my time verifying that the internet had not in fact gone anywhere. I checked my feeds, eager to find something new to read. I ended up reading several IBM articles related to Ruby and helped a friend with his statistics. All told, a rather fruitless day.