Dissecting Ruby with Ruby
Richard Schneeman (@schneems)
- Get into a library
- bundle open wicked
- Make sure you've set your
- Forget fancy debuggers
- All you need is
- A rubyist's tracer round:
- Problem: Where is this method being called?
Kernel#caller gives you the backtrace
- Problem: Where is this method defined?
Object#method returns a
Method#source_location returns file and line number
- Great for when you grep for a method and see it defined in a bunch of place
- If you see
super and want to see what it'll do...
- You can use
self.class.ancestors to see where it'll get called
- But that can return a crapload of ancestors
User.instance_method(:github_url).source_location same as above, but for an instance method
self.class.ancestors.each do |klass|
next unless klass.method_defined?(:method_we_are_looking_for)
- Keep following the source by applying these tools
- For developing OSS:
- Open an issue
- Reproduce the bug
- Attempt a fix
- At least raise awareness
- Find the right prbolem, and the solution becomes obvious(ish)
- Other fun tools:
- Slides are here!!!
- Go from bug reporter to bug fixer!