class ReqresRspec::Formatters::HTML

Private Instance Methods

cleanup_pattern() click to toggle source
# File lib/reqres_rspec/formatters/html.rb, line 22
def cleanup_pattern
  '*.html'
end
path(filename) click to toggle source
# File lib/reqres_rspec/formatters/html.rb, line 26
def path(filename)
  File.join(ReqresRspec.configuration.templates_path, filename)
end
render(filename, arguments = {}) click to toggle source
# File lib/reqres_rspec/formatters/html.rb, line 30
      def render(filename, arguments = {})
        eval <<-RUBY
          #{ arguments.map {|k, v| "#{k} = #{v}"}.join("\n") }
          ERB.new(File.open(path(filename)).read).result(binding)
        RUBY
      rescue Exception => e
        logger.error "Reqres::Formatters::HTML.render exception #{e.message}"
      end
save(filename, data) click to toggle source
# File lib/reqres_rspec/formatters/html.rb, line 39
def save(filename, data)
  File.write(File.join(output_path, filename), data)
  logger.info "Reqres::Formatters::HTML saved #{path(filename)}"
end
write() click to toggle source
# File lib/reqres_rspec/formatters/html.rb, line 7
def write
  files = {
    'rspec_doc_table_of_content.html' => 'header.erb',
    'index.html' => 'index.erb',
    'panel.html' => 'panel.erb'
  }

  files.each { |filename, template| save(filename, render(template)) }

  @records.each do |record|
    @record = record
    save "rspec_doc_#{record[:filename]}.html", render('spec.erb')
  end
end