Class: Origen::Utility::FileDiff::Formatter::Html

Inherits:
Base
  • Object
show all
Defined in:
lib/origen/utility/file_diff.rb

Instance Attribute Summary

Attributes inherited from Base

#file, #source_output, #target_output

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Origen::Utility::FileDiff::Formatter::Base

Instance Method Details

#formatObject



140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/origen/utility/file_diff.rb', line 140

def format
  tag(:style) { content('td{vertical-align: middle} pre{margin: 0px} .added{background-color: lightgreen;}.deleted{background-color: pink;}.changed{background-color: lightgray;}.line{background-color: lightblue}') }
  tag :table, cellpaddig: 0, cellspacing: 0 do
    source_output.each_with_index do |src, i|
      tgt = target_output[i]
      tag :tr do
        tag(:td, class: :line)     { tag(:pre) { content(src.original_number) } }
        tag(:td, class: src.type)  { tag(:pre) { content(src) } }
        tag(:td, class: :line)     { tag(:pre) { content(tgt.original_number) } }
        tag(:td, class: tgt.type)  { tag(:pre) { content(tgt) } }
      end
    end
  end
end