2013-08-09 17:33:57 +04:00
|
|
|
---
|
|
|
|
category: tool
|
|
|
|
tool: ruby ecosystem
|
|
|
|
contributors:
|
2013-08-09 17:56:46 +04:00
|
|
|
- ["Jon Smock", "http://github.com/jonsmock"]
|
2014-07-07 23:14:53 +04:00
|
|
|
- ["Rafal Chmiel", "http://github.com/rafalchmiel"]
|
2013-08-09 17:33:57 +04:00
|
|
|
|
|
|
|
---
|
|
|
|
|
2014-07-07 23:25:45 +04:00
|
|
|
People using Ruby generally have a way to install different Ruby versions,
|
2013-08-09 17:33:57 +04:00
|
|
|
manage their packages (or gems), and manage their gem dependencies.
|
|
|
|
|
|
|
|
## Ruby Managers
|
|
|
|
|
2014-07-07 23:25:45 +04:00
|
|
|
Some platforms have Ruby pre-installed or available as a package. Most rubyists
|
2014-07-08 00:07:29 +04:00
|
|
|
do not use these, or if they do, they only use them to bootstrap another Ruby
|
2014-07-07 23:25:45 +04:00
|
|
|
installer or implementation. Instead rubyists tend to install a Ruby manager to
|
2014-07-08 00:07:29 +04:00
|
|
|
install and switch between many versions of Ruby and their projects' Ruby
|
2013-08-09 17:33:57 +04:00
|
|
|
environments.
|
|
|
|
|
2014-07-08 00:07:29 +04:00
|
|
|
The following are the popular Ruby environment managers:
|
2013-08-09 17:33:57 +04:00
|
|
|
|
|
|
|
* [RVM](https://rvm.io/) - Installs and switches between rubies. RVM also has
|
|
|
|
the concept of gemsets to isolate projects' environments completely.
|
|
|
|
* [ruby-build](https://github.com/sstephenson/ruby-build) - Only installs
|
|
|
|
rubies. Use this for finer control over your rubies' installations.
|
|
|
|
* [rbenv](https://github.com/sstephenson/rbenv) - Only switches between rubies.
|
|
|
|
Used with ruby-build. Use this for finer control over how rubies load.
|
|
|
|
* [chruby](https://github.com/postmodern/chruby) - Only switches between rubies.
|
|
|
|
Similar in spirit to rbenv. Unopinionated about how rubies are installed.
|
|
|
|
|
|
|
|
## Ruby Versions
|
|
|
|
|
|
|
|
Ruby was created by Yukihiro "Matz" Matsumoto, who remains somewhat of a
|
|
|
|
[BDFL](https://en.wikipedia.org/wiki/Benevolent_Dictator_for_Life), although
|
2014-07-07 23:25:45 +04:00
|
|
|
that is changing recently. As a result, the reference implementation of Ruby is
|
|
|
|
called MRI (Matz' Reference Implementation), and when you hear a Ruby version,
|
2013-08-09 17:33:57 +04:00
|
|
|
it is referring to the release version of MRI.
|
|
|
|
|
2014-07-07 23:25:45 +04:00
|
|
|
The three major version of Ruby in use are:
|
2013-08-09 17:33:57 +04:00
|
|
|
|
|
|
|
* 2.0.0 - Released in February 2013. Most major libraries and frameworks support
|
|
|
|
2.0.0.
|
|
|
|
* 1.9.3 - Released in October 2011. This is the version most rubyists use
|
2015-10-06 17:08:41 +03:00
|
|
|
currently. Also [retired](https://www.ruby-lang.org/en/news/2015/02/23/support-for-ruby-1-9-3-has-ended/)
|
2013-08-09 17:33:57 +04:00
|
|
|
* 1.8.7 - Ruby 1.8.7 has been
|
|
|
|
[retired](http://www.ruby-lang.org/en/news/2013/06/30/we-retire-1-8-7/).
|
|
|
|
|
|
|
|
The change between 1.8.7 to 1.9.x is a much larger change than 1.9.3 to 2.0.0.
|
|
|
|
For instance, the 1.9 series introduced encodings and a bytecode VM. There
|
|
|
|
are projects still on 1.8.7, but they are becoming a small minority, as most of
|
|
|
|
the community has moved to at least 1.9.2 or 1.9.3.
|
|
|
|
|
|
|
|
## Ruby Implementations
|
|
|
|
|
2014-07-08 00:07:29 +04:00
|
|
|
The Ruby ecosystem enjoys many different implementations of Ruby, each with
|
2015-09-19 11:59:04 +03:00
|
|
|
unique strengths and states of compatibility. To be clear, the different
|
2014-07-08 00:07:29 +04:00
|
|
|
implementations are written in different languages, but *they are all Ruby*.
|
2013-08-09 17:33:57 +04:00
|
|
|
Each implementation has special hooks and extra features, but they all run
|
2014-07-07 23:25:45 +04:00
|
|
|
normal Ruby files well. For instance, JRuby is written in Java, but you do
|
2013-08-09 17:33:57 +04:00
|
|
|
not need to know Java to use it.
|
|
|
|
|
|
|
|
Very mature/compatible:
|
|
|
|
|
2014-07-08 00:07:29 +04:00
|
|
|
* [MRI](https://github.com/ruby/ruby) - Written in C, this is the reference implementation of Ruby. By
|
2013-08-09 17:33:57 +04:00
|
|
|
definition it is 100% compatible (with itself). All other rubies
|
2013-08-17 15:17:21 +04:00
|
|
|
maintain compatibility with MRI (see [RubySpec](#rubyspec) below).
|
2014-07-08 00:07:29 +04:00
|
|
|
* [JRuby](http://jruby.org/) - Written in Java and Ruby, this robust implementation is quite fast.
|
2013-08-09 17:33:57 +04:00
|
|
|
Most importantly, JRuby's strength is JVM/Java interop, leveraging existing
|
|
|
|
JVM tools, projects, and languages.
|
2014-07-07 23:25:45 +04:00
|
|
|
* [Rubinius](http://rubini.us/) - Written primarily in Ruby itself with a C++ bytecode VM. Also
|
|
|
|
mature and fast. Because it is implemented in Ruby itself, it exposes many VM
|
2013-08-09 17:33:57 +04:00
|
|
|
features into rubyland.
|
|
|
|
|
|
|
|
Medium mature/compatible:
|
|
|
|
|
2014-07-07 23:14:53 +04:00
|
|
|
* [Maglev](http://maglev.github.io/) - Built on top of Gemstone, a Smalltalk VM. Smalltalk has some
|
2014-07-08 00:07:29 +04:00
|
|
|
impressive tooling, and this project tries to bring that into Ruby
|
2013-08-09 17:33:57 +04:00
|
|
|
development.
|
2014-07-07 23:25:45 +04:00
|
|
|
* [RubyMotion](http://www.rubymotion.com/) - Brings Ruby to iOS development.
|
2013-08-09 17:33:57 +04:00
|
|
|
|
|
|
|
Less mature/compatible:
|
|
|
|
|
2014-07-07 23:14:53 +04:00
|
|
|
* [Topaz](http://topazruby.com/) - Written in RPython (using the PyPy toolchain), Topaz is fairly young
|
2014-07-08 00:50:27 +04:00
|
|
|
and not yet compatible. It shows promise to be a high-performance Ruby
|
2013-08-09 17:33:57 +04:00
|
|
|
implementation.
|
2014-07-07 23:14:53 +04:00
|
|
|
* [IronRuby](http://ironruby.net/) - Written in C# targeting the .NET platform, work on IronRuby seems
|
2013-08-09 17:33:57 +04:00
|
|
|
to have stopped since Microsoft pulled their support.
|
|
|
|
|
|
|
|
Ruby implementations may have their own release version numbers, but they always
|
2017-08-23 11:14:39 +03:00
|
|
|
target a specific version of MRI for compatibility. Many implementations have
|
2013-08-09 17:33:57 +04:00
|
|
|
the ability to enter different modes (for example, 1.8 or 1.9 mode) to specify
|
|
|
|
which MRI version to target.
|
|
|
|
|
|
|
|
## RubySpec
|
|
|
|
|
2014-07-07 23:25:45 +04:00
|
|
|
Most Ruby implementations rely heavily on [RubySpec](http://rubyspec.org/). Ruby
|
2013-08-09 17:33:57 +04:00
|
|
|
has no official specification, so the community has written executable specs in
|
2014-07-07 23:25:45 +04:00
|
|
|
Ruby to test their implementations' compatibility with MRI.
|
2013-08-09 17:33:57 +04:00
|
|
|
|
|
|
|
## RubyGems
|
|
|
|
|
2014-07-08 00:50:27 +04:00
|
|
|
[RubyGems](http://rubygems.org/) is a community-run package manager for Ruby.
|
|
|
|
RubyGems ships with Ruby, so there is no need to download it separately.
|
2013-08-09 17:33:57 +04:00
|
|
|
|
|
|
|
Ruby packages are called "gems," and they can be hosted by the community at
|
|
|
|
RubyGems.org. Each gem contains its source code and some metadata, including
|
|
|
|
things like version, dependencies, author(s), and license(s).
|
|
|
|
|
|
|
|
## Bundler
|
|
|
|
|
2013-08-12 18:17:37 +04:00
|
|
|
[Bundler](http://bundler.io/) is a gem dependency resolver. It uses a project's
|
2013-08-09 17:33:57 +04:00
|
|
|
Gemfile to find dependencies, and then fetches those dependencies' dependencies
|
|
|
|
recursively. It does this until all dependencies are resolved and downloaded, or
|
|
|
|
it will stop if a conflict has been found.
|
|
|
|
|
|
|
|
Bundler will raise an error if it finds conflicting dependencies. For example,
|
|
|
|
if gem A requires version 3 or greater of gem Z, but gem B requires version 2,
|
|
|
|
Bundler will notify you of the conflict. This becomes extremely helpful as many
|
|
|
|
gems refer to other gems (which refer to other gems), which can form a large
|
|
|
|
dependency graph to resolve.
|
|
|
|
|
2013-08-09 17:56:51 +04:00
|
|
|
# Testing
|
|
|
|
|
2014-07-07 23:25:45 +04:00
|
|
|
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
|
2013-09-08 12:24:37 +04:00
|
|
|
are many testing libraries with different goals.
|
2013-08-09 17:56:51 +04:00
|
|
|
|
2014-07-07 23:14:53 +04:00
|
|
|
* [TestUnit](http://ruby-doc.org/stdlib-1.8.7/libdoc/test/unit/rdoc/Test/Unit.html) - Ruby 1.8's built-in "Unit-style" testing framework
|
|
|
|
* [minitest](http://ruby-doc.org/stdlib-2.0.0/libdoc/minitest/rdoc/MiniTest.html) - Ruby 1.9/2.0's built-in testing framework
|
|
|
|
* [RSpec](http://rspec.info/) - A testing framework that focuses on expressivity
|
|
|
|
* [Cucumber](http://cukes.info/) - A BDD testing framework that parses Gherkin formatted tests
|
2013-08-09 17:56:51 +04:00
|
|
|
|
2013-08-09 17:33:57 +04:00
|
|
|
## Be Nice
|
|
|
|
|
2014-07-07 23:25:45 +04:00
|
|
|
The Ruby community takes pride in being an open, diverse, welcoming community.
|
2013-08-09 17:33:57 +04:00
|
|
|
Matz himself is extremely friendly, and the generosity of rubyists on the whole
|
|
|
|
is amazing.
|