Skip to content

Commit dca6ac6

Browse files
authored
Check if ruby >= 3.1 is already installed (#31)
1 parent e245d93 commit dca6ac6

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

ronin-dev.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,15 @@ function auto_install_git()
248248
}
249249

250250
#
251-
# Installs ruby 3, if it's not installed.
251+
# Installs ruby >= 3.1, if it's not installed.
252252
#
253253
function auto_install_ruby()
254254
{
255-
# check if ruby-3.x is already installed
256-
if [[ ! "$ruby_version" == "3."* ]]; then
257-
log "Installing ruby 3.x ..."
255+
# check if ruby >= 3.1 is already installed
256+
if [[ -z "$ruby_version" ]] ||
257+
[[ "$ruby_version" == "2."* ]] ||
258+
[[ "$ruby_version" == "3.0."* ]]; then
259+
log "Installing ruby >= 3.1 ..."
258260
case "$package_manager" in
259261
brew) homebrew_install_ruby ;;
260262
dnf|yum) install_packages ruby-devel ruby-bundled-gems ;;

ronin-install.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,15 @@ function install_packages()
200200
}
201201

202202
#
203-
# Installs ruby 3, if it's not installed.
203+
# Installs ruby >= 3.1, if it's not installed.
204204
#
205205
function auto_install_ruby()
206206
{
207-
# check if ruby-3.x is already installed
208-
if [[ ! "$ruby_version" == "3."* ]]; then
209-
log "Installing ruby 3.x ..."
207+
# check if ruby >= 3.1 is already installed
208+
if [[ -z "$ruby_version" ]] ||
209+
[[ "$ruby_version" == "2."* ]] ||
210+
[[ "$ruby_version" == "3.0."* ]]; then
211+
log "Installing ruby >= 3.1 ..."
210212
case "$package_manager" in
211213
brew) homebrew_install_ruby ;;
212214
dnf|yum) install_packages ruby-devel ruby-bundled-gems ;;

test/ronin_dev_test.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ function test_awk_installed()
2727
assertCommandInstalled "did not successfully install awk" 'awk'
2828
}
2929

30-
function test_ruby_3_x_installed()
30+
function test_at_least_ruby_3_1_installed()
3131
{
32-
# check if ruby-3.x is already installed
33-
if [[ "$test_ruby_version" == "3."* ]]; then
32+
# check if ruby >= 3.1.x is already installed
33+
if [[ -n "$ruby_version" ]] &&
34+
[[ "$ruby_version" != "2."* ]] &&
35+
[[ "$ruby_version" != "3.0."* ]]; then
3436
return
3537
fi
3638

test/ronin_install_test.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ function test_make_installed()
1717
assertCommandInstalled "did not successfully install make" 'make'
1818
}
1919

20-
function test_ruby_3_x_installed()
20+
function test_at_least_ruby_3_1_installed()
2121
{
22-
# check if ruby-3.x is already installed
23-
if [[ "$test_ruby_version" == "3."* ]]; then
22+
# check if ruby >= 3.1 is already installed
23+
if [[ -n "$ruby_version" ]] &&
24+
[[ "$ruby_version" != "2."* ]] &&
25+
[[ "$ruby_version" != "3.0."* ]]; then
2426
return
2527
fi
2628

0 commit comments

Comments
 (0)