discourse/lib/version.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
927 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2013-02-05 14:16:51 -05:00
module Discourse
VERSION_REGEXP = /\A\d+\.\d+\.\d+(\.beta\d+)?\z/ unless defined? ::Discourse::VERSION_REGEXP
2013-08-07 18:47:04 -04:00
# work around reloader
unless defined? ::Discourse::VERSION
module VERSION #:nodoc:
2018-01-03 16:54:55 -05:00
MAJOR = 2
2020-02-26 16:56:11 -05:00
MINOR = 5
2014-08-26 15:24:07 -04:00
TINY = 0
2020-06-01 14:13:48 -04:00
PRE = 'beta6'
2013-02-05 14:16:51 -05:00
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
2013-02-05 14:16:51 -05:00
end
def self.has_needed_version?(current, needed)
current_split = current.split('.')
needed_split = needed.split('.')
(0..[current_split.size, needed_split.size].max).each do |idx|
current_str = current_split[idx] || ''
c0 = (needed_split[idx] || '').sub('beta', '').to_i
c1 = (current_str || '').sub('beta', '').to_i
# beta is less than stable
return false if current_str.include?('beta') && (c0 == 0) && (c1 > 0)
return true if c1 > c0
return false if c0 > c1
end
true
end
end