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

HOW TO READ HUGE OPEN SOURCE CODE EASILY

HOW TO READ HUGE OPEN SOURCE CODE EASILY

for RailsConf 2019 LT

yhirano55

May 01, 2019
Tweet

More Decks by yhirano55

Other Decks in Technology

Transcript

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

    View full-size slide

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

    View full-size slide

  3. Have you ever read
    Ruby on Rails
    source code?

    View full-size slide

  4. 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?

    View full-size slide

  5. I do not think many
    of them actually do

    View full-size slide

  6. To tell the truth,

    View full-size slide

  7. I have not, too

    View full-size slide

  8. I guess we don't
    have much time
    and patience

    View full-size slide

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

    View full-size slide

  10. 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?

    View full-size slide

  11. Finally, I've shipped
    a new RubyGem this morning

    View full-size slide

  12. yhirano55/trace_location

    View full-size slide

  13. At first, boot rails console, and set request env

    View full-size slide

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

    View full-size slide

  15. Then it generates a log file

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  21. IMPLEMENTATION
    This is TracePoint

    View full-size slide

  22. IMPLEMENTATION
    Collect logs

    View full-size slide

  23. IMPLEMENTATION
    Trace events while block call
    And disable when it finished

    View full-size slide

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

    View full-size slide

  25. It helps you get deeply
    understanding Ruby on Rails

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  29. RailsKaigi 2020

    View full-size slide

  30. We hope you join
    RailsKaigi 2020 in
    Japan

    View full-size slide

  31. yhirano55/trace_location
    Thank you so much

    View full-size slide