ruby_version_check.rb 814 Bytes
Newer Older
1
2
3
4
5
6
7
module SystemCheck
  module App
    class RubyVersionCheck < SystemCheck::BaseCheck
      set_name -> { "Ruby version >= #{self.required_version} ?" }
      set_check_pass -> { "yes (#{self.current_version})" }

      def self.required_version
Zeger-Jan van de Weg's avatar
Zeger-Jan van de Weg committed
8
        @required_version ||= Gitlab::VersionInfo.new(2, 3, 5)
9
10
11
      end

      def self.current_version
12
        @current_version ||= Gitlab::VersionInfo.parse(Gitlab::TaskHelpers.run_command(%w(ruby --version)))
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
      end

      def check?
        self.class.current_version.valid? && self.class.required_version <= self.class.current_version
      end

      def show_error
        try_fixing_it(
          "Update your ruby to a version >= #{self.class.required_version} from #{self.class.current_version}"
        )
        fix_and_rerun
      end
    end
  end
end