class BundleOutdatedFormatter::HTMLFormatter
Formatter
for HTML
Public Class Methods
new(options)
click to toggle source
Calls superclass method
BundleOutdatedFormatter::Formatter::new
# File lib/bundle_outdated_formatter/formatter/html_formatter.rb, line 7 def initialize(options) super(options) @html = REXML::Document.new(nil, raw: :all) @root = REXML::Element.new('table') @html.add_element(@root) end
Public Instance Methods
convert()
click to toggle source
# File lib/bundle_outdated_formatter/formatter/html_formatter.rb, line 15 def convert add_header_row @outdated_gems.each do |gem| add_data_row(gem) end io = StringIO.new xml_formatter.write(@html, io) io.string.chomp end
Private Instance Methods
add_data_row(gem)
click to toggle source
# File lib/bundle_outdated_formatter/formatter/html_formatter.rb, line 37 def add_data_row(gem) elements = @root.add_element(REXML::Element.new('tr')) @columns.each do |column| escaped_text = REXML::Text.new(gem[column], false, nil, false) elements.add_element('td').add_text(escaped_text) end end
add_header_row()
click to toggle source
# File lib/bundle_outdated_formatter/formatter/html_formatter.rb, line 29 def add_header_row elements = @root.add_element(REXML::Element.new('tr')) @columns.each do |column| elements.add_element('th').add_text(column) end end