lib/data/version.rb in gfsm-0.3.2 vs lib/data/version.rb in gfsm-0.4.0

- old
+ new

@@ -5,11 +5,11 @@ module GFSM module Data class Version < SemVersion PRERELEASE_BUILD_VERSION = /^(?<prerelease_name>[a-zA-Z\-]+)(\.?)(?<prerelease_version>[0-9]*)$/i - def bump!(major = false, minor = false, patch = true, pre = false, prerelease_name = "pre") + def bump!(major = false, minor = false, patch = true, pre = false, prerelease_name) if major self.major = self.major + 1 self.minor = 0 self.patch = 0 elsif minor @@ -18,15 +18,19 @@ elsif patch self.patch = self.patch + 1 end if pre - preselease_match = self.pre.match(PRERELEASE_BUILD_VERSION) if self.pre - if preselease_match - self.pre = preselease_match[:prerelease_name] + "." + (preselease_match[:prerelease_version].to_i + 1).to_s - else - self.pre = prerelease_name - end + self.add_prerelease_suffix!(prerelease_name) + end + end + + def add_prerelease_suffix!(prerelease_name) + preselease_match = self.pre.match(PRERELEASE_BUILD_VERSION) if self.pre + if preselease_match + self.pre = preselease_match[:prerelease_name] + "." + (preselease_match[:prerelease_version].to_i + 1).to_s + else + self.pre = prerelease_name end end end end end \ No newline at end of file