Kaigi on Rails 2023 at 浅草橋ヒューリックホール&カンファレンス
.*9*RailsͷܕϑΝΠϧࣗಈੜʹ͓͚Δ՝ͱղܾ,BJHJPO3BJMT%BZ
View Slide
Kaigi on Rails 2023day 2
.*9*܀ݪ༐थ@ksssKurihara YukiRailsྺ9ΈͯͶϓϩμΫτ։ൃ෦ॴଐ
.*9*7https://github.com/ruby/rbs/graphs/contributors
.*9*9
.*9*10Rails×ܕRBS
.*9*11՝RailsΞϓϦखܰʹܕΛಋೖ͍ͨ͠
.*9*12ղܾ orthoses-rails
.*9*13orthoses-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*14orthoses-railsActionMailerActiveModelActiveRecordActiveStorageActiveSupport
.*9*15.rb .rbs
.*9*16ܗظFormingࠞཚظStorming౷ҰظNormingػೳظPerforming͜͜·Ͱ ͜Ε͔ΒRails×ܕͷੈք
.*9*17՝ RBSΛಋೖͨ͠ͷʹ୭ͬͯͳ͍
.*9*18ղܾੜͨ͠3#4ΛDPNNJU͢ΔɻRBSϋϯζΦϯΛෳճ࣮ࢪɻ
.*9*20՝ΞϓϦέʔγϣϯίʔυͷܕ͕͍͍ͭͯͳ͍
.*9*21ղܾ શ෦खͰ3#4Λॻ͘՝: ΞϓϦέʔγϣϯίʔυͷܕ͕͍͍ͭͯͳ͍
.*9*23ղܾ ࣗಈੜ՝: ΞϓϦέʔγϣϯίʔυͷܕ͕͍͍ͭͯͳ͍
.*9*24ղܾ rbs prototype rb՝: ΞϓϦέʔγϣϯίʔυͷܕ͕͍͍ͭͯͳ͍
.*9*25՝՝: ΞϓϦέʔγϣϯίʔυͷܕ͕͍͍ͭͯͳ͍ղܾ: rbsprototype rbeval, define_methodActiveSupport::ConcernArray, Hash, Enumerabledelegate
.*9*26rbs prototype rbevalActiveSupport::ConcernGenericsdelegate
.*9*27ղܾ rbs prototype runtime՝: ΞϓϦέʔγϣϯίʔυͷܕ͕͍͍ͭͯͳ͍ղܾ: rbsprototype rb՝: ͍Ζ͍ΖඇରԠ
.*9*28rbs prototype rbrbs prototyperuntimeevalActiveSupport::ConcernGenericsdelegate
.*9*29՝՝: ΞϓϦέʔγϣϯίʔυͷܕ͕͍͍ͭͯͳ͍ղܾ: rbsprototype rb՝: ͍Ζ͍ΖඇରԠղܾ: rbsprototyperuntimeautoloadඇରԠ͍
.*9*30ղܾ՝: ΞϓϦέʔγϣϯίʔυͷܕ͕͍͍ͭͯͳ͍ղܾ: rbsprototype rb՝: ͍Ζ͍ΖඇରԠղܾ: rbsprototyperuntimePull Request՝: ͍Ζ͍Ζ͕
.*9*31rbs prototype rbrbs prototyperuntimeevalActiveSupport::ConcernGenericsdelegateautoloadSpeed
.*9*32՝՝: ΞϓϦέʔγϣϯίʔυͷܕ͕͍͍ͭͯͳ͍ղܾ: rbsprototype rb՝: ͍Ζ͍ΖඇରԠղܾ: rbsprototyperuntimeActiveRecord PluginsͬͱػೳΛʂuntypedGemͷܕ
.*9*34͜͜Ͱ
.*9*36ղܾ orthoses
https://speakerdeck.com/ksss/rbs-generation-framework-using-rack-architecture
https://speakerdeck.com/ksss/rbs-generation-framework-using-rack-architectureOrthoses::Builder.new douse Orthoses::CreateFileByNameuse Orthoses::Mid, option: trueuse Orthoses::Tap do |store|store["Foo"] << "def foo: () -> void"enduse Orthoses::Mixinrun -> { require '...' }end
.*9*39orthosesMore FeatureExtendingCustomizingFilteringSplit filesDeduping
.*9*rbs prototype rbrbs prototyperuntimeorthosesevalActiveSupport::ConcernGenericsdelegateautoloadSpeedExtensibility
.*9*41՝ “orthoses”͕ಡΊͳ͍
.*9*42ղܾ
.*9*43՝ rakeͷΤϥʔ͕Θ͔Γʹ͍͘
.*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*54orthoses-yard# @param [String] str# @return [Integer]def str_to_i(str)str.to_ienddef str_to_i: (String str) -> Integer.rb.rbs
खॻ͖ͷน
खॻ͖ͷนorthoses-yard
.*9*57՝YARDΛؒҧ͑ΔͱRBSؒҧ͏
.*9*58YARDҙ֎ͱ͍͠# @param [String|Symbol]# @param [Hash] h# @param [String] sdef foo(str)ʁʁʁ
.*9*59YARDҙ֎ͱ͍͠# @param [String|Symbol]# @param [Hash] h# @param [String] sdef foo(str)SyntaxErrorHash[Symbol | String]def foo: (untyped str) -> untyped
.*9*60I have a rubocop
.*9*61and I have a yard
.*9*62
.*9*63rubocop-yardղܾ
.*9*64rubocop-yard
.*9*65rubocop-yard
.*9*66rubocop-yard
.*9*67rubocop-yard
खॻ͖ͷนorthoses-yardrubocop-yard
.*9*69·ͱΊorthosesuse Orthoses::LoadRBSuse Orthoses::YARDuse Orthoses::RBSPrototypeRuntimeuse Orthoses::RailsRails×ܕͷੈքͷఏҊuse Your::Middleware
.*9*70