# -*- coding: utf-8 -*-
require 'erb'
require 'rspec/core/formatters/helpers'
require 'turnip_formatter/template/tab/speed_statistics'
require 'turnip_formatter/template/tab/feature_statistics'
require 'turnip_formatter/template/tab/tag_statistics'
require 'sass'
module TurnipFormatter
class Template
include ERB::Util
include RSpec::Core::BacktraceFormatter
class << self
def add_js(js_string)
js_list << js_string
end
def js_render
js_list.join("\n")
end
def css_render
css_list.join("\n")
end
def add_scss(scss_string)
css_list << scss_compile(scss_string)
end
def js_list
@js_list ||= []
end
def css_list
@css_list ||= []
end
def scss_compile(scss)
Sass::Engine.new(scss, syntax: :scss).render
end
end
def print_header
<<-EOS
EOS
end
def print_main_header
<<-EOS
EOS
end
def print_main_footer(total_count, failed_count, pending_count, total_time)
update_report_js_tmp = ''
update_report_js = ''
%w{ total_count failed_count pending_count total_time }.each do |key|
update_report_js += update_report_js_tmp % [key, eval(key)]
end
"#{update_report_js}
"
end
def print_tab_speed_statsitics(passed_scenarios)
statistics = TurnipFormatter::Template::Tab::SpeedStatistics.new(passed_scenarios)
<<-EOS
Ranking of running time of each successfully scenario:
#{statistics.build}
EOS
end
def print_tab_feature_statsitics(scenarios)
statistics = TurnipFormatter::Template::Tab::FeatureStatistics.new(scenarios)
<<-EOS
The results for the feature:
#{statistics.build}
EOS
end
def print_tab_tag_statsitics(scenarios)
statistics = TurnipFormatter::Template::Tab::TagStatistics.new(scenarios)
<<-EOS
The results for the tab:
#{statistics.build}
EOS
end
def print_footer
<<-EOS