turboladen/sdp — pull request #25 by turboladen (2012-12-11 22:17:54+00:00)
Title: Redesigned to use Composite pattern

First, parsing. Using Parslet for parsing text was kinda nice--it made defining the rules easy, all in one place. ...but it wasn't as flexible as I'd have liked (or I just didn't know how to use it right). It felt awkward trying to define rules on the rules (i.e. making sure an attribute value used a certain charset) and didn't seem to allow for easy customization of checking field attributes. I've been wanting to get rid of this for some time.

Next, building. With RTSP, I wanted to be able to build a single media description separately from the main description, work with that, then add it to the main description once ready. The old design simply just users adding media sections (and any other field that could be used multiple times) as a Hash to an Array. While it mostly worked, it was not intuitive nor terse. I knew from day one that this part of the gem would have to change, but didn't need to implement it until the RTSP server came about (and thus building SDP descriptions became important).

Error checking is now easier (in the code at least) and more prevalent; you now, for example, get warnings if you call #to_s on a description when it doesn't have required fields set.

Maintenance should be easier now, where each field and group is defined individually and can be customized accordingly.

Lastly, fields and groups of fields now have #seed! which can help populate some basic info into the description, then let you customize later.

I think that's the most of it all...