class Cucumber::HTMLFormatter::Formatter

Attributes

out[R]

Public Class Methods

new(out) click to toggle source
# File lib/cucumber/html_formatter.rb, line 10
def initialize(out)
  @out = out
  @pre_message_written = false
  @first_message = true
end

Public Instance Methods

process_messages(messages) click to toggle source
# File lib/cucumber/html_formatter.rb, line 16
def process_messages(messages)
  write_pre_message
  messages.each { |message| write_message(message) }
  write_post_message
end
write_message(message) click to toggle source
# File lib/cucumber/html_formatter.rb, line 29
def write_message(message)
  unless @first_message
    out.puts(',')
  end
  out.print(message.to_json)

  @first_message = false
end
write_post_message() click to toggle source
# File lib/cucumber/html_formatter.rb, line 38
def write_post_message
  out.print(post_message)
end
write_pre_message() click to toggle source
# File lib/cucumber/html_formatter.rb, line 22
def write_pre_message
  return if @pre_message_written

  out.puts(pre_message)
  @pre_message_written = true
end

Private Instance Methods

assets_loader() click to toggle source
# File lib/cucumber/html_formatter.rb, line 44
def assets_loader
  @assets_loader ||= AssetsLoader.new
end
post_message() click to toggle source
# File lib/cucumber/html_formatter.rb, line 56
def post_message
  [
    template_writer.write_between('{{messages}}', '{{script}}'),
    assets_loader.script,
    template_writer.write_between('{{script}}', nil)
  ].join("\n")
end
pre_message() click to toggle source
# File lib/cucumber/html_formatter.rb, line 48
def pre_message
  [
    template_writer.write_between(nil, '{{css}}'),
    assets_loader.css,
    template_writer.write_between('{{css}}', '{{messages}}')
  ].join("\n")
end
template_writer() click to toggle source
# File lib/cucumber/html_formatter.rb, line 64
def template_writer
  @template_writer ||= TemplateWriter.new(assets_loader.template)
end