Diff Gem
Compare the source code and metadata between two versions of a Ruby gem.
Installation
gem install diff_gem
Or install locally:
gem build diff_gem.gemspec
gem install diff_gem-0.1.0.gem
Usage
Compare Source Code
Compare two versions of a gem:
diff_gem GEM_NAME OLD_VERSION NEW_VERSION
Example:
diff_gem rails 7.0.0 7.0.1
Or use the explicit command:
diff_gem compare rails 7.0.0 7.0.1
Compare Metadata
Compare gem metadata (dependencies, version info, file counts, etc.) without comparing source:
diff_gem metadata rails 7.0.0 7.0.1
Compare Both
Compare metadata and source code together:
diff_gem compare --metadata rails 7.0.0 7.0.1
Cache Management
View cache information:
diff_gem cache info
Clear the cache:
diff_gem cache clear
Custom Cache Directory
You can specify a custom cache directory:
diff_gem --cache-dir /tmp/gem_cache rails 7.0.0 7.0.1
Or set the environment variable:
export DIFF_GEM_CACHE_DIR=/tmp/gem_cache
diff_gem rails 7.0.0 7.0.1
How It Works
Source Comparison:
- Downloads both gem versions from rubygems.org
- Extracts the gem source code to a cache directory
- Runs
diff -r -u -Nto compare the source trees - Displays the unified diff output
Metadata Comparison:
- Downloads gem metadata from rubygems.org
- Extracts and parses the gemspec information
- Compares dependencies, file counts, version requirements, and other metadata
- Displays a structured comparison showing added, removed, and changed fields
Downloaded gems are cached in ~/.diff_gem_cache by default, so subsequent comparisons are faster.
Similar Tools
If diff_gem doesn't meet your needs, you might want to check out these alternatives:
- gemdiff - Compare gem versions with GitHub integration, showing commits between releases and opening diffs in the browser
- gem-compare - Another tool for comparing gem versions with a focus on simplicity
diff_gem focuses on providing both detailed source code diffs and comprehensive metadata comparisons in a command-line interface.
License
MIT