lib/semmy/version_string.rb in semmy-0.3.0 vs lib/semmy/version_string.rb in semmy-0.4.0

- old
+ new

@@ -34,10 +34,14 @@ def minor_only(version) version.split('.')[0..1].join('.') end + def patch_level?(version) + components(version)[:patch].to_i > 0 + end + def components(version) components = version.split('.') { major: components[0], @@ -56,8 +60,27 @@ else fail(NoPreviousMinor, "Cannot get previous version of #{version}.") end components.join('.') + end + + def previous_stable_branch_name(version, stable_branch_name_pattern) + stable_branch_name_pattern % previous_minor_version_components(version) + end + + private + + def previous_minor_version_components(version) + components = version.split('.').map(&:to_i) + + if components[1].zero? + fail(NoPreviousMinor, "Cannot get previous minor version of #{version}.") + end + + { + major: components[0], + minor: components[1] - 1 + } end end end