Refactors into gem; specs; early implementation of condition parsing.