About this Ruby comparison
Ruby favours short, expressive methods, so a renamed method or argument can ripple through a file. A Ruby diff shows each line that changed and marks the names that were replaced.
Use it for reviewing a change to a Rails model, comparing two versions of a Rakefile, or checking what a gem update rewrote.
What changed in this sample
- The method
add(a, b)was renamed tosum(x, y). display_result(result)becameshow_result(total).- The threshold went from 15 to 20 and the call now passes 12 and 18 instead of 10 and 20.
Tips for comparing Ruby
- Compare Gemfile.lock
- Lock files are long and mostly unchanged. Fold unchanged keeps only the gems whose versions moved, and the Characters highlight marks the changed version digits.
- Indentation-only changes
- If RuboCop re-indented a file, Ignore whitespace hides those lines.
- ERB templates
- For .erb views, pick HTML highlighting to keep the markup readable.
- Move between changes
- Use the arrows next to the change counter, or Alt + ↓ and Alt + ↑.
How to compare Ruby online
- Paste the older version into Original and the newer one into Changed, or open a file on each side.
- Check that the syntax menu says Ruby, then pick split or unified view.
- Step through the changes with the arrows or Alt ↓, and use Settings for options such as ignoring blank lines.
- Save the comparison in your browser, share a link, or download it as a .diff, HTML or PDF.
Ruby comparison: questions
Can I compare two Ruby files?
Yes. Open or drop them on the panes; Ruby highlighting is picked from the .rb extension.
Does it run the Ruby code?
No, it only compares the text in your browser.
Can I compare YAML fixtures from a Rails app?
Yes. Switch the syntax to YAML, or open the files and it is chosen for you.