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
430
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
Progressive Web Apps für Desktop und Mobile mit Angular (Hands-on)
christianliebel
PRO
0
110
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
9
980
Android 15 でアクションバー表示時にステータスバーが白くなってしまう問題
tonionagauzzi
0
140
レガシーな Android アプリのリアーキテクチャ戦略
oidy
1
170
cXML という電子商取引の トランザクションを支える プロトコルと向きあっている話
phigasui
3
2.2k
Piniaの現状と今後
waka292
5
1.4k
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
420
Dev ContainersとGitHub Codespacesの素敵な関係
ymd65536
1
120
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
1
290
Java ジェネリクス入門 2024
nagise
0
600
現場で役立つモデリング 超入門
masuda220
PRO
12
2.9k
CSC305 Lecture 13
javiergs
PRO
0
130
Featured
See All Featured
It's Worth the Effort
3n
183
27k
What's new in Ruby 2.0
geeforr
342
31k
KATA
mclloyd
29
13k
The Language of Interfaces
destraynor
154
24k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
9
680
Teambox: Starting and Learning
jrom
132
8.7k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Art, The Web, and Tiny UX
lynnandtonic
296
20k
StorybookのUI Testing Handbookを読んだ
zakiyama
26
5.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
32
2.4k
Adopting Sorbet at Scale
ufuk
73
9k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
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