Slide 1

Slide 1 text

HOW TO READ HUGE OPEN SOURCE CODE EASILY @yhirano55 at RailsConf 2019

Slide 2

Slide 2 text

self.inspect ➤Yoshiyuki Hirano from JAPAN ➤GitHub: @yhirano55 ➤Twitter: @yoshi_hirano ➤Rails Contributors #62 ➤I’m chief organizer of “Railsdm” ➤I love Rails community

Slide 3

Slide 3 text

Have you ever read Ruby on Rails source code?

Slide 4

Slide 4 text

MORE QUESTIONS ➤Do you know the request/response Lifecycle of Rails application? ➤Do you know the steps of Active Record's create, update, validate, and destroy? ➤Do you know the processing of initialization of Rails application?

Slide 5

Slide 5 text

I do not think many of them actually do

Slide 6

Slide 6 text

To tell the truth,

Slide 7

Slide 7 text

I have not, too

Slide 8

Slide 8 text

I guess we don't have much time and patience

Slide 9

Slide 9 text

Yesterday, I was impressed by Skylight’s sponsor talk. The design of the rack application is really elegant

Slide 10

Slide 10 text

AND.. ➤I want to read the code of its lifecycle of Rails application ➤But I don't want to spend much time to trace the code ➤I want to read source code easily. What would you do?

Slide 11

Slide 11 text

Finally, I've shipped a new RubyGem this morning

Slide 12

Slide 12 text

yhirano55/trace_location

Slide 13

Slide 13 text

DEMO

Slide 14

Slide 14 text

At first, boot rails console, and set request env

Slide 15

Slide 15 text

And execute `Rails.application.call(env)` inside `TraceLocation.trace` block

Slide 16

Slide 16 text

Then it generates a log file

Slide 17

Slide 17 text

It’s traced locations about `Rails.application.call(env)`

Slide 18

Slide 18 text

It’s traced locations about `Rails.application.call(env)` CALL on rails/engine.rb:522 #call

Slide 19

Slide 19 text

It’s traced locations about `Rails.application.call(env)` CALL on rails/application.rb:607 #build_request

Slide 20

Slide 20 text

It helps you can get tracing the processing of the Lifecycle of Rails application easily!!

Slide 21

Slide 21 text

HOW IT WORK? ➤Use TracePoint that is a Ruby standard API ➤TracePoint API is one of the BLACK MAGIC in Ruby

Slide 22

Slide 22 text

IMPLEMENTATION This is TracePoint

Slide 23

Slide 23 text

IMPLEMENTATION Collect logs

Slide 24

Slide 24 text

IMPLEMENTATION Trace events while block call And disable when it finished

Slide 25

Slide 25 text

In making this gem, I used TracePoint for the first time. It makes me really feel so good!!

Slide 26

Slide 26 text

It helps you get deeply understanding Ruby on Rails

Slide 27

Slide 27 text

It's my pleasure to help you enjoy Ruby on Rails

Slide 28

Slide 28 text

self.inspect ➤Yoshiyuki Hirano from JAPAN ➤GitHub: @yhirano55 ➤Twitter: @yoshi_hirano ➤Rails Contributors #62 ➤I’m chief organizer of “Railsdm” ➤I love Rails community

Slide 29

Slide 29 text

We’re going to have a new Ruby on Rails conference The name is…

Slide 30

Slide 30 text

RailsKaigi 2020

Slide 31

Slide 31 text

We hope you join RailsKaigi 2020 in Japan

Slide 32

Slide 32 text

yhirano55/trace_location Thank you so much