From 8ea4e7773a69c2469d3eb63c755d476d2486b2d8 Mon Sep 17 00:00:00 2001 From: 0xmachos <0xmachos@gmail.com> Date: Fri, 9 Mar 2018 13:29:24 +0000 Subject: [PATCH] Convert Ruby version detection steps to function --- install | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/install b/install index b067f032a..d249c4335 100755 --- a/install +++ b/install @@ -82,21 +82,24 @@ else fatal "Unable to locate installer for your Operating system: $OS" fi -info 'Detecting Ruby environment...' -MIN_RUBY_VER='2.3' -if command_exists ruby -then - RUBY_VERSION=`ruby -e "puts RUBY_VERSION"` - info "Ruby version ${RUBY_VERSION} is installed" - if [ `ruby -e "puts RUBY_VERSION.to_f >= ${MIN_RUBY_VER}"` = 'false' ] + +check_ruby_version () { + + info 'Detecting Ruby environment...' + + MIN_RUBY_VER='2.3' + if command_exists ruby then - fatal "Ruby version ${RUBY_VERSION} is not supported. Please install Ruby ${MIN_RUBY_VER} (or newer) and restart the installer." + RUBY_VERSION=$(ruby -e "puts RUBY_VERSION") + info "Ruby version ${RUBY_VERSION} is installed" + if [ "$(ruby -e "puts RUBY_VERSION.to_f >= ${MIN_RUBY_VER}")" = 'false' ] + then + fatal "Ruby version ${RUBY_VERSION} is not supported. Please install Ruby ${MIN_RUBY_VER} (or newer) and restart the installer." + fi + else + fatal "Ruby is not installed. Please install Ruby ${MIN_RUBY_VER} (or newer) and restart the installer." fi -else - fatal "Ruby is not installed. Please install Ruby ${MIN_RUBY_VER} (or newer) and restart the installer." -fi - - +} check_bundler () {