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
440
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
外部システム連携先が10を超えるシステムでのアーキテクチャ設計・実装事例
kiwasaki
1
280
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
1.7k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
240
プロジェクト新規参入者のリードタイム短縮の観点から見る、品質の高いコードとアーキテクチャを保つメリット
d_endo
1
1.1k
Dev ContainersとGitHub Codespacesの素敵な関係
ymd65536
1
140
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
200
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.2k
Outline View in SwiftUI
1024jp
1
300
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
600
讓數據說話:用 Python、Prometheus 和 Grafana 講故事
eddie
0
390
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
2
600
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Happy Clients
brianwarren
97
6.7k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Embracing the Ebb and Flow
colly
84
4.5k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
KATA
mclloyd
29
14k
The Language of Interfaces
destraynor
154
24k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
The Invisible Side of Design
smashingmag
297
50k
Documentation Writing (for coders)
carmenintech
65
4.4k
BBQ
matthewcrist
85
9.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