brew/Library/Homebrew/utils/ruby_check_version_script.rb
Maxim Belkin a6d29894d9 cleanup: fix and reuse portable ruby logic.
Align the logic in `cleanup_portable_ruby` with that in `ruby.sh`.

Co-authored-by: Maxim Belkin <maxim.belkin@gmail.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2020-09-03 09:43:41 +01:00

23 lines
856 B
Ruby
Executable File

#!/usr/bin/env ruby --enable-frozen-string-literal --disable=gems,did_you_mean,rubyopt
# frozen_string_literal: true
HOMEBREW_REQUIRED_RUBY_VERSION = ARGV.first.freeze
raise "No Ruby version passed!" if HOMEBREW_REQUIRED_RUBY_VERSION.to_s.empty?
require "rubygems"
ruby_version = Gem::Version.new(RUBY_VERSION)
# This will only happen if the Ruby is too old anyway.
abort unless ruby_version.respond_to?(:canonical_segments)
homebrew_required_ruby_version = Gem::Version.new(HOMEBREW_REQUIRED_RUBY_VERSION)
ruby_version_major, ruby_version_minor, = ruby_version.canonical_segments
homebrew_required_ruby_version_major, homebrew_required_ruby_version_minor, =
homebrew_required_ruby_version.canonical_segments
if ruby_version_major != homebrew_required_ruby_version_major ||
ruby_version_minor != homebrew_required_ruby_version_minor
abort
end