class BioDSL::HtmlReport
Class for creating HTML reports from an executed BioDSL
pipeline.
Public Class Methods
Constructor for HtmlReport
.
@param pipeline [BioPeices::Pipeline] Pipeline
object
# File lib/BioDSL/html_report.rb, line 40 def initialize(pipeline) @pipeline = pipeline @commands = pipeline.commands end
Public Instance Methods
Render HTML output.
# File lib/BioDSL/html_report.rb, line 46 def to_html render('layout.html.haml', self, pipeline: @pipeline.to_s, commands: @commands) end
Private Instance Methods
Return the help URL for a given command.
@param command [Symbol] Command
name.
@return [String] HTML link.
# File lib/BioDSL/html_report.rb, line 193 def help_url(command) camel = command.to_s.split('_').map(&:capitalize).join 'http://www.rubydoc.info/gems/BioDSL/' \ "#{BioDSL::VERSION}/BioDSL/#{camel}" end
Detect if any input options are set.
@param options [Hash] Options hash. @option options [String] :input File glob expression.
@return [Boolean]
# File lib/BioDSL/html_report.rb, line 141 def input?(options) if options[:input] true else false end end
Detect if any output options are set.
@param options [Hash] Options hash. @option options [String] :output Path to output file.
@return [Boolean]
# File lib/BioDSL/html_report.rb, line 155 def output?(options) if options[:output] true else false end end
Detect if any PNG file is available.
@param options [Hash] Options hash. @option options [String] :output Path to output file. @option options [Symbol] :terminal Plot type.
@return [Boolean]
# File lib/BioDSL/html_report.rb, line 170 def png?(options) if options[:output] && options[:terminal] && options[:terminal] == :png && File.exist?(options[:output]) true else false end end
Render HTML templates.
@param template [Path] Path to template file. @param scope [Object] Scope. @param args [Hash] Argument hash.
# File lib/BioDSL/html_report.rb, line 58 def render(template, scope, args = {}) Tilt.new(File.join(root_dir, template)).render(scope, args) end
Render HTML command section.
@param command [BioDSL::Command] Command
object.
# File lib/BioDSL/html_report.rb, line 86 def render_command(command, index) render('command.html.haml', self, command: command, index: index) end
Render HTML CSS section.
# File lib/BioDSL/html_report.rb, line 63 def render_css render('css.html.haml', self) end
Render HTML input files section.
@param options [Hash] Command
options hash.
# File lib/BioDSL/html_report.rb, line 109 def render_input_files(options) render('input_files.html.haml', self, files: options_glob(options[:input])) end
Render HTML output file section.
@param options [Hash] Command
options hash.
# File lib/BioDSL/html_report.rb, line 117 def render_output_files(options) render('output_files.html.haml', self, options: options) end
Render HTML overview section.
@param commands [Array] List of commands from a pipeline.
# File lib/BioDSL/html_report.rb, line 79 def render_overview(commands) render('overview.html.haml', self, commands: commands) end
Render HTML pipeline section
@param pipeline [String] String
from BioDSL::Pipeline#to_s
# File lib/BioDSL/html_report.rb, line 70 def render_pipeline(pipeline) pipeline = pipeline.scan(/[^.]+\(.*?\)|[^.(]+/).join(".\n").sub(/\n/, '') render('pipeline.html.haml', self, pipeline: pipeline) end
Render PNG data.
@param options [Hash] Command
options hash.
# File lib/BioDSL/html_report.rb, line 124 def render_png(options) path = options[:output] png_data = 'data:image/png;base64,' File.open(path, 'r') do |ios| png_data << Base64.encode64(ios.read) end render('png.html.haml', self, path: path, png_data: png_data) end
Render HTML status section.
@param command [BioDSL::Command] Command
object.
# File lib/BioDSL/html_report.rb, line 93 def render_status(command) stats = command.status.reject { |k, _| k.to_s[0..3] == 'time' } render('status.html.haml', self, exit_status: command.run_status, statsus: stats) end
Render HTML time section.
@param status [BioDSL::Status] Status object.
# File lib/BioDSL/html_report.rb, line 102 def render_time(status) render('time.html.haml', self, status: status) end
Return the path of the HTML root dir.
@return [String] Root dir.
# File lib/BioDSL/html_report.rb, line 184 def root_dir File.join(File.dirname(__FILE__), '..', '..', 'www') end