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
flutterkaigi_2024.pdf
kyoheig3
0
150
CSC509 Lecture 12
javiergs
PRO
0
160
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
610
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
Micro Frontends Unmasked Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
110
[Do iOS '24] Ship your app on a Friday...and enjoy your weekend!
polpielladev
0
110
初めてDefinitelyTypedにPRを出した話
syumai
0
420
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
630
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
109
49k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Music & Morning Musume
bryan
46
6.2k
Documentation Writing (for coders)
carmenintech
65
4.4k
For a Future-Friendly Web
brad_frost
175
9.4k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
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