3. An Introduction to the Ruby Ecosystem
Ruby is an interpreted language which means it needs an…
interpreter. In a nutshell, his job is to take your source code as an
input and to execute it.
The three most popular Ruby interpreter are:
● Matz’s Ruby Interpreter (MRI): the oficial by Matz
● Rubinius: a well-known fast Ruby implementation of Ruby
● JRuby: a JVM implementation
4. An Introduction to the Ruby Ecosystem
A read–eval–print loop (REPL), also known as an interactive
toplevel or language shell, is a simple, interactive computer
programming environment that takes single user inputs (i.e. single
expressions), evaluates them, and returns the result to the user; a
program written in a REPL environment is executed piecewise.
The Ruby language have 2 main used REPLs:
● IRB - Ruby built-in shell.
● PRY - A powerful alternative to the standard IRB shell for Ruby.
5. An Introduction to the Ruby Ecosystem
Command-line tool which allows you to easily install, manage, and
work with multiple ruby environments from interpreters to sets of
gems.
The Ruby language have 2 main used version managers:
● RVM - Ruby Version Manager.
● rbenv - Simple Ruby Version Manager.
6. An Introduction to the Ruby Ecosystem
RubyGems (previously known as Gemcutter) is a package manager
for the Ruby programming language that provides a standard format
for distributing Ruby programs and libraries (in a self-contained
format called a "gem"), a tool designed to easily manage the
installation of gems, and a server for distributing them.
Example of command to install a gem:
gem install mygem
● https://rubygems.org/
7. An Introduction to the Ruby Ecosystem
Bundler provides a consistent environment for Ruby projects by tracking and
installing the exact gems and versions that are needed.
Bundler is an exit from dependency hell, and ensures that the gems you need are
present in development, staging, and production. Starting work on a project is as
simple as bundle install.
source :rubygems
gem "nokogiri"
gem "rails", "3.0.0.beta3"
gem "rack", ">=1.0"
gem "thin", "~>1.1"
gem "thor", path: "../thor"
group :test do
gem "rspec"
end
8. An Introduction to the Ruby Ecosystem
Rake is a software task management tool. It allows you to specify tasks and
describe dependencies as well as to group tasks in a namespace.
It is similar to SCons and Make, but it has a number of differences. The tool is
written in the Ruby programming language and the Rakefiles (equivalent of
Makefiles in Make) use Ruby syntax. It was originated by Jim Weirich.
Rake uses Ruby's anonymous function blocks to define various tasks, allowing the
use of Ruby syntax. It has a library of common tasks: for example, functions to do
common file-manipulation tasks and a library to remove compiled files (the
"clean" task). Like Make, Rake can also synthesize tasks based on patterns: for
example, automatically building a file compilation task based on filename
patterns. Rake is now part of the standard library from Ruby version 1.9 onward.
9. An Introduction to the Ruby Ecosystem
namespace :afternoon do
task :make_coffee do
Rake::Task['morning:make_coffee'].invoke
puts "Ready for the rest of the day!"
end
end
10. An Introduction to the Ruby Ecosystem
Ruby has the most famous web framework and maybe the
framework with the larger community, its name is Ruby on Rails.
Ruby has a lot of web frameworks, here is listed the 2 most used.
● Ruby on Rails - An open-source web framework that’s optimized for
programmer happiness and sustainable productivity. It lets you write beautiful
code by favoring convention over configuration.
● Sinatra - A DSL for quickly creating web applications in Ruby with minimal
effort. Largelly used to create REST Services.
11. An Introduction to the Ruby Ecosystem
Ruby has toolchains that enable Ruby developers create mobile apps natively to
iOS, Android and Windows.
● RubyMotion - A revolutionary toolchain that lets you quickly develop and test full-fledged
native apps for iPhone, iPad, Mac and Android (beta), all using your favorite
editor and the awesome Ruby language you know and love.
● Ruboto - A framework and tool chain to develop native Android apps, using the Ruby
language we all know and love.
● IronRuby - An open-source implementation of the Ruby programming language
which is tightly integrated with the .NET Framework. IronRuby can use the .NET
Framework and Ruby libraries, and other .NET languages can use Ruby code just as
easily.
12. An Introduction to the Ruby Ecosystem
An Application Server is a complete server which provides an environment for running the
business components in addition to providing the capabilities of a Web Container as well as
of a Web Server.
● Phusion Passenger - An application server that is compiled either as an Apache
module or compiled directly along with the nginx source code (because nginx doesn't
contain a plugin architecture like Apache does). It excels in situations that need
multiple low traffic applications running on the same machine.
● Unicorn - An HTTP server for Rack applications designed to only serve fast clients on
low-latency, high-bandwidth connections and take advantage of features in
Unix/Unix-like kernels. Slow clients should only be served by placing a reverse proxy
capable of fully buffering both the the request and response in between Unicorn and
slow clients.
● Puma - A modern, concurrent web server for Ruby.
13. An Introduction to the Ruby Ecosystem
As the amount of services and applications grows, becomes extremely
hard to deploy all the services and handle all the configurations. In order to
solve this kind of problem Ruby has 2 very good tools.
● Capistrano - A utility and framework for executing commands in parallel on
multiple remote machines, via SSH.
● Chef - A configuration management tool designed to bring automation to
your entire infrastructure.
14. An Introduction to the Ruby Ecosystem
A very good practice adopted in the development process is the continuous
delivery. The process where every time the code is committed to a shared
host some tasks are executed on the code in order to validate the quality,
and if everything is ok the code is deployed. The 2 most used CI server
are:
● Jenkins - An extendable open source continuous integration server.
● Semaphore - A hosted continuous integration and delivery solution for open
source and private projects.
15. An Introduction to the Ruby Ecosystem
Testing is a large part of Ruby culture. Ruby comes with its own
Unit-style testing framework called minitest (Or TestUnit for Ruby
version 1.8.x). There are many testing libraries with different goals.
● TestUnit - Ruby 1.8’s built-in “Unit-style” testing framework
● minitest - Ruby 1.9/2.0’s built-in testing framework
● RSpec - A testing framework that focuses on expressivity
● Capybara - The integration testing framework
● Cucumber - A BDD testing framework that parses Gherkin formatted tests
16. An Introduction to the Ruby Ecosystem
A tool responsible to check possible vulnerabilities in a project.
● Brakeman - An open source vulnerability scanner specifically designed for
Ruby on Rails applications. It statically analyzes Rails application code to
find security issues at any stage of development.