Visually compare deeply nested data structures.
This gem started life as a hack to help me debug monstrous data blobs coming and going from an API. Trying to eyeball two structures each half a screen in size, with mostly equivalent data arranged in different orders, was a great big barrel of no fun!
NOTE: This gem is just barely pupating from "kludgy hack" to "a ruby gem that thinly wraps a kludgy hack". My development objectives for this tool are to increase functionality and to make it easier to use. If the move to a gem proves useful then I'll consider treating the code as something I care about maintaining. Right now it's, well, it's a kludgy hack. Draw your own assumptions (the more dismal the better).
Add this line to your application's Gemfile:
gem 'struct_diff'
And then execute:
$ bundle
Or install it yourself as:
$ gem install struct_diff
require 'struct_diff'
hash1 = { "a" => { "b" => 64, "c" => 13 }}
hash2 = { "a" => { "b" => 63, "c" => 13 }}
StructDiff.hash_cmp h1, h2
# => output rendered to console
TODO: Note that only comparing hashes is currently supported. Eventually
hash_cmp
will become struct_diff
or struct_cmp
and will tolerate Arrays,
and maybe Sets and Structs (but probably YAGNI). Further TODO items can be found
in the TODO file
or issues.
After checking out the repo, run bin/setup
to install dependencies. Then, run
rake spec
to run the tests. You can also run bin/console
for an interactive
prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To
release a new version, update the version number in version.rb
, and then run
bundle exec rake release
, which will create a git tag for the version, push
git commits and tags, and push the .gem
file
to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/dbrady/struct_diff. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the StructDiff project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.