Stroma
A foundation for building modular, extensible DSLs in Ruby.
๐ก Why Stroma?
Building modular DSLs shouldn't require reinventing the wheel. Stroma provides a structured approach for library authors to compose DSL modules with:
- ๐ Module Registration - Register DSL modules at boot time, compose them into a unified interface
- ๐งฑ Structured Composition - Include all registered modules automatically via single DSL entry point
- ๐๏ธ Inheritance Safe - Per-class state isolation with automatic deep copying
- ๐ช Extension Hooks - Optional before/after hooks for user customization
- โ๏ธ Extension Settings - Three-level hierarchical storage for extension configuration
- ๐ Thread Safe - Immutable registry after finalization, safe concurrent reads
๐งฌ Concept
Stroma is a foundation for library authors building DSL-driven frameworks (service objects, form objects, decorators, etc.).
Core lifecycle:
-
Register - Define DSL modules at boot time via
Stroma::Registry -
Compose - Classes include
Stroma::DSLto gain all registered modules automatically -
Extend (optional) - Users can add cross-cutting logic via
before/afterhooks
๐ Quick Start
Installation
gem "stroma"Define your library's DSL
module MyLib
module DSL
# Register DSL modules at load time
Stroma::Registry.register(:inputs, MyLib::Inputs::DSL)
Stroma::Registry.register(:actions, MyLib::Actions::DSL)
Stroma::Registry.finalize!
def self.included(base)
base.include(Stroma::DSL)
end
end
endCreate base class
module MyLib
class Base
include MyLib::DSL
end
endUsage
class UserService < MyLib::Base
input :email, type: String
make :create_user
private
def create_user
# implementation
end
end๐ค Contributing
We welcome contributions! Check out our Contributing Guide to get started.
Ways to contribute:
- ๐ Report bugs and issues
- ๐ก Suggest new features
- ๐ Improve documentation
- ๐งช Add test cases
- ๐ง Submit pull requests
๐ Acknowledgments
Special thanks to all our contributors!
๐ License
Stroma is available as open source under the terms of the MIT License.