mdsol/crichton-representors — pull request #4 by jcarres-mdsol (2014-05-08 14:03:45+00:00)
Title: Hal deserializer

Do not merge yet. Things to finish before merging:
- [ ] Write specs for Golum and PropertiesBag
- [ ] Maybe rename PropertiesBag to BagOfProperties or something cooler
- [ ] Add comments to the code
- [ ] Add Usage file or usage information in the Readme
- [ ] Move all the classes to the correct files.

I needed to parse some responses in a cucumber scenario to have a Hal deserializer so I made this one. It covers the whole HAL spec, take a look at the files in spec/fixtures to see what it can understand. BTW thanks to @edandersen of crichton-dotnet for those files.

I have kind of throw this together to cover my needs. It lacks some specs around a couple of objects but still the coverage is 97%

I have deleted Representor because it was conflicting with the Crichton::Representor module in the Crichton gem. As it was you would not use this gem and the Crichton gem from the same code (and I need it)

I have created a new class from scratch called Golem, because:
- Golems are cool (Google for examples)
- Golems are your friends (or better are)
- It conveys the idea of creating something and animate it from inanimate materia (the document)

I am sorry I did not reuse the design for Representor we already had. I wanted to make it grow more organically (TDD, using the files as guide in fact).

The usage of these classes is:
```Ruby
my_house = Crichton::HalDeserializer.new(some_real_state_document).deserialize
#now you can access properties
is_big = true if my_house.room_count > 4
#access links
wget my_house.links.pay_rent.href
#access embedded resources
wget my_house.kitchen.links.put_out_fire

#Alternatively and to access names that can not become methods there is a hash-like syntax:
puts my_house.links['self'].title
```

Review focusing on the big problems and keeping in mind my TODO for this PR.
@mdsol/hypermedia-team