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.3k
Railsの型ファイル自動生成における課題と解決
Kaigi on Rails 2023 at 浅草橋ヒューリックホール&カンファレンス
ksss
October 28, 2023
Tweet
Share
More Decks by ksss
See All by ksss
RaaP
ksss
0
490
RBS generation framework using Rack architecture
ksss
1
6.9k
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
第5回日本眼科AI学会総会_AIコンテスト_3位解法
neilsaw
0
170
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
320
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
910
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
170
useSyncExternalStoreを使いまくる
ssssota
6
1k
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
testcontainers のススメ
sgash708
1
120
From Translations to Multi Dimension Entities
alexanderschranz
2
120
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
760
「Chatwork」Android版アプリを 支える単体テストの現在
okuzawats
0
170
事業成長を爆速で進めてきたプロダクトエンジニアたちの成功談・失敗談
nealle
3
1.4k
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
160
Featured
See All Featured
Practical Orchestrator
shlominoach
186
10k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Code Reviewing Like a Champion
maltzj
520
39k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Designing for Performance
lara
604
68k
Agile that works and the tools we love
rasmusluckow
328
21k
4 Signs Your Business is Dying
shpigford
181
21k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
How STYLIGHT went responsive
nonsquared
95
5.2k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
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