watermelonexpress/developer-exercise — pull request #9 by ne0zen (2013-04-27 16:42:44+00:00)
Title: Developer Exercise complete

Hi There. Implemented all exercises to the best of my ability while trying to keep the timeframe down for implementation. You'll find details for each exercise below.

Ruby
====

General Notes
-------------
All code was run & written with Ruby 2.0.0-p0 installed via rvm on xubuntu linux 12.04 LTS. I don't think I did anything which won't work with Ruby 1.9.3. All commands given should be run from the specific project's directory which will be given just under the relevant H2

Where
-----

located in ``PROJECT_ROOT/ruby/where``

**Installation of dependancies**

``bundle``

**Running Tests**

``ruby test.rb``

Youtube API
-----------

located in ``PROJECT_ROOT/ruby/youtube``

**Installation of dependancies**

``bundle``

**Running Tests**

``rspec youtube_api_spec.rb``

**Starting the API**

``rackup``
(Started on port 9292 on my system)

**Performing a search (Requires curl)**

``curl http://localhost:9292/v1/videos?query=pycon``

**Performing a search (using wget)**

``wget -O - http://localhost:9292/v1/videos?query=pycon``

**Implementation notes**

Grape is pretty cool, hadn't worked with it before. Searches with no results will result in an empty json array being returned to the client.

Blackjack
---------

located in ``PROJECT_ROOT/ruby/blackjack``

**Installation of dependancies**

``bundle``

**Running Tests**

``rspec``
OR
``rake``

**Simulating a game**

``rake simulate``

**Implementation notes**

Went for an extremely simple simulation which just has the simulated player stopping when achieving a certain score (19).

Left the implementation of .sum in the Hand class to facilitate more advanced strategies which might depend on the visible card(s) the dealer or another player is showing (also made testing the sum logic a bit easier).

JavaScript
==========

General Notes
-------------

Ordinarily, I wouldn't commit both coffeescript and javascript files into a code repository, did so this time because it would mean whomever checked this wouldn't have to install NodeJS and coffeescript (or start a server in the directory). If you want to review my implementation, please review the .coffee files which generated the js actually appearing in the webpage. These were checked using:

* Chromium Version 25.0.1364.160 Ubuntu 12.04 (25.0.1364.160-0ubuntu0.12.04.1)
* Firefox 20.0 (Ubuntu package 11.0+build1-0ubuntu4)

accordion
---------

located in PROJECT_ROOT/javascript/accordion

**Running Tests**

(open tests.html)

**Note** You'll find you can't mess with the accordion while the tests are run as I removed the event handlers as a part of teardown. To actually interact with the accordion follow instructions below.

**Play with the Accordion**

(open accordion.html)

**Implementation Notes**

Went with a simple hide and show as when using slideToggle for transitions the tests passed but widget was left in an a confusing state. (QUnit appeared to be running all the tests simulaneously). I don't think I'll be using QUnit again by choice.

Menu
----

located in PROJECT_ROOT/javascript/menu

**Running Tests**

(open menu.html)

**Implementation Notes**

Probably got a little too fancy with titleize and slugify. But recall reading that certain characters are not a good idea within a URL and figured turning the found titles into slugs would makes things a little more sane.

Clicking on 'leaf' links within the nested menu tree will result in actually linking to the slugified version of Header within the document (had a heck of a time writing jasmine async tests around this behavior in Chromium so I had to manually verify).
e.g. From top-level in the menu:
Click "Practice"
Click "Overall Performance"
note the location in the address bar should now have the hash "#performance", the key for that leaf in the menu.