Project

boba

0.0
The project is in a healthy, maintained state
Custom Tapioca compilers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Boba

⚠️ This gem is in pre-release and is not ready for use.

Boba is a collection of compilers for Sorbet & Tapioca.

Tapioca is very opinionated about what types of compilers or changes are accepted into the repository. See here. Boba come in all different shapes, sizes, consistencies, etc, and is much less opinionated about what is or is not accepted. Boba is a collection of optional compilers that you can pick and choose from.

Available Compilers

See the compilers manual for a list of available compilers.

Usage

Add Boba to your development dependencies in your gemfile:

group :development do
  gem 'boba', require: false
end

We recommend you also use the only configuration option in your Tapioca config (typically sorbet/tapioca/config.yml) to specify only the Tapioca compilers you wish to use.

dsl:
  only:
    Compiler1
    Compiler2

This makes it easy to selectively enable only the compilers you want to use in your project.

Typing Relations

If you'd like to use relation types in your sigs that are less broad than ActiveRecord::Relation, such as those specific to a model, Boba provides a railtie to initialize these constants for each class. Move Boba in your gemfile out of the development group:

  gem 'boba'

The railtie will automatically define the PrivateRelation constant on each model that inherits from ActiveRecord::Base. It can then be used in typing, like thus:

class Post < ::ActiveRecord::Base
  scope :recent -> { where('created_at > ?', Date.current) }

  belongs_to :author
  has_many :comments
end

sig { params(author: Author).returns(Post::PrivateRelation) }
def posts_from_author(author); end

and the following should not raise an error:

sig { params(author: Author).returns(Post::PrivateRelation) }
def recent_posts_from_author(author)
  posts_from_author(author).recent
end

Contributing

Bugs and feature requests are welcome and should be filed as issues on github.

New Compilers

Compilers for any commonly used Ruby or Rails gems are welcome to be contributed. See the Writing New Compilers section of the Tapioca docs for an introduction to writing compilers.

Since Boba is intended to be used alongside Tapioca and the compilers provided by Boba are intended to be fully optional, we will not accept compilers which overwrite the Tapioca default compilers. See the Tapioca Manual for a list of these compilers. Instead, compilers which extend or overwrite the default Tapioca compilers should be given unique names.

Contributed compilers should be well documented, and named after and include a link or reference to the Gem, DSL, or other module they implement RBIs for.

Compilers for Gems, DSLs, or modules that are not publicly available will not be accepted.

Todo

  1. Specs & spec harness