Skip to content

sylhare/Ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ruby docker badge

Ruby est un langage de programmation libre. Il est interprété, orienté objet et multi-paradigme.

Check this article on railsapps to get you started on Linux

Getting started with Ruby

Install Ruby from ruby-lang.org. You have multiple installer for Windows or you can use the command line for UNIX (here for Debian, Ubuntu):

sudo apt-get install ruby-full

Once it's intalled, go on command prompt (windows) or a terminal on Linux and type:

ruby --version

If it's properly installed, it should return the version. Now you may want to start play with Ruby, so you can launch IRB (Interactive Ruby Shell).

irb

Then you can start typing some ruby (like a python prompt). You can quit the IRB by typing exit.

If you have a ruby program (with a .rb) you can launch from the prompt, here an example with the HelloWorld.rb program:

	ruby HelloWorld.rb

Getting RubyGems

RubyGems is a package management framework for Ruby. You can download it from rubygems.org. Once it's installed, you can check with:

	gem --version

It can be used to download packages (also called gems), for example rails:

	gem install rails

Gems works with a .gemspec file which containes the specification of the gem (name, author, version, ...). To build a gem use:

	gem build my-gem.gemspec

You can unpack a gem (to see what's inside) with:

	gem unpack my-gem-0.1.1.gem 

To update your gem online at RubyGem, you will need first an account then you can use:

	# Push the gem online
	gem push my-gem-0.1.1.gem  
	# Delete the gem online
	gem yank my-gem-0.1.1.gem 

Getting rvm

RVM can be use for ruby development. You can download it from rvm.io

Getting on rails

Ruby on Rails is a web framework that has been written in the Ruby programming language. So here are some example.

Everything is well documented on RoR getting started. But I've added some extra things that bugged me.

First on windows you can download rails installer which would also install SQLite3.

rails --version

⚠️ On Windows, you might have error #72 with rails, so you might need to overwrite the rails.bat file with one in here from #72. Then you can create a new webiste (will be created in the current directory).

rails new website

Usually this command has been launched at the end of the previous one. It is used to get all the gem required for rails. You can do so by going in the newly created repository cd website then:

bundle install

⚠️ On windows, the path was hard coded in bundle.bat you'll need to overwrite it with the one here from #70.

Then in the folder, run this command, you'll be able to access the website at http://localhost:3000/

rails server

⚠️ If you run into a ExecJS::ProgramError try one of the solution proposed here #1.

Sources

Here are some sources and links that relates to Ruby and Ruby on Rails.

Ruby

Encryption

Ruby on Rails

RoR - Introduction

RoR - Authentification

Vocabulary

Some definition:

  • CRUD : Create, Read, Update and Destroy. Model followed by Ruby on Rails applications.
  • RubyGems : is a package manager for the Ruby programming language that provides a tool designed to easily manage the installation of gems, and a server for distributing them.
  • Gem : A standard self-contained format for distributing Ruby programs and libraries. The gem command is used to build, upload, download, and install Gem packages.
  • rvm : RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.