Skip to content
A Thoughtbot Upcase Ruby Challenge
Branch: master
Clone or download
Pull request Compare This branch is 8 commits ahead of thoughtbot:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Upcase Analyzing Shakespeare

One of the many excersizes I take my students through at Devschool's Online Developer School


Take the following XML file: Macbeth XML

Write Ruby code to parse the xml and extract the speakers and their line counts.

The main entry-point is the lib/shakespeare_analyzer.rb and it is a stand-alone module, which means it holds no state and it is not meant to be mixed in.

Running the tests


Nothing more. You might need to bundle install frst.

The tests that are here are very basic top level tests. They are meant to be acceptance tests, meaning when the code 'works' these tests will pass without you changing them at'tall, as my English friend says.

How about some help asshole?

Well, sure. That is only fair. If I gave you no further help I wouldn't be much of a RubyMentor, and that is exactly what I have become and am happy to be. So.......

TDDing the Shakespeare Analyzer

I do this kind of thing much better in video than I do in text. Maybe it is because I curse less in video... Probably not, I think it may just be because I am really too lazy for my own good. Bullshit. I am a good programmer because I am just lazy enough!

Watch the episode here

And the code is in this branch

My solution

Located in this branch

In the ./bin folder you will find 2 executable files that implement my solution. One prints out to a screen, the other saves the file to the hard disk as output.txt You could, for instance, write one that saves to a database or whatever floats your boat, all without editing the original software in lib. Al la, the Open/Closed principle bitches.

Running my solution

to print the output to screen:


or to save the output:

You can’t perform that action at this time.