haf/semver — pull request #2 by jameschildress (2013-05-27 05:22:34+00:00)
Title: Metadata and Prerelease handling by SemVer class.

Hello! I've been using your gem and I'm hoping to contribute to it. My goal was to update the SemVer class to more closely match the SemVer 2.0.0-rc2 spec. My changes focused on two areas: pre-release versions and build metadata.

### Pre-release Versions

`SemVer#special` has been aliased to `SemVer#prerelease` to more closely reflect the vocabulary used by the official SemVer spec.

SemVers comparisons now take prerelease into account, as per the official spec:

> Pre-release precedence MUST be determined by comparing each dot separated identifier as follows: identifiers consisting of only digits are compared numerically and identifiers with letters or hyphens are compared lexically in ASCII sort order. Numeric identifiers always have lower precedence than non-numeric identifiers. Example: 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0.

### Build Metadata

Build metadata has been added to the SemVer class, as per the official spec:

> Build metadata MAY be denoted by appending a plus sign and a series of dot separated identifiers immediately following the patch or pre-release version. Identifiers MUST comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Build metadata SHOULD be ignored when determining version precedence. Thus two packages with the same version, but different build metadata are considered to be the same version. Examples: 1.0.0-alpha+001, 1.0.0+20130313144700, 1.0.0-beta+exp.sha.5114f85.

- Metadata can be parsed from a string just like the other SemVer properties.
- Metadata may be included in the output format string, and has been added to the default format.
- Metadata is serialized to and from the YAML file.
- Metadata is _not_ considered when comparing two SemVer objects.
- Metadata is validated in `SemVer#initialize`.

### Testing

Tests have been provided for the new features, and all existing tests continue to pass. The new features should be backwards-compatible with the current SemVer gem and .semver files.

Since no tests exist for `bin/semver`, that file has not been modified. I didn't want to risk breaking something.