Slide 1

Slide 1 text

˜.*9* RailsͷܕϑΝΠϧࣗಈੜ੒ʹ͓͚Δ ՝୊ͱղܾ ,BJHJPO3BJMT%BZ

Slide 2

Slide 2 text

Kaigi on Rails 2023 day 2

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

˜.*9* ܀ݪ༐थ @ksss Kurihara Yuki Railsྺ9೥ ΈͯͶϓϩμΫτ։ൃ෦ॴଐ

Slide 7

Slide 7 text

˜.*9* 7 https://github.com/ruby/rbs/graphs/contributors

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

˜.*9* 9

Slide 10

Slide 10 text

˜.*9* 10 Rails×ܕ RBS

Slide 11

Slide 11 text

˜.*9* 11 ՝୊ RailsΞϓϦ΁ खܰʹܕΛಋೖ ͍ͨ͠

Slide 12

Slide 12 text

˜.*9* 12 ղܾ orthoses-rails

Slide 13

Slide 13 text

˜.*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

Slide 14

Slide 14 text

˜.*9* 14 orthoses-rails ActionMailer ActiveModel ActiveRecord ActiveStorage ActiveSupport

Slide 15

Slide 15 text

˜.*9* 15 .rb .rbs

Slide 16

Slide 16 text

˜.*9* 16 ܗ੒ظ Forming ࠞཚظ Storming ౷Ұظ Norming ػೳظ Performing ͜͜·Ͱ ͜Ε͔Β Rails×ܕͷੈք

Slide 17

Slide 17 text

˜.*9* 17 ՝୊ RBSΛಋೖͨ͠ͷ ʹ୭΋࢖ͬͯͳ͍

Slide 18

Slide 18 text

˜.*9* 18 ղܾ ੜ੒ͨ͠3#4Λ DPNNJU͢Δɻ RBSϋϯζΦϯΛ ෳ਺ճ࣮ࢪɻ

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

˜.*9* 20 ՝୊ ΞϓϦέʔγϣϯ ίʔυͷ ܕ͕͍͍ͭͯͳ͍

Slide 21

Slide 21 text

˜.*9* 21 ղܾ શ෦खͰ3#4Λॻ͘ ՝୊: ΞϓϦ έʔγϣϯ ίʔυͷ ܕ͕͍ͭͯ ͍ͳ͍

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

˜.*9* 23 ղܾ ࣗಈੜ੒ ՝୊: ΞϓϦ έʔγϣϯ ίʔυͷ ܕ͕͍ͭͯ ͍ͳ͍

Slide 24

Slide 24 text

˜.*9* 24 ղܾ rbs prototype rb ՝୊: ΞϓϦ έʔγϣϯ ίʔυͷ ܕ͕͍ͭͯ ͍ͳ͍

Slide 25

Slide 25 text

˜.*9* 25 ՝୊ ՝୊: Ξϓ Ϧέʔγϣ ϯίʔυͷ ܕ͕͍ͭͯ ͍ͳ͍ ղܾ: rbs prototype rb eval, define_method ActiveSupport::Concern Array, Hash, Enumerable delegate

Slide 26

Slide 26 text

˜.*9* 26 rbs prototype rb eval ActiveSupport:: Concern Generics delegate

Slide 27

Slide 27 text

˜.*9* 27 ղܾ rbs prototype runtime ՝୊: Ξϓ Ϧέʔγϣ ϯίʔυͷ ܕ͕͍ͭͯ ͍ͳ͍ ղܾ: rbs prototype rb ՝୊: ͍Ζ ͍ΖඇରԠ

Slide 28

Slide 28 text

˜.*9* 28 rbs prototype rb rbs prototype runtime eval ActiveSupport:: Concern Generics delegate

Slide 29

Slide 29 text

˜.*9* 29 ՝୊ ՝୊: Ξϓ Ϧέʔγϣ ϯίʔυͷ ܕ͕͍ͭͯ ͍ͳ͍ ղܾ: rbs prototype rb ՝୊: ͍Ζ ͍ΖඇରԠ ղܾ: rbs prototype runtime autoloadඇରԠ ஗͍

Slide 30

Slide 30 text

˜.*9* 30 ղܾ ՝୊: Ξϓ Ϧέʔγϣ ϯίʔυͷ ܕ͕͍ͭͯ ͍ͳ͍ ղܾ: rbs prototype rb ՝୊: ͍Ζ ͍ΖඇରԠ ղܾ: rbs prototype runtime Pull Request ՝୊: ͍Ζ ͍Ζ໰୊͕

