Ruby

From Ever changing code
Revision as of 13:28, 28 February 2019 by Pio2pio (talk | contribs) (→‎Install)
Jump to navigation Jump to search

Ruby adventures...

Install

#Pre requsites
sudo apt-get install -y curl gnupg build-essential

# Install RVM - Ruby Version Manager
sudo gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | sudo bash -s stable
sudo usermod -a -G rvm `whoami`

# Install
sudo apt-get install ruby ruby-dev
 
# Install dependencies
bundler install

Basic file structure

#!/usr/bin/env ruby

# require 'yaml'
require 'fileutils'

file_name="file.txt"

# #{file_name} -: string interpolation
FileUtils.touch("#{file_name}.OK")

The require dependencies need to be installed using

sudo apt  install ruby-bundler
bundle install       #default, but NEVER RUN AS SUDO
bundle install -path #installs gems into ~/.path/