boba 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -8
- data/lib/boba/relations_railtie.rb +26 -0
- data/lib/boba/version.rb +1 -1
- data/lib/boba.rb +7 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6b2eb9c09c7bcd8a5050115892945fc23749ddc3b9f0376387c914c089c390b
|
4
|
+
data.tar.gz: b17a134072db6a900007bc4a74cba405ca69383039e710e86862de09c6daa93f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d1bd6b43cc6ad2104ad6bcb96f78a53eb7c70068ef948ba0ab172fb8821537963e3a4bf5fe2b810613f9a2e4e9c0a30364bca266e243af1b8cf2800f0d8772a
|
7
|
+
data.tar.gz: 38e5e55631671d0bf64c7c8f64b3d21d8d7c8dbd393b4ffc960f2e958766302bb67dea0c8aeef65ec606f2f395d1194ac1367551a795ae66c7f455ce412f287e
|
data/README.md
CHANGED
@@ -4,9 +4,7 @@
|
|
4
4
|
|
5
5
|
Boba is a collection of compilers for Sorbet & Tapioca.
|
6
6
|
|
7
|
-
Tapioca is very opinionated about what types of compilers or changes are accepted into the repository. See
|
8
|
-
[here](https://github.com/Shopify/tapioca?tab=readme-ov-file#dsl-compilers). Boba come in all
|
9
|
-
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.
|
7
|
+
Tapioca is very opinionated about what types of compilers or changes are accepted into the repository. See [here](https://github.com/Shopify/tapioca?tab=readme-ov-file#dsl-compilers). 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.
|
10
8
|
|
11
9
|
### Available Compilers
|
12
10
|
|
@@ -21,8 +19,7 @@ group :development do
|
|
21
19
|
end
|
22
20
|
```
|
23
21
|
|
24
|
-
We recommend you also use the `only` configuration option in your Tapioca config (typically `sorbet/tapioca/config.yml`)
|
25
|
-
to specify only the Tapioca compilers you wish to use.
|
22
|
+
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.
|
26
23
|
```yml
|
27
24
|
dsl:
|
28
25
|
only:
|
@@ -31,6 +28,36 @@ dsl:
|
|
31
28
|
```
|
32
29
|
This makes it easy to selectively enable only the compilers you want to use in your project.
|
33
30
|
|
31
|
+
### Typing Relations
|
32
|
+
|
33
|
+
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:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
gem 'boba'
|
37
|
+
```
|
38
|
+
|
39
|
+
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:
|
40
|
+
```ruby
|
41
|
+
class Post < ::ActiveRecord::Base
|
42
|
+
scope :recent -> { where('created_at > ?', Date.current) }
|
43
|
+
|
44
|
+
belongs_to :author
|
45
|
+
has_many :comments
|
46
|
+
end
|
47
|
+
|
48
|
+
sig { params(author: Author).returns(Post::PrivateRelation) }
|
49
|
+
def posts_from_author(author); end
|
50
|
+
```
|
51
|
+
|
52
|
+
and the following should not raise an error:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
sig { params(author: Author).returns(Post::PrivateRelation) }
|
56
|
+
def recent_posts_from_author(author)
|
57
|
+
posts_from_author(author).recent
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
34
61
|
## Contributing
|
35
62
|
|
36
63
|
Bugs and feature requests are welcome and should be [filed as issues on github](https://github.com/angellist/boba/issues).
|
@@ -39,9 +66,7 @@ Bugs and feature requests are welcome and should be [filed as issues on github](
|
|
39
66
|
|
40
67
|
Compilers for any commonly used Ruby or Rails gems are welcome to be contributed. See the [Writing New Compilers section of the Tapioca docs](https://github.com/Shopify/tapioca?tab=readme-ov-file#writing-custom-dsl-compilers) for an introduction to writing compilers.
|
41
68
|
|
42
|
-
Since Boba is intended to be used alongside Tapioca and the compilers provided by Boba are intended to be fully optional,
|
43
|
-
we will not accept compilers which overwrite the Tapioca default compilers. See the [Tapioca Manual](https://github.com/Shopify/tapioca/blob/main/manual/compilers.md) for a list of these
|
44
|
-
compilers. Instead, compilers which extend or overwrite the default Tapioca compilers should be given unique names.
|
69
|
+
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](https://github.com/Shopify/tapioca/blob/main/manual/compilers.md) for a list of these compilers. Instead, compilers which extend or overwrite the default Tapioca compilers should be given unique names.
|
45
70
|
|
46
71
|
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.
|
47
72
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "rails/railtie"
|
5
|
+
|
6
|
+
class Boba::RelationsRailtie < Rails::Railtie
|
7
|
+
railtie_name(:boba)
|
8
|
+
|
9
|
+
initializer("boba.add_private_relation_constant") do
|
10
|
+
ActiveSupport.on_load(:active_record) do
|
11
|
+
module AciveRecordInheritDefineRelationTypes
|
12
|
+
def inherited(child)
|
13
|
+
super(child)
|
14
|
+
|
15
|
+
child.const_set("PrivateRelation", Object)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class ::ActiveRecord::Base
|
20
|
+
class << self
|
21
|
+
prepend AciveRecordInheritDefineRelationTypes
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/boba/version.rb
CHANGED
data/lib/boba.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Angellist
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorbet-static-and-runtime
|
@@ -47,6 +47,8 @@ extra_rdoc_files: []
|
|
47
47
|
files:
|
48
48
|
- LICENSE
|
49
49
|
- README.md
|
50
|
+
- lib/boba.rb
|
51
|
+
- lib/boba/relations_railtie.rb
|
50
52
|
- lib/boba/version.rb
|
51
53
|
- lib/tapioca/dsl/compilers/active_record_associations_persisted.rb
|
52
54
|
- lib/tapioca/dsl/compilers/active_record_columns_persisted.rb
|
@@ -56,9 +58,9 @@ licenses:
|
|
56
58
|
- MIT
|
57
59
|
metadata:
|
58
60
|
bug_tracker_uri: https://github.com/angellist/boba/issues
|
59
|
-
changelog_uri: https://github.com/angellist/boba/blob/0.0.
|
61
|
+
changelog_uri: https://github.com/angellist/boba/blob/0.0.4/History.md
|
60
62
|
homepage_uri: https://github.com/angellist/boba
|
61
|
-
source_code_uri: https://github.com/angellist/boba/tree/0.0.
|
63
|
+
source_code_uri: https://github.com/angellist/boba/tree/0.0.4
|
62
64
|
rubygems_mfa_required: 'true'
|
63
65
|
post_install_message:
|
64
66
|
rdoc_options: []
|