Module: Wdiff

Defined in:
lib/wdiff.rb

Defined Under Namespace

Modules: Helper

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.bin_pathObject



10
11
12
# File 'lib/wdiff.rb', line 10

def bin_path
  'wdiff'
end

.included(target) ⇒ Object



3
4
5
# File 'lib/wdiff.rb', line 3

def included(target)
  verify_wdiff_in_path
end

.verify_wdiff_in_pathObject



6
7
8
9
# File 'lib/wdiff.rb', line 6

def verify_wdiff_in_path
  path = %x{which #{bin_path}}
  raise "GNU wdiff (http://www.gnu.org/software/wdiff/) not found in $PATH" if path.empty?
end

Instance Method Details

#wdiff(str_new) ⇒ Object



15
16
17
18
19
# File 'lib/wdiff.rb', line 15

def wdiff(str_new)
  cmd = "bash -c '#{Wdiff::bin_path} <(echo \"#{self}\") <(echo \"#{str_new}\")'"
  raw = %x{#{cmd}}
  raw.chop unless raw.nil?
end