Better Standards

A guide to Ruby's stdlib and available alternatives.

Please note: The standard library was turned into gems, see stdgems.org for up-to-date information on all standard gems!

Standard Library Overview

Library Sources Description Alternatives
abbrev mri Small library that finds the shortest abbreviation to identify one string amongst many -
base64 mri Encodes and decodes strings to a Base64 representation. Implemented as a small wrapper around String#unpack -
continuation mri Deprecated library that adds the goto-like Kernel#callcc Concurrent Ruby, Fiber
coverage c mri Measures code coverage -
debug mri Command-line debugger byebug
digest c mri Provides common hash functions like MD5, SHA1, SHA2, or RIPEMD-160 OpenSSL::Digest
drb mri Distributed object system for Ruby -
English mri Readable aliases for special global variables -
erb mri Templating engine for Ruby erubis, erbse, erubi
expect mri Adds IO#expect, which can be used to wait for a specific pattern to be read -
fiber c mri Adds Fiber#transfer and Fiber#alive? -
find mri Finds all files in a given directory and its sub-directories `find .`.split($/)
io/nonblock c mri Allows to work with IO streams in a non-blocking way -
io/wait c mri Adds methods to wait until an IO stream becomes readable or writable -
mkmf mri Generates Makefiles for native C extensions -
monitor mri Monitors for multi-threaded code -
net/ftp mri Support for FTP (File Transfer Protocol) -
net/http mri Support for HTTP (Hypertext Transfer Protocol) http.rb, em-http-request, excon, httpclient
net/imap mri Support for IMAP (Internet Message Access Protocol) em-imap
nkf c mri Kanji encoding converter -
objspace c mri Adds more statistics methods to ObjectSpace -
open-uri mri Monkeypatches Kernel#open to support remote endpoints via net/http and net/ftp -
optparse mri Command-line option parser slop, optimist, clap, rationalist
pathname c mri Wraps File, FileTest, Dir, and FileUtils to ease working with file system paths path
prettyprint mri Better object formatting and inspection. Comes with the pp print debugging helper via require 'pp' wirb, hirb, awesome_print
profiler mri Measures which methods are called and how long each method takes to complete. Auto-start via require 'profile' ruby-prof, perftools.rb, method_profiler
pty c mri Manages pseudo terminals -
racc c mri
gem
A YACC-like LALR(1) parser generator parslet, citrus, treetop
rbconfig - RbConfig is a Ruby constant that contains compile time information -
resolv mri Thread-aware DNS resolver. Will replace Socket's DNS via require 'resolve-replace' rubydns, net-dns, em-resolve-replace
rinda mri Support fot the Linda distributed computing paradigm in drb -
ripper c mri Ruby parser that creates a symbolic expression tree ruby_parser, parser
securerandom mri Provides crpytographical randomness from openssl or the OS -
set mri Data structure for unordered collections without duplicates. Implemented on top of Hash. Also comes with SortedSet for ordered collections. -
shellwords mri Escape and manipulate commands to be run in the shell -
socket c mri Support for unix- and network sockets -
syslog c mri Interface to the low-level syslog logger syslogger, log4r, lumberjack_syslog_device, yell-adapters-syslog
tempfile mri Simplifies OS independent creation of temporary files -
time mri Adds more methods to Time -
tmpdir mri Adds a Dir.mktmpdir method for creating temporary directories OS independently -
tsort mri Typological sorting using Tarjan’s algorithm, which finds strongly connected components in graphs -
un mri Utilities to replace common UNIX commands -
unicode_normalize
(auto-require)
mri Adds a String#unicode_normalize method which normalizes unicode strings unf, unicode
weakref mri Explicitly allow objects to be garbage collected ref
Win32API c mri Let's you use Windows APIs, like calling functions in DLLs win32-api, ffi
win32ole c mri Windows OLE automation interface -

Default Gems

These libraries come as default Ruby gems, so that they can be updated independently from Ruby. See stdgems.org for more info.

