Better Standards

A guide to Ruby's stdlib and available alternatives.

Also see: The standard library is being turned into gems: stdgems.org

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 -
benchmark mri Benchmarking library benchmark-ips, absolute_time
cgi mri Support for CGI (Common Gateway Interface) rack
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
delegate mri Provides three ways to delegate method calls forwardable
digest c mri Provides common hash functions like MD5, SHA1, SHA2, or RIPEMD-160 OpenSSL::Digest
drb mri Distributed object system for Ruby -
e2mmap mri Abstraction arround exception handling -
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($/)
forwardable mri Provides a way to delegate method calls. Also see this overview of delegation in Ruby, which contains an example -
getoptlong mri GNU getopt_long() style command-line option parsing OptParse, slop, trollop, clap, rationalist
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 -
irb mri Interactive Ruby Console (REPL) ripl, pry, rib
logger mri Logging utility log4r, lumberjack, yell, logging, micrologger
matrix mri Support for matrices nmatrix
mkmf mri Generates Makefiles for native C extensions -
monitor mri Monitors for multi-threaded code -
mutex_m mri A mixin that makes any object behave like a mutex -
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
net/pop mri Support for POP3 (Post Office Protocol) -
net/smtp mri Support for SMTP (Simple Mail Transfer Protocol) -
nkf c mri Kanji encoding converter -
objspace c mri Adds more statistics methods to ObjectSpace -
observer mri Implementation of the observer pattern, a way to let interested other objects know o an objetc's updates microevent, signal_lamp
open-uri mri Monkeypatches Kernel#open to support remote endpoints via net/http and net/ftp -
open3 mri Simple spawning of child processes open4
optparse mri Command-line option parser slop, trollop, clap, rationalist
ostruct mri Wrapper around Hash that lets you read and set attributes with a method API Hash, ostruct2
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
prime mri Access to prime numbers and prime factorization -
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
pstore mri Transactional file storage for Ruby objects -
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 -
readline mri Interface to GNU Readline and NetBSD Editline rb-readline
resolv mri Thread-aware DNS resolver. Will replace Socket's DNS via require 'resolve-replace' rubydns, net-dns, em-resolve-replace
rexml mri Support for XML (Extensible Markup Language) nokogiri, oga
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
rss mri Support for RSS (Rich Site Summary) and Atom -
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. -
shell mri Provides a Ruby interface for interacting with the shell session
shellwords mri Escape and manipulate commads to be run in the shell -
singleton mri Mixin for Ruby classes that should only have one instance -
socket c mri Support for unix- and network sockets -
sync mri Two-phase lock with a counter for multi-threaded code -
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 -
thwait mri Waits for threads to finish thread
time mri Adds more methods to Time -
timeout mri Auto-terminates code blocks after the time limit is reached -
tmpdir mri Adds a Dir.mktmpdir method for creating temporary directories OS independently -
tracer mri Outputs the code execution trace via Kernel#set_trace_func TracePoint
tsort mri Topological 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
uri mri URI/URL manipulation adressable,ruby-uriparser
weakref mri Explicitely 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 -
yaml mri Loads the psych yaml parser and sets YAML = Psych -

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
bigdecimal c mri
gem
Support for arbitrary-precision floating point decimal arithmetic -
cmath mri
gem
Trigonometric and transcendental functions for complex numbers -
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 -
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 descriptior 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 -
gdbm c mri
gem
Support for GNU dbm databases -
io/console c mri
gem
Patches IO for simple and portable access to the console -
ipaddr mri
gem
IP address manipulation ipaddress, ruby-ip
json c mri
gem
Support for JSON (JavaScript Object Notation) oj, yajl-ruby
openssl c mri
gem
Wraps OpenSSL for cryptographic functionality -
psych c mri
gem
Support for YAML (YAML Ain't Markup Language) -
rdoc mri
gem
Ruby documentation generator yard
rubygems
(auto-require)
mri
gem
Manages Ruby libraries. -
scanf mri
gem
Pure-Ruby scanf implementation -
sdbm c mri
gem
Support for SDBM databases -
stringio c mri
gem
Makes strings behave like IO objects -
strscan c mri
gem
Lexical string scanning -
webrick mri
gem
HTTP server thin, unicorn, puma
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
did_you_mean
(auto-require)
Patches error messages to suggest correct spelling of methods/classes/variables -
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