Class: Semver::Parser Private
- Inherits:
-
Object
- Object
- Semver::Parser
- Defined in:
- lib/semver/parser.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- PATTERN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%r{^ (0|[1-9]\d*)\. # major (0|[1-9]\d*)\. # minor (0|[1-9]\d*) # patch (- # pre release (0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*) (\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))* )? (\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)? # build metadata $}x
Instance Method Summary collapse
- #parse(string) ⇒ Object private
Instance Method Details
#parse(string) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/semver/parser.rb', line 18 def parse(string) matches = PATTERN.match(string.to_s) raise InvalidFormatError, string unless matches { major: matches[1].to_i, minor: matches[2].to_i, patch: matches[3].to_i, pre_release: left_chop(matches[4]), build_metadata: left_chop(matches[8]), } end |