Module: Daddy::Cucumber::Diff

Defined in:
lib/daddy/cucumber/diff.rb

Instance Method Summary collapse

Instance Method Details

#diff(file_a, file_b) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/daddy/cucumber/diff.rb', line 22

def diff(file_a, file_b)
  a = File.read(file_a)
  b = File.read(file_b)
  diff = format_diff(Differ.diff(a, b))

  puts file_a
  puts "<pre>#{diff}</pre>"
end

#git_diff(file, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/daddy/cucumber/diff.rb', line 7

def git_diff(file, options = {})
  git = Daddy::Git.new
  a = File.read(file).gsub(/[<>]/, '<' => '&lt;', '>' => '&gt;')
  b = git.show_previous(file, true).gsub(/[<>]/, '<' => '&lt;', '>' => '&gt;')
  diff = format_diff(Differ.diff(a, b))

  show_filename(file, options)
  puts "<pre>#{diff}</pre>"
end

#git_diff_name(*includes) ⇒ Object



17
18
19
20
# File 'lib/daddy/cucumber/diff.rb', line 17

def git_diff_name(*includes)
  git = Daddy::Git.new
  puts '<pre>' + git.git_diff_name(*includes) + '</pre>'
end

#show(file, options = {}) ⇒ Object



31
32
33
34
# File 'lib/daddy/cucumber/diff.rb', line 31

def show(file, options = {})
  show_filename(file, options)
  puts "<pre>#{File.read(file).gsub(/[<>]/, '<' => '&lt;', '>' => '&gt;')}</pre>"
end