similar.cr
similar
A Crystal port of the Rust similar diff library.
Installation
Add this to your application's shard.yml:
dependencies:
similar:
github: dsisnero/similar
Then run:
shards install
Usage
Basic text diff:
require "similar"
diff = Similar::TextDiff.from_lines("a\nb\n", "a\nB\n")
diff.iter_all_changes.each do |change|
puts "#{change.tag}: #{change.value}"
end
Unified diff:
require "similar"
old_text = "Hello\nWorld\n"
new_text = "Hello\nCrystal\n"
diff = Similar::TextDiff.from_lines(old_text, new_text)
puts diff.unified_diff.header("old.txt", "new.txt").to_s
Close matches:
require "similar"
matches = Similar.get_close_matches("appel", ["ape", "apple", "peach", "puppy"], 3, 0.6)
pp matches
Development
Run formatting, linting, and specs:
crystal tool format
ameba --fix
ameba
crystal spec
Contributing
- Fork it (https://github.com/dsisnero/similar/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- dsisnero - creator and maintainer
Repository
similar.cr
Owner
Statistic
- 0
- 0
- 0
- 1
- 1
- 5 days ago
- January 30, 2026
License
MIT License
Links
Synced at
Mon, 02 Feb 2026 00:17:55 GMT
Languages