Welcome to Dry! This is a family of 20+ focused Ruby gems that help you write clear, flexible, and maintainable code. From business logic to everyday utilities, these gems work great together or standalone in any kind of app.
This guide is your map of the ecosystem. Each gem has its own guide — follow any link for a full introduction and reference.
What Dry is about
Dry gems are:
- Focused. Each gem has a clear purpose, and does it well.
- Composable. Each gem handles a different concern, so they combine cleanly.
- Framework-agnostic. Works in plain Ruby, Hanami, or Rails.
- Explicit over magic. Clear code, no surprises.
- Functional. Data-oriented, with immutable values and explicit transformations.
- Testable. Small, focused pieces with explicit inputs make for straightforward tests.
Dry is also the foundation Hanami is built on — if you use Hanami, you’re already using Dry, and are in a great position to use more of these gems.
See Dry in action
Want to see what Dry code actually looks like? The Dry overview tours the headline gems with code examples.
Where to start
Pick a path that fits what you’re building:
- Building a full app, with Hanami, Rails, or anything else. Start with Dry Validation for inputs and Dry Operation for organising processes, with Dry Types and Dry Struct to model your domain. Hanami ships with these wired up and ready to use; for Rails, Dry Rails is the easiest way in.
- Writing a CLI. Dry CLI is a self-contained framework for building rich command line apps — argument parsing, subcommands, help text, and full Ruby underneath.
- Authoring a gem. Dry Core, Dry Initializer, and Dry Configurable cover the everyday needs of library code. Dry Logger gives you structured logging without forcing it on your users.
- Exploring functional Ruby. Dry Monads and Dry Effects bring monadic composition and algebraic effects to Ruby in idiomatic ways.
The gems
Read on for the full map of the ecosystem, grouped by what each gem helps you do.
Validation and data
Describe the shape of your data, transform untrusted input into trusted values, and build typed objects you can rely on.
- Dry Validation — domain validation with rule-based contracts.
- Dry Schema — coercion and validation for data structures.
- Dry Types — an extensible type system with constraints.
- Dry Struct — typed, immutable value objects.
- Dry Initializer — a params and options DSL for object initialization.
- Dry Logic — predicate logic and composable rule objects.
Business logic and control flow
Write explicit, testable business logic with clear paths for success and failure.
- Dry Operation — a step-based DSL for business operations.
- Dry Monads — monads for expressive error handling and composition.
- Dry Effects — algebraic effects for managing side effects.
Everyday utilities
Practical, standalone helpers for both libraries and apps.
- Dry Configurable — a thread-safe configuration mixin for classes.
- Dry Logger — structured logging with pluggable formatters.
- Dry Inflector — string inflection and case transformation.
- Dry Core — shared utilities used across the Dry gems.
- Dry CLI — a framework for building command line applications.
- Dry Files — a file system abstraction and utilities.
Architecture and composition
Structure apps around clear boundaries, loosely coupled components, and explicit dependencies.
- Dry System — a dependency container with auto-registration (the basis for Hanami’s slices).
- Dry Auto Inject — automatic dependency injection from a container.
- Dry Events — a publish-subscribe event system.
- Dry Monitor — instrumentation and monitoring middleware.
Framework integration
- Dry Rails — a Dry-rb integration for Rails applications.
Legacy gems
These remain for reference but are no longer recommended for new projects.
- Dry Container — now part of Dry Core.
- Dry Equalizer — now part of Dry Core.
- Dry Matcher — superseded by Dry Monads pattern matching
- Dry Transaction — superseded by Dry Operation.
- Dry View — renamed to Hanami View.