dastels @ 8:45 pm
Here’s an article I wrote a while ago but didn’t get around to releasing. Enjoy.
Describing Equivalence Classes in Ruby with RSpec
Since writing that article, I’ve made good use of the code. Here’s an example of it in action: grouping the cards in a deck into their types. A second method then uses those groups to reassemble the cards into an ordered list.
CARD_TYPES = ['basic land', 'land', 'creature', 'artifact',
'enchantment', 'sorcery', 'instant', '']
def maindeck_cards_grouped
maindeck_cards.equivalence_classes(*CARD_TYPES) do |card, the_type|
card.magic_card.card_type.downcase.include?(the_type)
end
end
def maindeck_cards_ordered
cards_by_class = maindeck_cards_grouped
(CARD_TYPES.inject([]) {|cards, type| cards << cards_by_class[type]}).flatten
end
dastels @ 5:18 am
The stats for our project:
+----------------------+-------+-------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 70 | 55 | 2 | 6 | 3 | 7 |
| Helpers | 6 | 4 | 0 | 0 | 0 | 0 |
| Models | 891 | 734 | 13 | 110 | 8 | 4 |
| Libraries | 0 | 0 | 0 | 0 | 0 | 0 |
| Model specs | 2283 | 1835 | 0 | 0 | 0 | 0 |
| View specs | 0 | 0 | 0 | 0 | 0 | 0 |
| Controller specs | 0 | 0 | 0 | 0 | 0 | 0 |
| Helper specs | 0 | 0 | 0 | 0 | 0 | 0 |
+----------------------+-------+-------+---------+---------+-----+-------+
| Total | 3250 | 2628 | 15 | 116 | 7 | 20 |
+----------------------+-------+-------+---------+---------+-----+-------+
Code LOC: 793 Test LOC: 1835 Code to Test Ratio: 1:2.3
A few things to notice:
- very “rails” light… small controller… very literally a controller.. all the action happens in the models,
- all the specs are for model classes, the controller & view do very little.. although the controller could probably do with a few specs, and
- there’s over twice as much code in the specs than in the working classes.
The spec run:
$rake spec
(in /Users/dastels/Projects/Ruby-Projects/merlin/trunk)
..........................................................................
..........................................................................
..........................................................................
........................................................
Finished in 62.891545 seconds
278 examples, 0 failures
and the coverage report:
 |
| Note that echo was under development and actually didn’t get finished in time. Also we ran out of time before getting to mindbender. |
dastels @ 3:11 am
Rails Rumble ’07 is over.
It was a total good time.We didn’t get as much done on our app as we had hoped, but what we got done turned out as well as we could have hoped.I was on the IRC channel the whole time pretty much, which provided a nice sideline. The whole thing had a strong co-opatition feel. There was a great group of people involved.
A big THANK YOU to the sponsors, the organisers, the other teams, and mostly to my teammate, Nancy.
We ran into some interesting technical issues in the course of the 48 hours, which I’ll be writing about over the next few days.For those interested, or just with voyeristic tendancies (ain’t the web great), there’s a flickr pool, and I’ve posted some pics in my .mac gallery.
dastels @ 4:37 am
We’re nearing the half way point of the Rails Rumble.. 1 day, 2 hours, 24 minutes remaining as I write this. We’ve been taking some photos that I’ve been posting at my .Mac web gallery.
dastels @ 8:36 pm
We’re getting prepped for the Rails Rumble. Nancy & I have entered as a team. The kids have been told they’re on their own for the weekend. This is going to be a great bit of fun.
dastels @ 3:30 am
RSpec Autotest now a Rails Plugin:
“Posted by Nick Sieger Wed, 15 Nov 2006 15:46:00 GMT
Inspired by a posting on the RSpec list and recent comments stating that my Auto RSpec hack wasn’t working, I’ve bitten the bullet and upgraded to RSpec 0.7.2, and made rspec_autotest a plugin in the process. So, here are the necessary incantations to auto-rspec your project.”
OK, so I’m a bit behind on RSpec developments. But this plugin makes a world of difference when using rspec.
While Nick mentions rspec 0.7.2 in the post, I’m using it with the latest (pre-trunk) 0.9.0 without any issues.
If you use rspec (with rails or not.. see rspec-autotest-for-standalone-projects) you should be using this plugin!
dastels @ 7:12 am
Nancy and I have begun exploring game development for the Nintendo DS. We found that most of the material available online wasn’t of the greatest quality. So we set up nds-homebrew.net to be a repository of the useful information we find, as well as being home to a blog tracking our efforts and progress.
The blog is there now, and more structured information will follow.
dastels @ 2:48 am
I’ve read a couple of the beta versions of this book from the Pragmatic Press. It’s good. If you are using TextMate, you should have this book. The current documentation for TextMate is pretty lame. This book does an admirable job of filling that void.
The writing style is easy to read, and is quite information dense. Content goes from basic cursor movement all the way to custom language support. It’s a good read, and packed with valuable and useful information.
That said, while I’m impressed with the book, I’ve become less and less impressed with TextMate itself. It’s a wonderful text editor and a sweet Mac app, and will long have a place on my dock. But for serious programming, it doesn’t cut it. I’ve gone back to “old faithful”… my constant companion from from way back.. GNU Emacs. If you’re doing serious programming, there’s nothing like Emacs.