Difference between revisions of "Ruby"
Jump to navigation
Jump to search
Line 48: | Line 48: | ||
Install dependencies, uses project's Gemfile | Install dependencies, uses project's Gemfile | ||
<source lang=bash> | <source lang=bash> | ||
bundler install | bundler install #installs gems and their dependencies | ||
bundler install --path #installs gems in ./path dir, much easier to remove them if something is wrong | |||
#creates .bundle/config file that contains path to gems | |||
bundle info kwalify #display where a gem got installed | bundle info kwalify #display where a gem got installed | ||
* kwalify (0.7.2) | * kwalify (0.7.2) |
Revision as of 22:44, 28 February 2019
Ruby adventures...
Install
#Pre requsites sudo apt-get install -y curl gnupg build-essential # Install RVM - Ruby Version Manager sudo apt-get install -y curl gnupg2 build-essential gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB # Install RVM stable with ruby: curl -sSL https://get.rvm.io | bash -s stable --ruby # can take ~10 min as it's compiling sources
To start using RVM you need to run source /home/vagrant/.rvm/scripts/rvm
in all your open shell windows, in rare cases you need to reopen all shell windows.
source /home/vagrant/.rvm/scripts/rvm #this in U18 adds following to your env export PATH=$PATH:/home/vagrant/.rvm/bin #adds local rvm bin to your user path rvm_user_install_flag=1 rvm_stored_umask=0002 rvm_loaded_flag=1 # Optional: sudo usermod -a -G rvm `whoami`
Use RVM to install Ruby version you want ruby-X.X.X
- this will search your package management for version you ask if not found
- will download sources and get it compiled
- will remove undesired packages, rg. U18 libssl-dev to install libssl1.0-dev instead
rvm install ruby-2.1.0 rvm --default use ruby-X.X.X
- Install Bundler
gem install bundler --no-rdoc --no-ri </source>
Optional install using OS package manager, rarely working
sudo apt-get install ruby ruby-dev
Install dependencies, uses project's Gemfile
bundler install #installs gems and their dependencies bundler install --path #installs gems in ./path dir, much easier to remove them if something is wrong #creates .bundle/config file that contains path to gems bundle info kwalify #display where a gem got installed * kwalify (0.7.2) Summary: a parser, schema validator, and data-binding tool for YAML and JSON. Homepage: http://www.kuwata-lab.com/kwalify/ Path: /home/vagrant/.rvm/gems/ruby-2.6.0/gems/kwalify-0.7.2
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/