Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Railsの型ファイル自動生成における課題と解決
Search
ksss
October 28, 2023
Programming
4
4.2k
Railsの型ファイル自動生成における課題と解決
Kaigi on Rails 2023 at 浅草橋ヒューリックホール&カンファレンス
ksss
October 28, 2023
Tweet
Share
More Decks by ksss
See All by ksss
RaaP
ksss
0
450
RBS generation framework using Rack architecture
ksss
0
6.8k
mrubyでruby/specを走らせてみた結果www
ksss
1
2.4k
Rubyに型があると便利か
ksss
4
4.5k
A New Testing Framework Rgot
ksss
0
1.2k
mruby hacking guide
ksss
7
1.8k
Other Decks in Programming
See All in Programming
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
160
現場で役立つモデリング 超入門
masuda220
PRO
15
3.2k
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.4k
受け取る人から提供する人になるということ
little_rubyist
0
230
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
ヤプリ新卒SREの オンボーディング
masaki12
0
130
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
320
役立つログに取り組もう
irof
28
9.6k
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
Featured
See All Featured
Ruby is Unlike a Banana
tanoku
97
11k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
KATA
mclloyd
29
14k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Into the Great Unknown - MozCon
thekraken
32
1.5k
A Modern Web Designer's Workflow
chriscoyier
693
190k
GraphQLとの向き合い方2022年版
quramy
43
13k
Six Lessons from altMBA
skipperchong
27
3.5k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Transcript
.*9* RailsͷܕϑΝΠϧࣗಈੜʹ͓͚Δ ՝ͱղܾ ,BJHJPO3BJMT%BZ
Kaigi on Rails 2023 day 2
None
None
None
.*9* ܀ݪ༐थ @ksss Kurihara Yuki Railsྺ9 ΈͯͶϓϩμΫτ։ൃ෦ॴଐ
.*9* 7 https://github.com/ruby/rbs/graphs/contributors
None
.*9* 9
.*9* 10 Rails×ܕ RBS
.*9* 11 ՝ RailsΞϓϦ खܰʹܕΛಋೖ ͍ͨ͠
.*9* 12 ղܾ orthoses-rails
.*9* 13 orthoses-rails $ bundle add orthoses-rails —require false $
bin/rails generate orthoses:rails:install $ bin/rails orthoses:rails $ bundle exec rbs collection init $ bundle exec rbs collection install
.*9* 14 orthoses-rails ActionMailer ActiveModel ActiveRecord ActiveStorage ActiveSupport
.*9* 15 .rb .rbs
.*9* 16 ܗظ Forming ࠞཚظ Storming ౷Ұظ Norming ػೳظ Performing
͜͜·Ͱ ͜Ε͔Β Rails×ܕͷੈք
.*9* 17 ՝ RBSΛಋೖͨ͠ͷ ʹ୭ͬͯͳ͍
.*9* 18 ղܾ ੜͨ͠3#4Λ DPNNJU͢Δɻ RBSϋϯζΦϯΛ ෳճ࣮ࢪɻ
None
.*9* 20 ՝ ΞϓϦέʔγϣϯ ίʔυͷ ܕ͕͍͍ͭͯͳ͍
.*9* 21 ղܾ શ෦खͰ3#4Λॻ͘ ՝: ΞϓϦ έʔγϣϯ ίʔυͷ ܕ͕͍ͭͯ ͍ͳ͍
None
.*9* 23 ղܾ ࣗಈੜ ՝: ΞϓϦ έʔγϣϯ ίʔυͷ ܕ͕͍ͭͯ ͍ͳ͍
.*9* 24 ղܾ rbs prototype rb ՝: ΞϓϦ έʔγϣϯ ίʔυͷ
ܕ͕͍ͭͯ ͍ͳ͍
.*9* 25 ՝ ՝: Ξϓ Ϧέʔγϣ ϯίʔυͷ ܕ͕͍ͭͯ ͍ͳ͍ ղܾ:
rbs prototype rb eval, define_method ActiveSupport::Concern Array, Hash, Enumerable delegate
.*9* 26 rbs prototype rb eval ActiveSupport:: Concern Generics delegate
.*9* 27 ղܾ rbs prototype runtime ՝: Ξϓ Ϧέʔγϣ ϯίʔυͷ
ܕ͕͍ͭͯ ͍ͳ͍ ղܾ: rbs prototype rb ՝: ͍Ζ ͍ΖඇରԠ
.*9* 28 rbs prototype rb rbs prototype runtime eval ActiveSupport::
Concern Generics delegate
.*9* 29 ՝ ՝: Ξϓ Ϧέʔγϣ ϯίʔυͷ ܕ͕͍ͭͯ ͍ͳ͍ ղܾ:
rbs prototype rb ՝: ͍Ζ ͍ΖඇରԠ ղܾ: rbs prototype runtime autoloadඇରԠ ͍
.*9* 30 ղܾ ՝: Ξϓ Ϧέʔγϣ ϯίʔυͷ ܕ͕͍ͭͯ ͍ͳ͍ ղܾ:
rbs prototype rb ՝: ͍Ζ ͍ΖඇରԠ ղܾ: rbs prototype runtime Pull Request ՝: ͍Ζ ͍Ζ͕
.*9* 31 rbs prototype rb rbs prototype runtime eval ActiveSupport::
Concern Generics delegate autoload Speed
.*9* 32 ՝ ՝: Ξϓ Ϧέʔγϣ ϯίʔυͷ ܕ͕͍ͭͯ ͍ͳ͍ ղܾ:
rbs prototype rb ՝: ͍Ζ ͍ΖඇରԠ ղܾ: rbs prototype runtime ActiveRecord Plugins ͬͱػೳΛʂ untyped Gemͷܕ
None
.*9* 34 ͜͜Ͱ
None
.*9* 36 ղܾ orthoses
https://speakerdeck.com/ksss/rbs-generation-framework-using-rack-architecture
https://speakerdeck.com/ksss/rbs-generation-framework-using-rack-architecture Orthoses::Builder.new do use Orthoses::CreateFileByName use Orthoses::Mid, option: true use
Orthoses::Tap do |store| store["Foo"] << "def foo: () -> void" end use Orthoses::Mixin run -> { require '...' } end
.*9* 39 orthoses More Feature Extending Customizing Filtering Split files
Deduping
.*9* rbs prototype rb rbs prototype runtime orthoses eval ActiveSupport::
Concern Generics delegate autoload Speed Extensibility
.*9* 41 ՝ “orthoses” ͕ಡΊͳ͍
.*9* 42 ղܾ
.*9* 43 ՝ rakeͷΤϥʔ͕Θ͔ Γʹ͍͘
None
None
None
.*9* 47 ղܾ #detailed_message
.*9* 48 ՝ rakeλεΫͷσ όοά͕͍͠
$ bundle exec rdbg -c -- bin/rails orthoses:rails
.*9* 50 ղܾ RAKE_DEBUG=1
$ RAKE_DEBUG=1 bin/rails orthoses:rails
.*9* 52 ՝ YARDͷࢿ࢈Λ ྲྀ༻͍ͨ͠
.*9* 53 ղܾ orthoses-yard
.*9* 54 orthoses-yard # @param [String] str # @return [Integer]
def str_to_i(str) str.to_i end def str_to_i: (String str) -> Integer .rb .rbs
खॻ͖ ͷน
खॻ͖ ͷน orthoses-yard
.*9* 57 ՝ YARDΛؒҧ͑Δ ͱ RBSؒҧ͏
.*9* 58 YARDҙ֎ͱ͍͠ # @param [String|Symbol] # @param [Hash<Symbol, String>]
h # @param [String] s def foo(str) ʁ ʁ ʁ
.*9* 59 YARDҙ֎ͱ͍͠ # @param [String|Symbol] # @param [Hash<Symbol, String>]
h # @param [String] s def foo(str) SyntaxError Hash[Symbol | String] def foo: (untyped str) -> untyped
.*9* 60 I have a rubocop
.*9* 61 and I have a yard
.*9* 62
.*9* 63 rubocop-yard ղܾ
.*9* 64 rubocop-yard
.*9* 65 rubocop-yard
.*9* 66 rubocop-yard
.*9* 67 rubocop-yard
खॻ͖ ͷน orthoses-yard rubocop-yard
.*9* 69 ·ͱΊ orthoses use Orthoses::LoadRBS use Orthoses::YARD use Orthoses::RBSPrototypeRuntime
use Orthoses::Rails Rails×ܕͷੈքͷఏҊ use Your::Middleware
.*9* 70