Class: BomDB::Diff::Dwdiff
- Inherits:
-
Object
- Object
- BomDB::Diff::Dwdiff
- Defined in:
- lib/bomdb/diff/dwdiff.rb
Overview
This wraps the command-line tool, dwdiff See linux.die.net/man/1/dwdiff
Instance Method Summary collapse
- #diff(str1, str2) ⇒ Object
-
#initialize(bin = '/usr/local/bin/dwdiff') ⇒ Dwdiff
constructor
A new instance of Dwdiff.
Constructor Details
#initialize(bin = '/usr/local/bin/dwdiff') ⇒ Dwdiff
Returns a new instance of Dwdiff.
8 9 10 |
# File 'lib/bomdb/diff/dwdiff.rb', line 8 def initialize(bin = '/usr/local/bin/dwdiff') @bin = bin end |
Instance Method Details
#diff(str1, str2) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bomdb/diff/dwdiff.rb', line 12 def diff(str1, str2) Dir.mktmpdir("bomdb") do |dir| file1 = File.join(dir, "file1.txt") file2 = File.join(dir, "file2.txt") File.open(file1, "w"){ |f1| f1.write(str1) } File.open(file2, "w"){ |f2| f2.write(str2) } # -w : start-delete marker, {- # -x : end-delete marker, -} # -y : start-insert marker, {+ # -z : end-insert marker, +} # -P : use punctuation characters as delimiters `#{@bin} -w'{-' -x'-}' -y'{+' -z'+}' -P #{file1} #{file2}` end end |