Sitelet https://www.ruby-toolbox.com/projects/facets
A long-lived project that still receives updates
Facets is the premier collection of extension methods for the Ruby programming language. Facets extensions are unique by virtue of their atomicity. They are stored in individual files allowing for highly granular control of requirements. In addition, Facets includes a few additional classes and mixins suitable to a wide variety of applications.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Ruby Facets cherries

Gem Version CI

More of Ruby, one method at a time. Facets is a collection of extensions to Ruby's core classes and standard library, plus a few small, reusable classes and modules. Most methods live in their own files, so you can load one extension, a class's extensions, or the core collection.

Facets took its name in 2004, growing out of a small methods library started in 2002, and is still maintained. The current release is 3.2.2, which requires Ruby 3.1 or newer. See the release history for changes and migration notes from earlier versions. The main branch also contains changes awaiting the next release.

Install

gem install facets

With Bundler, add this to your Gemfile:

gem 'facets', require: false

require: false lets you choose which extensions to load. Omit it if you want Bundler to load the core collection automatically.

Choose how much to load

One method

require 'facets/array/to_ranges'

[1, 2, 3, 6, 7].to_ranges
#=> [1..3, 6..7]

One class's core extensions

require 'facets/string'

'Ruby Facets'.snakecase
#=> "ruby_facets"

The core collection

require 'facets'

[1, 2, 3].average
#=> 2.0

require 'facets' loads the broadly useful core extensions: roughly 860 methods from 448 files, adding about 35 ms of load time and 2 MB of memory (Ruby 3.3, Linux). Some specialized core extensions are opt-in; require their method file directly. To load Facets extensions to a Ruby standard library, require that library through Facets:

require 'facets/ostruct'

This loads ostruct and Facets' OpenStruct extensions. On Ruby 3.5+, declare the ostruct gem separately because it is no longer a default gem.

Documentation

The split between lib/core, lib/standard and lib/rails is visible in API source paths. This helps you tell whether a method is loaded by require 'facets' or needs an explicit require. The lib/rails area, new in 4.0.0, holds Rails-compatible helpers; see the release history for details.

Contribute

Issues and pull requests are welcome. Start with CONTRIBUTING.md for the library's method organization, demos, and test conventions. The test suite runs with:

bundle install
bundle exec rake test

Source · Issues · Website

License and credits

Facets is distributed under the BSD 2-Clause License. Thomas Sawyer started the project, and many Rubyists have contributed code, ideas, tests, and documentation. Individual files record additional credits where applicable.

All your base are belong to Ruby.