lib/origen/version_string.rb in origen-0.60.7 vs lib/origen/version_string.rb in origen-0.60.8
- old
+ new
@@ -3,11 +3,11 @@
include Utility::TimeAndDate
require 'date'
# returns version number string but strips out prefix
def initialize(version, prefix = 'v')
- version.gsub!(/^#{prefix}/, '') # remove leading prefix
+ version.gsub!(/^#{prefix}/, '') # remove leading prefix
super(version)
end
# Returns a new production timestamp version string
def self.production_timestamp
@@ -137,58 +137,50 @@
VersionString.new("Rel#{time_now(format: :universal, include_time: false)}")
end
end
def major
- @major ||= begin
- if semantic?
- self =~ /v?(\d+)/
- Regexp.last_match[1].to_i
- else
- fail "#{self} is not a valid semantic version number!"
- end
- end
+ @major ||= if semantic?
+ self =~ /v?(\d+)/
+ Regexp.last_match[1].to_i
+ else
+ fail "#{self} is not a valid semantic version number!"
+ end
end
def minor
- @minor ||= begin
- if semantic?
- self =~ /v?\d+.(\d+)/
- Regexp.last_match[1].to_i
- else
- fail "#{self} is not a valid semantic version number!"
- end
- end
+ @minor ||= if semantic?
+ self =~ /v?\d+.(\d+)/
+ Regexp.last_match[1].to_i
+ else
+ fail "#{self} is not a valid semantic version number!"
+ end
end
def bugfix
- @bugfix ||= begin
- if semantic?
- self =~ /v?\d+.\d+.(\d+)/
- Regexp.last_match[1].to_i
- else
- fail "#{self} is not a valid semantic version number!"
- end
- end
+ @bugfix ||= if semantic?
+ self =~ /v?\d+.\d+.(\d+)/
+ Regexp.last_match[1].to_i
+ else
+ fail "#{self} is not a valid semantic version number!"
+ end
end
alias_method :tiny, :bugfix
def pre
- @pre ||= begin
- if semantic?
- if self =~ /(dev|pre)(\d+)$/
- Regexp.last_match[2].to_i
- end
- else
- fail "#{self} is not a valid semantic version number!"
- end
- end
+ @pre ||= if semantic?
+ if self =~ /(dev|pre)(\d+)$/
+ Regexp.last_match[2].to_i
+ end
+ else
+ fail "#{self} is not a valid semantic version number!"
+ end
end
alias_method :dev, :pre
def latest?
- downcase.orig_equal?('trunk') || downcase.orig_equal?('latest')
+ downcase.to_s.eql?('trunk') || downcase.to_s.eql?('latest')
end
# Returns true if the version is a timestamp format version number
def timestamp?
!!(self =~ /^Rel\d\d\d\d\d\d\d\d$/ ||
@@ -218,36 +210,36 @@
# which one is greater
if production? != tag.production? && timestamp? &&
to_date == tag.to_date
false
else
- numeric >= tag.numeric && ((self.latest? || tag.latest?) || self.timestamp? == tag.timestamp?)
+ numeric >= tag.numeric && ((latest? || tag.latest?) || timestamp? == tag.timestamp?)
end
elsif condition =~ /^>\s*(.*)/
tag = validate_condition!(condition, Regexp.last_match[1])
if production? != tag.production? && timestamp? &&
to_date == tag.to_date
false
else
- numeric > tag.numeric && ((self.latest? || tag.latest?) || self.timestamp? == tag.timestamp?)
+ numeric > tag.numeric && ((latest? || tag.latest?) || timestamp? == tag.timestamp?)
end
elsif condition =~ /^<=\s*(.*)/
tag = validate_condition!(condition, Regexp.last_match[1])
- numeric <= tag.numeric && ((self.latest? || tag.latest?) || self.timestamp? == tag.timestamp?)
+ numeric <= tag.numeric && ((latest? || tag.latest?) || timestamp? == tag.timestamp?)
elsif condition =~ /^<\s*(.*)/
tag = validate_condition!(condition, Regexp.last_match[1])
- numeric < tag.numeric && ((self.latest? || tag.latest?) || self.timestamp? == tag.timestamp?)
+ numeric < tag.numeric && ((latest? || tag.latest?) || timestamp? == tag.timestamp?)
elsif condition =~ /^==?\s*(.*)/
tag = validate_condition!(condition, Regexp.last_match[1])
- self.orig_equal?(tag)
+ orig_equal?(tag)
else
tag = validate_condition!(condition, condition)
- self.orig_equal?(tag)
+ orig_equal?(tag)
end
end
# Returns a numeric representation of the version, this can be used
# for chronological comparison with other versions