haf/semver — pull request #1 by timmfin (2013-01-26 06:29:08+00:00)
Title: Adding a SemVar.parse(str, format) class method

Add a parse class method to SemVer that parses a SemVer instance from a string and passed format. If the format is omitted, it defaults to SemVer::TAG_FORMAT. By default, the parse still pass if major, minor, or patch isn't found (or omitted from the format), but that can be turned off by passing false for allow_missing.

SemVer.parse 'v1.2.3-beta'
SemVer.parse '1-2-3===beta', '%M-%m-%p===%s'
SemVer.parse 'v1.2', 'v%M.%m'
SemVer.parse 'v1.2', 'v%M.%m', false ===> fails and returns nil