#!/bin/bash -e

eval "$(cli-shezargs $@)"

[[ -n $no_ruby ]] && exit 0
[[ -z $ruby    ]] && exit 0

if jsaws-build-block "ruby" "Installing Ruby"; then
  if ! which ruby > /dev/null; then

    # Install packages
    sudo DEBIAN_FRONTEND=noninteractive apt-get update
    sudo DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential

    mkdir -p ~/zz_packages && cd $_
    curl 'http://ftp.ruby-lang.org/pub/ruby/2.4/ruby-2.4.0.tar.gz' | tar -xzv
    cd ruby-2.4.0/

    ./configure && make -j`grep -c ^processor /proc/cpuinfo` && sudo make install
  fi

  jsaws-build-block "ruby" "done"
fi

