We want to
benefit
from types
in Ruby
https://unsplash.com/photos/nxy9wFUiksg
Slide 21
Slide 21 text
We can now write static types in Ruby
RBS, Steep
Starting with Ruby 3.0, those are bundled with Ruby 💎
Can start small
No impact on runtime
No loss of writing comfort
Product code and type definitions are separated
Slide 22
Slide 22 text
So why is it so difficult?
One reason comes to mind
Slide 23
Slide 23 text
https://rubygems.org
Slide 24
Slide 24 text
https://rubygems.org/stats
Slide 25
Slide 25 text
https://rubygems.org/stats
Slide 26
Slide 26 text
No content
Slide 27
Slide 27 text
No content
Slide 28
Slide 28 text
Directory with type
definitions for gems
Slide 29
Slide 29 text
No content
Slide 30
Slide 30 text
No content
Slide 31
Slide 31 text
44 / about 173,000 😢
Slide 32
Slide 32 text
Most gem type definitions are missing
✓Many projects rely on third-party gems
✓About 173,000 gems registered at
rubygems.org
✓In contrast, gem_rbs_collection still has
only about 40 gem type definitions😢
Slide 33
Slide 33 text
https://unsplash.com/photos/JrZ1yE1PjQ0
Slide 34
Slide 34 text
Proposal
Slide 35
Slide 35 text
Proposal
Let’s contribute to
gem_rbs_collection!
Slide 36
Slide 36 text
Centralized repository
for gem type definitions
”DefinitelyTyped" in TypeScript
More type definitions here are expected to
make it easier to implement into projects.
Slide 37
Slide 37 text
So...
Step by step instructions
on how to contribute to
gem_rbs_collection
Today's Theme
Slide 38
Slide 38 text
Notice
I ’m a contributor and not the maintainer of
gem_rbs_collection
I'll speak based on my experience so far, but it
may differ from the maintainer's intentions
RBS syntax is not discussed.
Steps to
Steps to
contribute to
contribute to
gem_rbs_collection
gem_rbs_collection
Slide 41
Slide 41 text
One
Add or modify existing
type definitions
Two
Add new gem type
definitions
Slide 42
Slide 42 text
One
Add or modify existing
type definitions
Two
Add new gem type
definitions
Slide 43
Slide 43 text
Steps to
contribute
Finding
Finding missing or incorrect type
definitions
Check
Check for mismatch between type
definition and implementation
Fix
Fix the appropriate rbs file
Patch
Open a Pull Request
Slide 44
Slide 44 text
No content
Slide 45
Slide 45 text
No content
Slide 46
Slide 46 text
No content
Slide 47
Slide 47 text
No content
Slide 48
Slide 48 text
🤔
Slide 49
Slide 49 text
No content
Slide 50
Slide 50 text
No content
Slide 51
Slide 51 text
Receive block!
Slide 52
Slide 52 text
No content
Slide 53
Slide 53 text
No content
Slide 54
Slide 54 text
Not able to
receive block
Slide 55
Slide 55 text
No content
Slide 56
Slide 56 text
Pull Request: Add #count type definitions to activerecord
Slide 57
Slide 57 text
No content
Slide 58
Slide 58 text
Just this
Slide 59
Slide 59 text
Steps to
contribute
Finding
Finding missing or incorrect type
definitions
Check
Check for discrepancies between
errors and implementation
Fix
Fix the appropriate rbs file
Patch
Open a Pull Request
Slide 60
Slide 60 text
One
Add or modify existing
type definitions
Two
Add new gem type
definitions
Slide 61
Slide 61 text
One
Add or modify existing
type definitions
Two
Add new gem type
definitions
Slide 62
Slide 62 text
Two more cases
✓Automatic and exhaustive generation
✓Add only some of them
Slide 63
Slide 63 text
Two more cases
✓Automatic and exhaustive generation
✓Add only some of them
These steps are almost identical,
differing only in the way
the RBS is defined
https://github.com/ruby/gem_rbs_collection/blob/main/docs/CONTRIBUTING.md
Steps are
shown here
Slide 66
Slide 66 text
Step.1
Setup environment
Slide 67
Slide 67 text
No content
Slide 68
Slide 68 text
Run `bundle install`
Slide 69
Slide 69 text
Step.2
Generate a boilerplate
Slide 70
Slide 70 text
No content
Slide 71
Slide 71 text
No content
Slide 72
Slide 72 text
No content
Slide 73
Slide 73 text
No content
Slide 74
Slide 74 text
No content
Slide 75
Slide 75 text
No content
Slide 76
Slide 76 text
No content
Slide 77
Slide 77 text
No content
Slide 78
Slide 78 text
Step.3, 4
Write RBS files & tests
Slide 79
Slide 79 text
Assumption:
Not necessarily all APIs
need to have type definitions
Slide 80
Slide 80 text
"
Writing high-quality type
definitions are difficult.
Focus on examples available
through the README or docs of
the gem. Focus on the APIs your
app is using.
https://github.com/ruby/gem_rbs_collection/blob/main/docs/CONTRIBUTING.md
"
Writing high-quality type
definitions are difficult.
Focus on examples available
through the README or docs of
the gem. Focus on the APIs your
app is using.
https://github.com/ruby/gem_rbs_collection/blob/main/docs/CONTRIBUTING.md
Slide 115
Slide 115 text
Pull Request: Add RBS for Enumerize gem
Slide 116
Slide 116 text
No content
Slide 117
Slide 117 text
Partitive
Exhaustive
Slide 118
Slide 118 text
Partitive
Exhaustive
How should we use
How should we use
them differently?
them differently?
Slide 119
Slide 119 text
✓If you want a tight type
definition for a particular
method
✓If you want RBS for now
👉Partitive
👉Exhaustive
Slide 120
Slide 120 text
Step.5
Open a Pull Request
Slide 121
Slide 121 text
Before that...
Slide 122
Slide 122 text
No content
Slide 123
Slide 123 text
No content
Slide 124
Slide 124 text
rbs validate
steep check
Slide 125
Slide 125 text
And then
Open your Pull Request!😄
Slide 126
Slide 126 text
F Y I 💁♂️
For your information
Slide 127
Slide 127 text
FYI
REMOVE manifest.yml
The file manifest.yml is necessary if there are
dependencies that are not described in Gemfile.lock or
gemspec. If there are no dependencies, remove it before
opening PR
NOT ALL GEMS ARE COVERED
Standard and built-in library RBS files are available in the
ruby/rbs repository
Slide 128
Slide 128 text
No content
Slide 129
Slide 129 text
No content
Slide 130
Slide 130 text
No content
Slide 131
Slide 131 text
No content
Slide 132
Slide 132 text
No content
Slide 133
Slide 133 text
No content
Slide 134
Slide 134 text
No content
Slide 135
Slide 135 text
No content
Slide 136
Slide 136 text
No content
Slide 137
Slide 137 text
No content
Slide 138
Slide 138 text
https://unsplash.com/photos/4V1dC_eoCwg
Slide 139
Slide 139 text
WHAT
WANTED
TO TELL
Let's actively use
RBS, Steep and
share our knowledges
I hope that
the Ruby type ecosystem
will develop further