Upgrade to Pro — share decks privately, control downloads, hide ads and more …

みんなに知って欲しい Meguro.rb

みんなに知って欲しい Meguro.rb

東急 Ruby 会議 #12 LTで、前半は meguro.rb の紹介、後半は yard2steep の紹介 LT をしました!

Nao Minami

July 29, 2018
Tweet

More Decks by Nao Minami

Other Decks in Programming

Transcript

  1. ©2018 Wantedly, Inc. 29.Jul.2018 - Nao Minami (@south37) ΈΜͳʹ஌ͬͯཉ͍͠ YARD

    Ͱ੩తܕ෇͖ Ruby ʢyard2steepʣ ͱࢥͬͨΜͰ͕͢ɻɻɻ
  2. ©2018 Wantedly, Inc. 29.Jul.2018 - Nao Minami (@south37) ΈΜͳʹ஌ͬͯཉ͍͠ YARD

    Ͱ੩తܕ෇͖ Ruby ʢyard2steepʣ ෼Ͱ͸ແཧͦ͏ʂ
  3. ©2018 Wantedly, Inc. 4UFFQͷܕఆٛϑΝΠϧ class Person @name: String @contacts: Array<Email

    | Phone> def initialize: (name: String) -> any def name: -> String def contacts: -> Array<Email | Phone> def guess_country: -> (String | nil) end
  4. ©2018 Wantedly, Inc. 4UFFQͷ1SPT$POT w 1SPT w 3VCZͰ੩తܕݕ͕ࠪग़དྷΔʂιϑτ΢ΣΞ։ൃͷॿ͚ʹͳͬͯ͘ΕΔʂ w $POT

    w ܕఆٛϑΝΠϧͷઐ༻จ๏Λ֮͑Δඞཁ͕͋Δ w ܕఆٛϑΝΠϧΛ͔Βॻ͘ͷ͕େมʂ w ATUFFQTDB⒎PMEAίϚϯυ͕ॿ͚ʹͳͬͯ͘ΕΔ͕ɻɻɻ
  5. ©2018 Wantedly, Inc. 3VCZίʔυΛ༻ҙ͢Δ # lib/parser.rb class AST # @return

    [String] def to_s "AST" end # @param [Hash] opt def traverse!(opt) end end class Parser # @param [String] text # @param [Hash] opt # @return [AST] def parse(text, opt) ast = AST.new ast.traverse!(opt) ast end end
  6. ©2018 Wantedly, Inc. ZBSETUFFQίϚϯυΛ࣮ߦ $ yard2steep lib ZBSETUFFQͰܕఆٛϑΝΠϧΛੜ੒ # sig/parser.rbi

    class AST def to_s: -> String def traverse!: (Hash<any, any>) -> any end class Parser def parse: (String, Hash<any, any>) -> AST end
  7. ©2018 Wantedly, Inc. ܕݕࠪͰࣦഊͤͯ͞ΈΔ # lib/parser.rb class AST # @return

    [String] def to_s "AST" end # @param [Hash] opt def traverse!(opt) end end class Parser # @param [String] text - # @param [Hash] opt + # @param [Hash, nil] opt # @return [AST] - def parse(text, opt) + def parse(text, opt: nil) ast = AST.new ast.traverse!(opt) ast end end
  8. ©2018 Wantedly, Inc. ܕݕࠪͰࣦഊͤͯ͞ΈΔ $ yard2steep lib && steep check

    lib lib/parser.rb:18:18: ArgumentTypeMismatch: receiver=::AST, expected=::Hash<any, any>, actual=(::Hash<any, any> | nil) (opt) ZBSETUFFQͱTUFFQΛ૊Έ߹ΘͤͯܕνΣοΫ ͪΌΜͱɺAOJMAνΣοΫ͍ͯ͠ͳ͍ίʔυͰΤϥʔ ͕ग़ͨʂ
  9. ©2018 Wantedly, Inc. ࠷ۙͷΞοϓσʔτ w ϦϦʔεޙϲ݄Ͱ΍ͬͨ͜ͱ w BUUS@SFBEFSͳͲɺ3VCZͷ૊ΈࠐΈͷNFUBQSPHSBNNJOHܥͷػೳΛTVQQPSU w 3VCZQBSTFSͷվળ

    ࣗલ࣮૷3JQQFSϕʔε΁Ҡߦ  w ఆ਺ͷܕ෇͚ w FUD w ΍Γ͍ͨ͜ͱ w :"3%BOOPUBUJPOͷϦονͳه๏Λαϙʔτ w BUSS@XSJUFS BUUS@BDDFTTPSͳͲͷTVQQPSU