Slide 31

Slide 31 text

˜.*9* 31 rbs prototype rb rbs prototype runtime eval ActiveSupport:: Concern Generics delegate autoload Speed

Slide 32

Slide 32 text

˜.*9* 32 ՝୊ ՝୊: Ξϓ Ϧέʔγϣ ϯίʔυͷ ܕ͕͍ͭͯ ͍ͳ͍ ղܾ: rbs prototype rb ՝୊: ͍Ζ ͍ΖඇରԠ ղܾ: rbs prototype runtime ActiveRecord Plugins ΋ͬͱػೳΛʂ untyped Gemͷܕ

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

˜.*9* 34 ͜͜Ͱ ൒෼

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

˜.*9* 36 ղܾ orthoses

Slide 37

Slide 37 text

https://speakerdeck.com/ksss/rbs-generation-framework-using-rack-architecture

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

˜.*9* 39 orthoses More Feature Extending Customizing Filtering Split files Deduping

Slide 40

Slide 40 text

˜.*9* rbs prototype rb rbs prototype runtime orthoses eval ActiveSupport:: Concern Generics delegate autoload Speed Extensibility

Slide 41

Slide 41 text

˜.*9* 41 ՝୊ “orthoses” ͕ಡΊͳ͍

Slide 42

Slide 42 text

˜.*9* 42 ղܾ

Slide 43

Slide 43 text

˜.*9* 43 ՝୊ rakeͷΤϥʔ͕Θ͔ Γʹ͍͘

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

˜.*9* 47 ղܾ #detailed_message

Slide 48

Slide 48 text

˜.*9* 48 ՝୊ rakeλεΫͷσ όοά͕೉͍͠

Slide 49

Slide 49 text

$ bundle exec rdbg -c -- bin/rails orthoses:rails

Slide 50

Slide 50 text

˜.*9* 50 ղܾ RAKE_DEBUG=1

Slide 51

Slide 51 text

$ RAKE_DEBUG=1 bin/rails orthoses:rails

Slide 52

Slide 52 text

˜.*9* 52 ՝୊ YARDͷࢿ࢈Λ ྲྀ༻͍ͨ͠

Slide 53

Slide 53 text

˜.*9* 53 ղܾ orthoses-yard

Slide 54

Slide 54 text

˜.*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

Slide 55

Slide 55 text

खॻ͖ ͷน

Slide 56

Slide 56 text

खॻ͖ ͷน orthoses-yard

Slide 57

Slide 57 text

˜.*9* 57 ՝୊ YARDΛؒҧ͑Δ ͱ RBS΋ؒҧ͏

Slide 58

Slide 58 text

˜.*9* 58 YARD͸ҙ֎ͱ೉͍͠ # @param [String|Symbol] # @param [Hash] h # @param [String] s def foo(str) ʁ ʁ ʁ

Slide 59

Slide 59 text

˜.*9* 59 YARD͸ҙ֎ͱ೉͍͠ # @param [String|Symbol] # @param [Hash] h # @param [String] s def foo(str) SyntaxError Hash[Symbol | String] def foo: (untyped str) -> untyped

Slide 60

Slide 60 text

˜.*9* 60 I have a rubocop

Slide 61

Slide 61 text

˜.*9* 61 and I have a yard

Slide 62

Slide 62 text

˜.*9* 62

Slide 63

Slide 63 text

˜.*9* 63 rubocop-yard ղܾ

Slide 64

Slide 64 text

˜.*9* 64 rubocop-yard

Slide 65

Slide 65 text

˜.*9* 65 rubocop-yard

Slide 66

Slide 66 text

˜.*9* 66 rubocop-yard

Slide 67

Slide 67 text

˜.*9* 67 rubocop-yard

Slide 68

Slide 68 text

खॻ͖ ͷน orthoses-yard rubocop-yard

Slide 69

Slide 69 text

˜.*9* 69 ·ͱΊ orthoses use Orthoses::LoadRBS use Orthoses::YARD use Orthoses::RBSPrototypeRuntime use Orthoses::Rails Rails×ܕͷੈք΁ͷఏҊ use Your::Middleware

Slide 70

Slide 70 text

˜.*9* 70