Gem Sources Description Alternatives
benchmark mri
gem
Benchmarking library benchmark-ips, benchmark-driver
bigdecimal c mri
gem
Support for arbitrary-precision floating point decimal arithmetic -
bundler mri
gem
Bundler is the local package manager for Ruby applications -
cgi mri
gem
Support for CGI (Common Gateway Interface) rack
csv mri
gem
Support for CSV (Comma-separated Values) smarter_csv
date c mri
gem
The Date and DateTime classes -
dbm c mri
gem
Support for DBM databases -
delegate mri
gem
Provides three ways to delegate method calls forwardable
did_you_mean
(auto-require)
mri
gem
Patches error messages to suggest correct spelling of methods/classes/variables -
etc c mri
gem
Access UNIX info from /etc -
fcntl c mri
gem
Loads values from the OS' fcntl.h to be used for low-level file descriptor manipulation system calls with IO#fcntl and IO.sysopen -
fiddle c mri
gem
Support for FFI (Foreign Function Interface) ffi
fileutils mri
gem
Utilities for working with the file system -
forwardable mri
gem
Provides a way to delegate method calls. Also see this overview of delegation in Ruby, which contains an example -
gdbm c mri
gem
Support for GNU dbm databases -
getoptlong mri
gem
GNU getopt_long() style command-line option parsing OptParse, slop, optimist, clap, rationalist
io/console c mri
gem
Patches IO for simple and portable access to the console -
ipaddr mri
gem
IP address manipulation ipaddress, ruby-ip
irb mri Interactive Ruby Console (REPL) ripl, pry, rib
json c mri
gem
Support for JSON (JavaScript Object Notation) oj, yajl-ruby
logger mri
gem
Logging utility log4r, lumberjack, yell, logging, micrologger
matrix mri
gem
Support for matrices nmatrix
mutex_m mri
gem
A mixin that makes any object behave like a mutex -
observer mri
gem
Implementation of the observer pattern, a way to let interested other objects know o an object's updates microevent, signal_lamp
net/pop mri
gem
Support for POP3 (Post Office Protocol) -
net/smtp mri
gem
Support for SMTP (Simple Mail Transfer Protocol) -
open3 mri
gem
Simple spawning of child processes open4
openssl c mri
gem
Wraps OpenSSL for cryptographic functionality -
ostruct mri
gem
Wrapper around Hash that lets you read and set attributes with a method API Hash, ostruct2
prime mri
gem
Access to prime numbers and prime factorization -
pstore mri
gem
Transactional file storage for Ruby objects -
psych c mri
gem
Support for YAML (YAML Ain't Markup Language) -
rdoc mri
gem
Ruby documentation generator yard
readline mri
gem
If available, readline-ext will be loaded, or (Ruby-only) reline will be used -
readline-ext mri
gem
Interface to GNU Readline and NetBSD Editline rb-readline, reline
reline mri
gem
Ruby-only implementation of GNU Readline / NetBSD Editline rb-readline
rexml mri
gem
Support for XML (Extensible Markup Language) nokogiri, oga
rss mri
gem
Support for RSS (Rich Site Summary) and Atom -
rubygems
(auto-require)
mri
gem
Manages Ruby libraries. -
sdbm c mri
gem
Support for SDBM databases -
singleton mri
gem
Mixin for Ruby classes that should only have one instance -
stringio c mri
gem
Makes strings behave like IO objects -
strscan c mri
gem
Lexical string scanning -
timeout mri
gem
Auto-terminates code blocks after the time limit is reached -
tracer mri
gem
Outputs the code execution trace via Kernel#set_trace_func TracePoint
uri mri
gem
URI/URL manipulation addressable,ruby-uriparser
webrick mri
gem
HTTP server thin, unicorn, puma
yaml mri
gem
Loads the psych yaml parser and sets YAML = Psych -
zlib c mri
gem
Interface to the zlib compression library -

Bundled Gems

Gems that will be installed together with Ruby. See stdgems.org for more info.

Gem Description Alternatives
minitest Test/spec framework, comes with mocking and benchmark capabilities rspec
net-telnet Support for Telnet -
power_assert Debug tool that displays intermediate results of a method chain -
rake A Ruby task runner, inspired by make thor, boson
test-unit A xUnit family unit testing framework minitest, rspec
xmlrpc Remote Procedure Calls via XML and HTTP -

Something's wrong or missing? You can edit this list on GitHub!

Resources

More Idiosyncratic Ruby