class Origen::Utility::FileDiff::Formatter::Html

Public Instance Methods

format() click to toggle source
# 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

Private Instance Methods

content(inner_text) click to toggle source
# File lib/origen/utility/file_diff.rb, line 165
def content(inner_text)
  file.puts(inner_text.to_s == '' ? ' ' : inner_text)
end
tag(name, options = {}) { || ... } click to toggle source
# File lib/origen/utility/file_diff.rb, line 157
def tag(name, options = {}, &block)
  file.puts %(<#{name})
  file.puts options.collect { |attribute, value| %(#{attribute}="#{value}") }
  file.puts '>'
  yield
  file.puts "</#{name}>"
end