Slide 1

Slide 1 text

RBS generation framework using Rack architecture

Slide 2

Slide 2 text

ksss Yuki Kurihara READYFOR, inc. From KOKA(ߕլ) in SHIGA

Slide 3

Slide 3 text

Logic model

Slide 4

Slide 4 text

Impact Happy Hacking

Slide 5

Slide 5 text

Outcome Type Everywhere H H

Slide 6

Slide 6 text

Outputs in long Auto Generation Type File T E

Slide 7

Slide 7 text

Outputs In short Implementation Marketing A G T

Slide 8

Slide 8 text

Implementation

Slide 9

Slide 9 text

Issues Needs a lot of Type Needs accuracy Needs expandability Needs flexibility

Slide 10

Slide 10 text

TracePoint TracePoint.new(:call) do |tp| args = tp.parameters.to_h do |op, name| b = tp.binding [name, b.local_variable_get(name).dup] end p [tp.self, args] end.enable(target: target) do require '...' end

Slide 11

Slide 11 text

Needs a New 
 Model Load Before After Feature

Slide 12

Slide 12 text

Rack Architecture

Slide 13

Slide 13 text

use Middleware1 use Middleware2 use Middleware3 run App.new Rack Architecture

Slide 14

Slide 14 text

use Middleware1 use Middleware2 use Middleware3 run -> { require 'library' } Use case for Library

Slide 15

Slide 15 text

require 'library' use Middleware1 use Middleware2 use Middleware3 run -> { Rails.application.eager_load! } Use case for Application

Slide 16

Slide 16 text

Sponsored by

Slide 17

Slide 17 text

Sponsored by

Slide 18

Slide 18 text

New Product

Slide 19

Slide 19 text

Orthoses IUUQTHJUIVCDPNLTTTPSUIPTFT IUUQTFOXJLJQFEJBPSHXJLJ0SUIPUJDT

Slide 20

Slide 20 text

Rack Orthoses class Middleware def initialize(app) @app = app end def call(env) @app.call(env) end end class Middleware def initialize(loader) @loader = loader end def call @loader.call end end

Slide 21

Slide 21 text

Store store = @loader.call pp store #=> { "Foo" => #, "Bar::Baz" => # }

Slide 22

Slide 22 text

Content store = @loader.call store["Foo"] << "def foo: () -> int" store["Foo"] << "alias bar foo" store["Foo"] << "include Baz"

Slide 23

Slide 23 text

CallTracer foo = CallTracer.new store = foo.trace(Foo.method(:foo)) do @loader.call end foo.captures.each do |capture| capture.method.receiver capture.argument[:name] end

Slide 24

Slide 24 text

CallTracer::Lazy foo = CallTracer::Lazy.new store = foo.trace('Foo#foo')) do @loader.call end foo.captures.each do |capture| capture.method.receiver capture.argument[:name] end

Slide 25

Slide 25 text

Builder example 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 26

Slide 26 text

Middleware Example module Orthoses class Mid def initialize(loader, option: false) @loader = loader @option = option end def call foo = Orthoses::CallTracer::Lazy.new store = foo.trace('Foo#foo') do @loader.call end foo.captures.each do |capture| mod = capture.method.receiver name = Utils.module_name(mod) or next store[name] << "def bar: () -> void" end store end

Slide 27

Slide 27 text

Nest to Line VTF VTF VTF

Slide 28

Slide 28 text

Middlewares •include, extend and prepend •attr_accessor, attr_writer and attr_reader •ObjectSpace •Constants •Tap and PP •RBS prototype

Slide 29

Slide 29 text

Middlewares •Load RBS •Filter •Create file by name •Autoload •DelegateClass

Slide 30

Slide 30 text

Orthoses-rails for Application •has_many, has_one and belongs_to •enum •delegated_type •scope •has_secure_password IUUQTHJUIVCDPNLTTTPSUIPTFTSBJMT

Slide 31

Slide 31 text

Orthoses-rails for gems •TimeWithZone •railties •delegate •class_attribute, mattr_accessor IUUQTHJUIVCDPNLTTTPSUIPTFTSBJMT

Slide 32

Slide 32 text

You can create extension gems •orthoses-yard •orthoses-typeprof •orthoses-rolify

Slide 33

Slide 33 text

Feature tasks •gem_rbs_collection •Support Rails Application •Usability •Newcomers

Slide 34

Slide 34 text

Special Thanks QPDLF LP

Slide 35

Slide 35 text

Happy Hacking