- Get into a library
- bundle open wicked
- Make sure you've set your
$EDITOR
- Forget fancy debuggers
- All you need is
puts
- A rubyist's tracer round:
puts "================="
- All you need is
- Notation
ClassOrModule#instance_method
ClassOrModule.class_method
- Problem: Where is this method being called?
Kernel#caller
gives you the backtraceputs caller.inspect
- Problem: Where is this method defined?
Object#method
returns aMethod
Method#source_location
returns file and line numberUser.last.method(:github_url).source_location
- 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
- You can use
self.class.ancestors.each do |klass|
next unless klass.method_defined?(:method_we_are_looking_for)
puts klass.instance_method(:method_we_are_looking_for).source_location
end
- 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:
Object#methods
Module#instance_methods
- Slides are here!!!
- Go from bug reporter to bug fixer!