Sha256: d674d64baafa8d95aea9c7fb46babe079503cc1ed335dcb5ab0aff36d3a58417
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
# frozen_string_literal: true # ******************************************************************************* # OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC. # See also https://openstudio.net/license # ******************************************************************************* require 'erb' module OpenStudioMeasureTester class Dashboard attr_reader :html # @param test_results_directory [String]: The directory def initialize(test_results_directory) @test_results_directory = test_results_directory erb_file = File.expand_path('templates/dashboard.html.erb', File.dirname(__FILE__)) @template = File.read(erb_file) file = File.read("#{@test_results_directory}/combined_results.json") @data = file @hash = JSON.parse(@data) end def render rendered = ERB.new(@template, trim_mode: nil, eoutvar: '@html').result(binding) save_dir = "#{@test_results_directory}/dashboard" # Render the dashboard FileUtils.mkdir_p save_dir unless Dir.exist? save_dir File.open("#{save_dir}/index.html", 'w') { |file| file.write(rendered) } # copy over all the resource files to display the website correctly. resource_path = File.expand_path('../../dashboard', File.dirname(__FILE__)) # KAF: for some reason, not overwriting the files. delete them from destination first FileUtils.remove_dir("#{save_dir}/css") if Dir.exist? "#{save_dir}/css" FileUtils.remove_dir("#{save_dir}/js") if Dir.exist? "#{save_dir}/js" FileUtils.cp_r("#{resource_path}/css", "#{save_dir}/css", remove_destination: true) FileUtils.cp_r("#{resource_path}/js", "#{save_dir}/js", remove_destination: true) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
openstudio_measure_tester-0.4.0 | lib/openstudio_measure_tester/dashboard.rb |