lib/gem/release/version/number.rb in gem-release-2.0.0.rc.1 vs lib/gem/release/version/number.rb in gem-release-2.0.0.rc.2
- old
+ new
@@ -1,17 +1,19 @@
module Gem
module Release
module Version
class Number < Struct.new(:number, :target)
- NUMBER = /^(\d+)\.?(\d+)?\.?(\d+)?\.?(\w+)?\.?(\d+)?$/
+ NUMBER = /^(\d+)\.?(\d+)?\.?(\d+)?(\-|\.)?(\w+)?\.?(\d+)?$/
STAGES = %i(alpha beta pre rc)
def bump
return target if specific?
validate_stage
- [major, minor, patch, stage, num].compact.join('.')
+ parts = [[major, minor, patch].compact.join('.')]
+ parts << [stage, num].join('.') if stage
+ parts.join(stage_delim)
end
private
def specific?
@@ -40,13 +42,17 @@
def stage
target unless to_release?
end
+ def stage_delim
+ parts[3] || '-'
+ end
+
def num
return if to_release?
- same_stage? ? parts[4].to_i + 1 : 1
+ same_stage? ? parts[5].to_i + 1 : 1
end
def to?(*targets)
targets.include?(target)
end
@@ -70,11 +76,11 @@
def same_stage?
from_stage == target
end
def from_stage
- parts[3]
+ parts[4]
end
def target
super || (from_pre_release? ? from_stage : :patch)
end
@@ -85,10 +91,11 @@
raise Abort, "Cannot go from an #{from_stage} version to a #{target} version"
end
def parts
@parts ||= matches.compact.map(&:to_i).tap do |parts|
- parts[3] = matches[3].to_sym if matches[3]
+ parts[3] = matches[3]
+ parts[4] = matches[4].to_sym if matches[4]
end
end
def matches
@matches ||= parse.to_a[1..-1]