2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-02-05 13:16:51 -06:00
|
|
|
module Discourse
|
2019-01-25 08:19:01 -06:00
|
|
|
VERSION_REGEXP = /\A\d+\.\d+\.\d+(\.beta\d+)?\z/ unless defined? ::Discourse::VERSION_REGEXP
|
|
|
|
|
2013-08-07 17:47:04 -05:00
|
|
|
# work around reloader
|
|
|
|
unless defined? ::Discourse::VERSION
|
2013-03-12 22:06:58 -05:00
|
|
|
module VERSION #:nodoc:
|
2018-01-03 15:54:55 -06:00
|
|
|
MAJOR = 2
|
2019-01-31 16:49:43 -06:00
|
|
|
MINOR = 3
|
2014-08-26 14:24:07 -05:00
|
|
|
TINY = 0
|
2019-04-24 09:22:00 -05:00
|
|
|
PRE = 'beta9'
|
2013-02-05 13:16:51 -06:00
|
|
|
|
2013-03-12 22:06:58 -05:00
|
|
|
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
|
|
|
|
end
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
2015-04-27 12:06:53 -05:00
|
|
|
|
|
|
|
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
|
2013-03-12 22:06:58 -05:00
|
|
|
end
|