Class: HtmlDiffRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/wiki_renderer.rb

Instance Method Summary collapse

Instance Method Details

#get_resultObject



75
76
77
78
79
# File 'lib/wiki_renderer.rb', line 75

def get_result
  inject(@diff_words, @removed_text, @inserted_text)
  
  @diff_words.xml_join
end

#render_html_diff(old_html, new_html) ⇒ Object



55
56
57
58
# File 'lib/wiki_renderer.rb', line 55

def render_html_diff(old_html, new_html)
  @diff_words = @removed_text = @inserted_text = []
  Differ.new(self).diff(old_html.xml_split, new_html.xml_split)
end

#start_new_chunk(action) ⇒ Object



60
61
62
63
64
# File 'lib/wiki_renderer.rb', line 60

def start_new_chunk(action)
  inject(@diff_words, @removed_text, @inserted_text)
  @removed_text = []
  @inserted_text = []
end

#store_diff(sdiff) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/wiki_renderer.rb', line 66

def store_diff(sdiff)
  if '=' == sdiff.action
    @diff_words << sdiff.old_element
  else
    @removed_text  << sdiff.old_element unless sdiff.old_element.nil?
    @inserted_text << sdiff.new_element unless sdiff.new_element.nil?
  end
end