Class: BundleOutdatedFormatter::HTMLFormatter

Inherits:
Formatter
  • Object
show all
Defined in:
lib/bundle_outdated_formatter/formatter/html_formatter.rb

Overview

Formatter for HTML

Constant Summary

Constants inherited from Formatter

Formatter::GEM_REGEXP, Formatter::GROUPS_REGEXP, Formatter::INSTALLED_REGEXP, Formatter::NEWEST_REGEXP, Formatter::REQUESTED_REGEXP

Instance Method Summary collapse

Methods inherited from Formatter

#read_stdin

Constructor Details

#initialize(options) ⇒ HTMLFormatter

Returns a new instance of HTMLFormatter.



7
8
9
10
11
12
13
# 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

Instance Method Details

#convertObject



15
16
17
18
19
20
21
22
23
24
25
# 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