lib/mixlib/versioning/format/opscode_semver.rb in mixlib-versioning-1.0.0 vs lib/mixlib/versioning/format/opscode_semver.rb in mixlib-versioning-1.1.0

- old
+ new

@@ -1,8 +1,8 @@ # -# Author:: Seth Chisamore (<schisamo@opscode.com>) -# Author:: Christopher Maier (<cm@opscode.com>) +# Author:: Seth Chisamore (<schisamo@chef.io>) +# Author:: Christopher Maier (<cm@chef.io>) # Copyright:: Copyright (c) 2013 Opscode, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -49,14 +49,13 @@ # 11.0.0-alpha.1 # 11.0.0-alpha1+20121218164140 # 11.0.0-alpha1+20121218164140.git.207.694b062 # ``` # - # @author Seth Chisamore (<schisamo@opscode.com>) - # @author Christopher Maier (<cm@opscode.com>) + # @author Seth Chisamore (<schisamo@chef.io>) + # @author Christopher Maier (<cm@chef.io>) class OpscodeSemVer < SemVer - # The pattern is: `YYYYMMDDHHMMSS.git.COMMITS_SINCE.SHA1` OPSCODE_BUILD_REGEX = /^\d{14}(\.git\.\d+\.[a-f0-9]{7})?$/ # Allows the following: # @@ -70,22 +69,12 @@ # @see SemVer#parse def parse(version_string) super(version_string) - unless @prerelease.nil? - unless @prerelease.match(OPSCODE_PRERELEASE_REGEX) - raise Mixlib::Versioning::ParseError, "'#{@prerelease}' is not a valid Opscode pre-release signifier!" - end - end - - unless @build.nil? - unless @build.match(OPSCODE_BUILD_REGEX) - raise Mixlib::Versioning::ParseError, "'#{@build}' is not a valid Opscode build signifier!" - end - end + fail Mixlib::Versioning::ParseError, "'#{@prerelease}' is not a valid Opscode pre-release signifier!" unless @prerelease.nil? || @prerelease.match(OPSCODE_PRERELEASE_REGEX) + fail Mixlib::Versioning::ParseError, "'#{@build}' is not a valid Opscode build signifier!" unless @build.nil? || @build.match(OPSCODE_BUILD_REGEX) end - end # class OpscodeSemVer end # class Format end # module Versioning end # module Mixlib